I have 2 question

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

Question 1:

There is no tile entity for double chest yet so thats why it can not be grabbed. My way around it was to check for the player and then use blockRays to see what they are looking at (it doesn’t work if the client is so laggy that the inventory appears way after they clicked the block.

I belive they fixed this issue in api 7 but didn’t for api 6 for some reason.

Question 2.
I belive it was something like ChunkUnloadEvent.Entity but i can not find it anymore.


For question 2, if I understood you right UnloadChunkEvent is working (at least on my 5.2.0 API)
I made a little try with the following code :

public void onChunkUnload(UnloadChunkEvent event) {
Collection<Entity> entities = event.getTargetChunk().getEntities();
for(Entity entity : entities) {

This seems to work, when moving/disconnecting it spams me a lot of

[14:11:52] [Server thread/INFO] [STDOUT]: [me.raisto.darkengine.DarkEngine:onChunkUnload:124]: SpongeEntityType{id=minecraft:zombie, name=zombie, translation=SpongeTranslation{id=entity.Zombie.name}, modid=minecraft, class=net.minecraft.entity.monster.EntityZombie}

Whats on line 124?
(A whole error would be nice)

Oh this wasn’t an error, I was just showing that I get the entity with the code I sent