I’m trying to listen to the InteractInventoryEvent.Open
event and use the BlockSnapshot
from its cause. I have this listener:
@Listener
public void onInventoryOpen(InteractInventoryEvent.Open event, @Filter BlockSnapshot block) {
...
}
It is not triggering when interacting with a ShulkerBox
. I am assuming it is because of the BlockSnapshot
filter not finding a BlockSnapshot
in the cause.
When I listen to the event without the filter it fires as expected. I then print out the Cause
and find that it does contain a BlockSnapshot
. Here’s my code:
@Listener
public void onInventoryOpen(InteractInventoryEvent.Open event) {
logger.info("Cause: " + event.getCause().toString());
}
Here’s the output of the above code showing that the cause contains a BlockSnapshot
:
Cause[
Context=Context [
"sponge:block_hit" =SpongeBlockSnapshot {
worldUniqueId=be4d39bb-46f4-4838-ad23-033e48bba9f1,
position=(-26,
65,
-19 ),
blockState=minecraft:yellow_shulker_box [
facing=up
],
extendedState=minecraft:yellow_shulker_box [
facing=up
]
},
"sponge:used_item" =SpongeItemStackSnapshot {
itemType=ItemAir {
Name=null
},
quantity=0
}
],
Stack= {
EntityPlayerMP [
'VapidLinus' /103,
l='temp_0',
x=-26.15,
y=65.00,
z=-21.78
]
}
]
I’m probably doing something wrong so I’d like some clarification on why my filtered event is never fired. What should I do instead to retrieve the BlockSnapshot
(or TileEntity
, because that’s what I actually need).
Thanks in advance!
EDIT;
Forgot the version info!
SpongeVanilla version 1.12.2-7.0.0-BETA-337
org.spongepowered:spongeapi:7.0.0-SNAPSHOT