VanillaHopper icon indicating copy to clipboard operation
VanillaHopper copied to clipboard

ItemSpawnEvent gets called twice

Open fadijalal07 opened this issue 10 months ago • 0 comments

I have the plugin on my server for a very long time, however today i decided to work on a feature called Collection Chests (Picks up all dropped items in the chunk the chest is in)

i completed the feature, when i tested it, by dropping 1 stone, the chest gets filled with 2, which confused it me as i didnt have duplicate events or the listener registered twice, i kept debugging and i found out that ItemSpawnEvent is getting called twice for 1 item drop.

i had a feeling it was your plugin perhaps colliding w it, so i disabled it and tried again and it worked smoothly.

this is most likely happening due to your EntitySpawnListener file, specifically the "$newEntity = new ItemEntity($entity->getLocation(), $entity->getItem());" line. which causes the item entity to call the event twice...

https://streamable.com/lowoh9 perhaps this can help

fadijalal07 avatar Mar 07 '25 20:03 fadijalal07