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

/clear turns items held by mouse into ghost items

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Minecraft 19w12a
    • Minecraft 13w48b, 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
          349 kB
          AgentM
        2. 2013-11-28_20.09.55.png
          310 kB
          AgentM
        3. aufnahme (04).mp4
          3.21 MB
          Panossa YT
        4. aufnahme (05).mp4
          3.39 MB
          Panossa YT
        5. aufnahme (06).mp4
          4.12 MB
          Panossa YT
        6. aufnahme (07).mp4
          4.65 MB
          Panossa YT
        7. Minecraft 15w44b 11_1_2015 10_31_08 AM.mp4
          2.73 MB
          Amr Satrio

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

              Created:
              Updated:
              Resolved:
              CHK: