quilt-standard-libraries
quilt-standard-libraries copied to clipboard
Event triggered on item usage with QoL features.
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!
Have the event per-block, maybe? edit: I resisted the urge
Just noting this here:
- forgetting to check for adventure mode
This is already handled by Vanilla itself! See ItemStack#useOnBlock.
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
why are you like this Mojang