Entity interaction event isn't fired for Armor Stand interaction
desht opened this issue ยท 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).
Actually, this is also a bit broken on Forge 1.18.2 - see MinecraftForge/MinecraftForge#8143, where cancelling the EntityInteractSpecific
event doesn't prevent this behaviour. It's fixed for Forge in 1.19.2 though (MinecraftForge/MinecraftForge#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 :)
LTS backport has been merged into 1.18 branch: MinecraftForge/MinecraftForge#9494
Just making sure you are aware ๐๐ป