mojira.dev
MC-114104

Some actions apply the same NBT object instance to multiple items entities or tile entities instead of applying a copy

The bug

Some actions in the game apply the same NBT object instance to multiple items, entities or tile entities. This means if you edit it for one of them you basically edit it for all of them.

This could in theory happen with non-NBT data as well, but at least in the current versions this is not the case because either:

  • the data is stored in primitive types and therefor no objects are involved

  • the data is provided in NBT format but then parsed and stored with objects; therefor no reference to the NBT data exists anymore

Some of the cases listed below might happen when the NBT data is read or written by entities or tile entities. The expected fix is however not to have them always create a copy because that would slow down saving and loading worlds. Instead the methods calling these methods should create a copy before respectively after.

The reason why this report contains a list of all cases, even the ones which are not affected, is to have an overview and make it easier to detect new cases in which this happens.

Actions

Affected key

Symbol

Meaning

Affected

Not affected

⚠️

Currently not affected, but current behavior is listed as bug and therefor likely affected in the future

List

Based on 1.11.2 decompiled using MCP 9.35 rc1

Last updated for 1.11.2
Likely incomplete

Action

Affected

Comment

Affected method

Pick block with NBT

⚠️

Currently happens client-side, but should happen server-side

Minecraft.storeTEInStack(ItemStack, TileEntity)

Copying items in Creative

-

-

Crafting: Cloning books

-

-

Crafting: Cloning banners

-

-

Crafting: Cloning maps

-

RecipesMapCloning.getCraftingResult(InventoryCrafting)

Creating item in Creative with BlockEntityTag

-

NetHandlerPlayServer.processCreativeInventoryAction(CPacketCreativeInventoryAction)

Using item with EntityTag

Dispenser, spawn eggs, armor stand...

ItemMonsterPlacer.applyItemEntityDataToEntity(World, EntityPlayer, ItemStack, Entity)

Item with BlockEntityTag placed

-

-

Items from loottables

Uses NBTTagCompound.merge which clones

-

Items from villagers

-

-

Splitting item stacks

-

-

Hopper (minecart) item actions

-

-

Droppers transferring items

-

-

Cleaning banner in cauldron

-

-

Cleaning leather armor in cauldron

⚠️

Even in Creative stack is replaced and water level reduced, not the case with banners, see MC-114105

BlockCauldron.onBlockActivated(World, BlockPos, IBlockState, EntityPlayer, EnumHand, EnumFacing, float, float, float)

Putting item on armor stand

-

-

Using firework

-

-

Putting item in item frame

⚠️

Only cloned when not empty, but even if empty set as item

EntityItemFrame.setDisplayedItemWithUpdate(ItemStack, boolean)

Putting chest on donkey or mule

⚠️

Entity does not store item data but only boolean, see MC-91005

-

Putting saddle on pig

⚠️

Entity does not store item data but only boolean, see MC-91005

-

Dispenser / dropper dropping item

-

-

Dispenser placing player skull

GameProfile is read and stored

-

Dispenser shooting tipped arrow

Potion effects are read and stored

-

Dispenser throwing splash or lingering potion

-

-

Dispenser equipping armor (including pumpkin, elytra and skull)

-

-

Dispenser playing shulker box

-

-

/clone

See paragraph "How to reproduce" for reproduction

CommandClone.execute(MinecraftServer, ICommandSender, String[])

/fill

Fixed, see MC-163953

CommandFill.execute(MinecraftServer, ICommandSender, String[])

/entitydata

Runs for each entity seperately and uses NBTTagCompound.merge which clones

-

/replaceitem entity

Runs for each entity seperately

-

Structure blocks loading and saving

See MC-114030

-

How to reproduce

Some of these cases cannot be reproduced because other actions only override the affected data instead of modifying it, or other actions create a copy before you could try to reproduce them. Therefor here are only reproduction steps for some actions.

/clone

  1. Place a spawner

    /setblock ~ ~ ~ spawner{SpawnData:{id:"armor_stand"},SpawnCount:0s,SpawnRange:0s,MinSpawnDelay:0s,MaxSpawnDelay:0s,MaxNearbyEntities:1s,RequiredPlayerRange:16s,SpawnPotentials:[{Weight:1,Entity:{id:"bat"}}]}
  2. Stand on top of the spawner and run the following command

    /clone ~ ~-1 ~ ~ ~-1 ~ ~2 ~-1 ~
  3. For the cloned spawner

    1. Make it switch to the SpawnPotentials (stand on top of it while running the command)

      /data modify block ~ ~-1 ~ SpawnCount set value 1b
    2. Right click the spawner with a creeper spawn egg

  4. For the original spawner

    1. Inspect the NBT data

      /data get block ~ ~-1 ~ SpawnPotentials

      ❌ It shows "minecraft:creeper" as entry for the SpawnPotentials instead of "minecraft:bat"

/fill

Fixed by MC-163953

Linked issues

Comments 4

Brian McNamara

once upon a time, I recall that doing entitydata on a ThrownPotion to change the potion details would cause the potion item in my inventory to also change, which sounds like a similar thing (have not tried to repro now)

SunCat

@unknown, you are thinking about MC-92191 (already fixed)

[Mod] redstonehelper

Unable to reproduce for /fill and /clone as of 20w07a.

edit: /clone still reproducible

UncomfyMattress

Can confirm in 1.20.1.

marcono1234

(Unassigned)

Confirmed

(Unassigned)

NBT, block-entity, entity, item, nbt, object

Minecraft 1.11.2, Minecraft 17w06a, 20w07a, 21w20a

Retrieved