hi
For a logging plugin I am working on, I am trying to get the block that owns an inventory whenever the AffectSlotEvent is fired to judge whether or not the inventory change should be logged. This works fine for inventories bound to a single tile entity, such as chests, beacons, etc. by casting the inventory to a CarriedInventory and then using #getCarrier(). However, this method will return an empty optional when the owner of the inventory is a double chest.
I have been looking for a different way to identify the owner of an inventory if it is a double chest, but to no avail. I have been trying this on API versions 5.1.0 and 6.0.0 using SpongeForge for testing.
Does anyone know a way to obtain a reference to the double chest in this situation?
and the second question
I’m trying to keep track on a certain type of entity (Pixelmon) but can’t figure out what event to listen to for when they despawn/being unloaded. Currently listening to DestructEntityEvent (works when they die), ExpireEntityEvent and UnloadChunkEvent.
Am I missing an event? What’s the proper event for when chunks have no players within view distance (I assume it was UnloadChunkEvent but doesn’t seem to be the case)?
EDIT: To clarify: When a player moves away from an area entities disappear, none of the above events catch this.
Sponge API: 5.1.0
thx all