quilt-standard-libraries icon indicating copy to clipboard operation
quilt-standard-libraries copied to clipboard

Event triggered on item usage with QoL features.

Open LambdAurora opened this issue 3 years ago • 4 comments

Let's say I have a flint and steel, and want to burn vines so they don't grow more. I then need some kind of injection into the flint and steel item to add this behavior.

Same with a custom campfire-like block, like a brazier, if it's extinguished I would need an injection into the flint and steel item to add the turning it back on behavior!

This is where an event could come into place, allowing to easily add those behaviors!

Here's an existing mixin that I personally use to create the behaviors described earlier.

While I could've used FAPI's ItemUseCallback I didn't, I don't entirely remember the reason but it's something along the lines of it being a bit awkward.

But now we got some considerations for implementation:

First of all, let's look at the mixin and let's think about the stuff that could have been easily forgotten by modders in order of less likely to most likely:

  • forgetting to damage the tool
  • forgetting to emit the game event
  • forgetting to check for adventure mode

This could be solved by extending ItemUsageContext with injected interfaces, like context.canModifyWorld(), etc.

Second, look into make this event as less confusing as possible!

Third, make sure it's easy to use!

LambdAurora avatar Aug 21 '22 23:08 LambdAurora

Have the event per-block, maybe? edit: I resisted the urge

Leo40Git avatar Aug 22 '22 03:08 Leo40Git

Just noting this here:

  • forgetting to check for adventure mode

This is already handled by Vanilla itself! See ItemStack#useOnBlock.

Leo40Git avatar Aug 22 '22 15:08 Leo40Git

Just noting this here:

  • forgetting to check for adventure mode

This is already handled by Vanilla itself! See ItemStack#useOnBlock.

It actually isn't! You're the second person getting caught by that lmao

LambdAurora avatar Aug 22 '22 15:08 LambdAurora

why are you like this Mojang

Leo40Git avatar Aug 22 '22 15:08 Leo40Git