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

Spawn eggs can spawn entities with already used UUID


    • Icon: Bug Bug
    • Resolution: Fixed
    • Minecraft 1.13.1
    • Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 17w45b
    • Confirmed

      The bug

      Spawn eggs can spawn entities with already used UUIDs. This should not be possible since UUIDs are supposed to be unique and duplicate UUIDs can and will cause errors.

      How to reproduce

      1. Give yourself a spawn egg
        /give @s spawn_egg{EntityTag:{id:"minecraft:husk",UUIDLeast:1L,UUIDMost:1L}}
      2. Use the spawn egg at least twice
      3. Use the following command to list all entities with the used UUID
        /say @e[nbt={UUIDMost:1L,UUIDLeast:1L}]

        → It lists multiple entities

      Code analysis and fix note

      Based on 1.12.2 decompiled using MCP 9.40

      The method net.minecraft.item.ItemMonsterPlacer.applyItemEntityDataToEntity(World, EntityPlayer, ItemStack, Entity) is apparently supposed to use the randomly generated UUID instead of the provided one, however does this incorrectly by setting the original UUID before merging the NBT data, see also MC-98244.

      However, this is not required and probably not the correct behavior. Since the entity is a new one, the method applyItemEntityDataToEntity does not have to do anything to prevent UUID manipulation. Instead the methods ItemMonsterPlacer.onItemUse(EntityPlayer, World, BlockPos, EnumHand, EnumFacing, float, float, float), ItemMonsterPlacer.onItemRightClick(World, EntityPlayer, EnumHand) and net.minecraft.init.Bootstrap.registerDispenserBehaviors().new BehaviorDefaultDispenseItem() {...}.dispenseStack(IBlockSource, ItemStack) should first create the entity, then apply the NBT data and then try to spawn it. This would then fail as expected like it is currently the case for armor stands.

            Unassigned Unassigned
            MukiTanuki MukiTanuki
            1 Vote for this issue
            2 Start watching this issue