Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-114104

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

    XMLWordPrintable

    Details

    • Confirmation Status:
      Confirmed
    • Category:
      (Unassigned)

      Description

      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 See paragraph "How to reproduce" for reproduction
      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 ~ ~ ~ mob_spawner default replace {SpawnData:{id:"armor_stand"},SpawnCount:0s,SpawnRange:0s,MinSpawnDelay:0s,MaxSpawnDelay:0s,MaxNearbyEntities:1s,RequiredPlayerRange:16s,SpawnPotentials:[{Weight:1,Entity:{id:"bat"}}]}
        
      2. Clone the spawner
        /clone ~ ~-1 ~ ~ ~-1 ~ ~2 ~-1 ~
        
      3. For the cloned spawner
        1. Make it switch to the SpawnPotentials
          /blockdata ~ ~-1 ~ {SpawnCount:1b}
          
        2. Right click with a creeper spawn egg
      4. For the original spawner
        1. Inspect the NBT data
          /blockdata ~ ~-1 ~ {}
          

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

      /fill

      1. Fill in spawners
        /fill ~1 ~ ~ ~2 ~ ~ mob_spawner default replace {SpawnData:{id:"armor_stand"},SpawnCount:0s,SpawnRange:0s,MinSpawnDelay:0s,MaxSpawnDelay:0s,MaxNearbyEntities:1s,RequiredPlayerRange:16s,SpawnPotentials:[{Weight:1,Entity:{id:"bat"}}]}
        
      2. For first spawner
        1. Make it switch to the SpawnPotentials
          /blockdata ~ ~-1 ~ {SpawnCount:1b}
          
        2. Right click with a creeper spawn egg
      3. For the second spawner
        1. Inspect the NBT data
          /blockdata ~ ~-1 ~ {}
          

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                marcono1234 [Mod] Marcono1234
              • Votes:
                5 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  CHK: