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

/clear turns items held by mouse into ghost items

    • Icon: Bug Bug
    • Resolution: Fixed
    • Minecraft 19w12a
    • Minecraft 13w48b, (66)
      Minecraft 1.7.10, Minecraft 14w30c, Minecraft 14w32a, Minecraft 1.8-pre1, Minecraft 1.8-pre2, Minecraft 1.8, Minecraft 1.8.2-pre6, Minecraft 15w34c, Minecraft 15w44b, Minecraft 15w45a, Minecraft 1.8.9, Minecraft 16w04a, Minecraft 16w05b, Minecraft 1.9 Pre-Release 1, Minecraft 1.9 Pre-Release 2, Minecraft 1.9, Minecraft 1.9.2, Minecraft 1.10, Minecraft 1.10.2, Minecraft 16w32a, Minecraft 16w32b, Minecraft 16w33a, Minecraft 16w36a, Minecraft 16w39b, Minecraft 16w39c, Minecraft 16w42a, Minecraft 1.11 Pre-Release 1, Minecraft 1.11.2, Minecraft 17w17b, Minecraft 1.12 Pre-Release 2, Minecraft 1.12, Minecraft 1.12.2, Minecraft 18w05a, Minecraft 18w06a, Minecraft 18w10c, Minecraft 18w15a, Minecraft 18w19a, Minecraft 18w21b, Minecraft 18w22c, Minecraft 1.13-pre1, Minecraft 1.13-pre2, Minecraft 1.13-pre3, Minecraft 1.13-pre4, Minecraft 1.13-pre5, Minecraft 1.13-pre6, Minecraft 1.13-pre8, Minecraft 1.13, Minecraft 18w30b, Minecraft 18w31a, Minecraft 1.13.1-pre1, Minecraft 1.13.1-pre2, Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 18w43b, Minecraft 18w43c, Minecraft 18w44a, Minecraft 18w45a, Minecraft 18w48a, Minecraft 18w48b, Minecraft 18w49a, Minecraft 18w50a, Minecraft 19w02a, Minecraft 19w03c, Minecraft 19w04b, Minecraft 19w05a, Minecraft 19w06a
    • Confirmed

      The bug

      Using /clear while an inventory is open and you are holding an item with your mouse causes an inventory desync and turns this item into a "ghost" item. You can place it in your inventory, but using it will fail in Creative mode and in Adventure and Survival mode additionally removes the item.

      Expected would be that /clear successfully clears the held item client-side as well.

      How to reproduce

      1. Put a repeating command block down with
        /clear @p torch
        
      2. Switch to Creative mode
        /gamemode creative
        
      3. Grab a stack of torches for example from your Creative inventory and put it in your hotbar
      4. Try placing down torches
        The torches are not placed

      Code analysis (outdated for 1.13+)

      The following is based on a decompiled version of Minecraft 1.8 using MCP. All method and class names are the ones used in the decompiled version.

      The reason for this is a piece of code in the public void processCommand(ICommandSender sender, String[] args) method of the net.minecraft.command.CommandClearInventory class that only updates the held item once the /clear command was used, if the player is not in Creative mode:

      public void processCommand(ICommandSender sender, String[] args) throws CommandException
      {
      	EntityPlayerMP var3 = args.length == 0 ? getCommandSenderAsPlayer(sender) : getPlayer(sender, args[0]);
      	
      	// ...
      	
      	if (args.length >= 2 && var4 == null)
      	{
      		throw new CommandException("commands.clear.failure", new Object[] {var3.getName()});
      	}
      	else
      	{
      		int var8 = var3.inventory.func_174925_a(var4, var5, var6, var7);
      		var3.inventoryContainer.detectAndSendChanges();
      
      		//This prevents the update
      		if (!var3.capabilities.isCreativeMode)
      		{
      			var3.updateHeldItem();
      		}
      
      		//...
      	}
      }
      

        1. 2013-11-28_20.08.06.png
          2013-11-28_20.08.06.png
          349 kB
        2. 2013-11-28_20.09.55.png
          2013-11-28_20.09.55.png
          310 kB
        3. Minecraft 15w44b 11_1_2015 10_31_08 AM.mp4
          2.73 MB
        4. aufnahme (05).mp4
          3.39 MB
        5. aufnahme (04).mp4
          3.21 MB
        6. aufnahme (06).mp4
          4.12 MB
        7. aufnahme (07).mp4
          4.65 MB

          [MC-41113] /clear turns items held by mouse into ghost items

          CreeperMagnet_It was always cleared on server, but client was not informed about it. So fix was to trigger update.

          [Mojang] Bartosz Bok added a comment - CreeperMagnet_ It was always cleared on server, but client was not informed about it. So fix was to trigger update.

          Влад added a comment -

          Love you Mojang! One of the most annoying bugs in mapmaking is fixed

          Влад added a comment - Love you Mojang! One of the most annoying bugs in mapmaking is fixed

          Just wondering, how exactly was this bug fixed? Can command blocks clear & detect items 'on the mouse' anymore, or not? Or is it a new slot or something of the like?

          CreeperMagnet_ added a comment - Just wondering, how exactly was this bug fixed? Can command blocks clear & detect items 'on the mouse' anymore, or not? Or is it a new slot or something of the like?

          Whenever you open a chest, furnace or any other objects like that, it updates and removes the torches.
          https://bit.ly/2Hz9UGa

          Charlie Gallie added a comment - Whenever you open a chest, furnace or any other objects like that, it updates and removes the torches. https://bit.ly/2Hz9UGa

          For any map creators, you could use this while it lasts. It could create a false adventure mode cause you can add nbt to items and specify what type of items for this to work on, also, dropping the item just removes the item from your hotbar and doesn't actually drop them. But although it could be used like that, it is a bug and should be removed.

          Charlie Gallie added a comment - For any map creators, you could use this while it lasts. It could create a false adventure mode cause you can add nbt to items and specify what type of items for this to work on, also, dropping the item just removes the item from your hotbar and doesn't actually drop them. But although it could be used like that, it is a bug and should be removed.

          Similar issue with nether stars not changing name color after clearing and being given a new one immediately in 19w06a.
          And this time no comment updates

          user-2a4c8 (Inactive) added a comment - Similar issue with nether stars not changing name color after clearing and being given a new one immediately in 19w06a. And this time no comment updates

          @violine1101 OOPS ma bad... Was trying to get the formatting right. It was late and I kept changing my mind. Apologizes to all!

          user-2a4c8 (Inactive) added a comment - @violine1101 OOPS ma bad... Was trying to get the formatting right. It was late and I kept changing my mind. Apologizes to all!

          jirauser54679, please keep in mind that everytime you edit your comment, everyone who is watching this ticket (48 people) receives an email. You sent out approximately 480 emails today. Please use the visual editor to check your comments before posting them if you want to make sure that they look right.

          [Mod] violine1101 added a comment - jirauser54679 , please keep in mind that everytime you edit your comment, everyone who is watching this ticket (48 people) receives an email. You sent out approximately 480 emails today. Please use the visual editor to check your comments before posting them if you want to make sure that they look right.

          user-2a4c8 (Inactive) added a comment - - edited

          Yeah ghost items in 19w04b, but not directly related to /clear, just ghost items in general. Specifically when an item is dropped and given back immediatly by /give like the repeating chain below:

          /execute as @e[type=item,nbt={Item:{id:"minecraft:gold_ingot"}}] at @s run scoreboard players set @p temp 1
          /kill @e[type=item]
          /give @a[scores={temp=1}] minecraft:gold_ingot
          - Other stuff inbetween here
          /scoreboard players set @a[scores={temp=1}] temp 0
          

          (temp is a dummy type scoreboard)

          user-2a4c8 (Inactive) added a comment - - edited Yeah ghost items in 19w04b, but not directly related to /clear, just ghost items in general. Specifically when an item is dropped and given back immediatly by /give like the repeating chain below: /execute as @e[type=item,nbt={Item:{id: "minecraft:gold_ingot" }}] at @s run scoreboard players set @p temp 1 /kill @e[type=item] /give @a[scores={temp=1}] minecraft:gold_ingot - Other stuff inbetween here /scoreboard players set @a[scores={temp=1}] temp 0 (temp is a dummy type scoreboard)

          Teixon added a comment -

          I really need this fixed. My inventory won't update if I replace a slot too quickly. The only workaround working for me is to clear my slot with something else to refresh it before replacing it with the actual item. Can't do this in any case however.

          Teixon added a comment - I really need this fixed. My inventory won't update if I replace a slot too quickly. The only workaround working for me is to clear my slot with something else to refresh it before replacing it with the actual item. Can't do this in any case however.

            boq [Mojang] Bartosz Bok
            m124367 AgentM
            Votes:
            80 Vote for this issue
            Watchers:
            47 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: