architectury-api icon indicating copy to clipboard operation
architectury-api copied to clipboard

Entity interaction event isn't fired for Armor Stand interaction

Open desht opened this issue 2 years ago • 3 comments

InteractionEvent.INTERACT_ENTITY is not currently fired when a player right-clicks an Armor Stand entity. This is because Architectury currently mixes into Player#interactOn, but that's only one of the two paths entity interaction can take.

Looking at ServerGamePacketListenerImpl#handleInteract, the anonymous implementation of ServerboundInteractPacket.Handler within that method implements two onInteraction() overloads. The first is called for general entity interaction, e.g. right-clicking an item frame; that calls Player#interactOn which you mix into, and event is fired. The second overload (onInteraction(InteractionHand,Vec3)) is called when specific position data is required, e.g. interacting with an Armor Stand to check which armor slot is relevant. This is not currently mixed in by Architectury, so Armor Stand interactions are not currently catchable.

(Note that Forge handles this situation with its PlayerInteractEvent.EntityInteractSpecific event in the performInteraction() method, so hooking that, and injecting an equivalent mixin on Fabric, is an option).

desht avatar Nov 08 '22 10:11 desht

Actually, this is also a bit broken on Forge 1.18.2 - see https://github.com/MinecraftForge/MinecraftForge/issues/8143, where cancelling the EntityInteractSpecific event doesn't prevent this behaviour. It's fixed for Forge in 1.19.2 though (https://github.com/MinecraftForge/MinecraftForge/pull/9079) so hopefully a fix will be forthcoming for 1.18.

In the meantime, I'll leave it up to you as to how (or if) you want to work around this :)

desht avatar Nov 08 '22 11:11 desht

LTS backport has been merged into 1.18 branch: https://github.com/MinecraftForge/MinecraftForge/pull/9494 Just making sure you are aware 👍🏻

andriihorpenko avatar Jun 01 '23 10:06 andriihorpenko

Oh that's great actually, means we'll only have to fix this for Fabric still

MaxNeedsSnacks avatar Jun 01 '23 14:06 MaxNeedsSnacks