Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DispenserItemBehavior for flint and brick. #5029

Open
wants to merge 2 commits into
base: 1.18.2
Choose a base branch
from

Conversation

Waterpicker
Copy link
Contributor

No description provided.

@KnightMiner KnightMiner added Feature For pull requests adding in new content, and occasionally larger enhancements 1.18 Issue affects 1.18 labels Nov 26, 2022
@KnightMiner
Copy link
Member

General comments, will leave specific code comments later

  • I cannot get the flint and brick to light fires at all, with no modifiers it should work identically to flint and steel. Use whatever logic it has to determine side hit for other modifier logic
  • Glowing, pathing, stripping, and tilling seem to work as expected. Turns out pathing is the one that had unique behavior, but that is handled automatically with how you wrote the code
  • Regarding expanders, it seems for firestarter expanded and fireprimer act identically, so together they can give a radius 2 circle. On anything else (tilling, stripping, pathing, glowing) it currently does nothing as its technically impossible to get both. Not sure we need to support both, if you wish to you could always hardcode it to circle.

* @param stack Stack being dispensed
* @return True if dispenser action was taken
*/
public boolean onDispenserUse(IToolStackView tool, int level, BlockSource source, ItemStack stack) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the item stack parameter? I generally leave it out of modifier hooks as people should be using the tool stack.

Looks like you use it to create a use on context below if I am understanding the code, double check if that is avoidable, if not modify the javadoc to be clear about the relationship between the tool and the stack and that the stack should not be used to create a ToolStack instance.

Direction width, height;
// for Y, direction is based on facing
if (sideHit.getAxis() == Direction.Axis.Y) {
height = harvestDirection;
Copy link
Member

@KnightMiner KnightMiner Nov 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, the harvest direction parameter does not matter for circles. It matters for a rectangle as it determines the rectangle orientation and was conveient to reuse the rectangle logic for a circle, but if you are going to extract it I would just ditch the side/player argument entirely (could be accomplished by making player nullable in the above method signature then ignoring it here)

@@ -585,4 +588,8 @@ public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStac
public static BlockHitResult blockRayTrace(Level worldIn, Player player, ClipContext.Fluid fluidMode) {
return Item.getPlayerPOVHitResult(worldIn, player, fluidMode);
}

public static UseOnContext contextFromBlockSource(BlockSource source, ItemStack stack) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs javadoc, and probably belongs in ModifierUtils or one of those similar helper classes. Above method is only here as getPlayerPOVHitResult is protected.

return stack;
};

DispenserBlock.registerBehavior(TinkerTools.flintAndBrick, behavior);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flint and steel fires particles if its unable to do anything. Looks like they use a class called OptionalDispenseItemBehavior for that fallback particle, I suggest using that


// AOE transforming, run even if we did not transform the center
// note we consider anything effective, as hoes are not effective on all tillable blocks
// if (player != null && !tool.isBroken()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets just hardcode to circle AOE here, using the same logic you were planning to use in fireprimer.

@@ -161,4 +165,64 @@ public InteractionResult afterBlockUse(IToolStackView tool, int level, UseOnCont
}
return didIgnite ? InteractionResult.sidedSuccess(world.isClientSide) : InteractionResult.PASS;
}

/** Ignites the given block */
private static boolean igniteDispenser(IToolStackView tool, Level world, BlockPos pos, BlockState state, Direction sideHit, Direction horizontalFacing) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you duplicate this whole method just to remove a nullable player argument? Just call the original method by passing null.

If there are any other differences, add the needed parameter to distinguish the two

@KnightMiner KnightMiner added the Needs Update Issues or PR needs additional action to be taken by the reporter label Dec 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.18 Issue affects 1.18 Feature For pull requests adding in new content, and occasionally larger enhancements Needs Update Issues or PR needs additional action to be taken by the reporter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants