Error dropping items

Hi guys,

I’m actually writing a plugin that need to drop items.
My code now looks like this :
Optional<Entity> entity = this.location.getExtent().createEntity(EntityTypes.ITEM, this.location.getPosition()); if(entity.isPresent()) { Item item = (Item)entity.get(); item.offer(Keys.REPRESENTED_ITEM, this.itemStack.createSnapshot()); for(int i = 0; i < this.stackCount; i++) { player.getWorld().spawnEntity(item, Cause.of(player)); } }

The items drops well but i got an error :
"Silently" catching entity tracking error. net.minecraft.util.ReportedException: Adding entity to track

Any one faced this exception before ?

Thanks :stuck_out_tongue:

That error is because you’re spawning the same entity multiple times.
You only need to spawn it once, the Item entity holds an item stack so it can have multiple items (vanilla will group items of the same type together anyway)

Ah ah yeah my bad. I realized this just before you replied :stuck_out_tongue:.
I don’t know why but in my mind an itemstack was just the “description” of the items and not the items them self.
Thanks.