Skip to content

Conversation

@Fellteros
Copy link

@Fellteros Fellteros commented Aug 18, 2025

Heya,
I noticed that there aren't any events for Item.useOnBlock() and AbstractBlock.onUseWithItem() methods. I recently tried to make a mod that would need this kind of callbacks, so I decided to implement it. It's mostly based on NeoForge's UseItemOnBlockCallback, with some minor changes (e.g. omitting the ITEM_BEFORE_BLOCK phase).

I also added a little test mod, that allows you to change stone bricks to their mossy variant when right-clicking them with moss, and stripping the moss with any axe.

I added these events to the event-interaction-api module, let me know if there is any better place to move them to

@Fellteros Fellteros deleted the branch FabricMC:1.21.8 August 18, 2025 14:30
@Fellteros Fellteros closed this Aug 18, 2025
@Fellteros Fellteros deleted the 1.21.8 branch August 18, 2025 14:30
@Fellteros Fellteros restored the 1.21.8 branch August 18, 2025 14:31
@Fellteros Fellteros reopened this Aug 18, 2025
@cputnam-a11y cputnam-a11y added the enhancement New feature or request label Aug 18, 2025
@Fuzss
Copy link
Member

Fuzss commented Aug 20, 2025

The events should allow for forcing ActionResult.PASS / ActionResult.PASS_TO_DEFAULT_BLOCK_ACTION respectively when cancelling vanilla behavior.

Ideally make the return value for the events @Nullable.

This has long been an issue with the existing interaction events not allowing for returning ActionResult.PASS properly. New interaction events shouldn't introduce this fault to begin with.

NeoForge also allows for cancelling vanilla regardless of the returned ActionResult.

@Fellteros
Copy link
Author

I made both methods @Nullable and changed the mixins to return any non-null value from the callbacks. This should fix the issues you pointed out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants