Stop itemMerge of spawned item


#1

Hello
I try to stop a spawned item from stacking with each other.
I create the item like its described in the docs:

ItemStack gold = ItemStack.builder().itemType(ItemTypes.GOLD_INGOT).build();
    gold.offer(Keys.DISPLAY_NAME, Text.of(TextColors.GOLD, "Gold"));

    Extent extent = _spawnLocation.getExtent();
    Entity item = extent.createEntity(EntityTypes.ITEM, _spawnLocation.getPosition());
    item.offer(Keys.REPRESENTED_ITEM, gold.createSnapshot());

I then spawn them when a mob gets killed by a player. If they stack i cant work with them correctly.
Is there a way to set a max stack size or something similar?

I tried to cancel the ItemMergeItemEvent but it just never gets called, i dont know why.
Thanks


#2

I didnt find a way to change the maxStackSize yet. I used the workaround that items with different lore dont merge, so that works.


#3

Listen for the ItemMergeItemEvent and check if one of the items are one of your dropped items


#4

If you make the lore modification consist entirely of color codes, you won’t have any strange display properties either.