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
Put a repeating command block down with
/clear @p torch
Switch to Creative mode
/gamemode creative
Grab a stack of torches for example from your Creative inventory and put it in your hotbar
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();
}
//...
}
}
Linked issues
is duplicated by 29
relates to 2
Attachments
Comments 53
Is this still a concern in the current Minecraft version 14w11b / Launcher version 1.3.11 or later? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.
Is this still a concern in the current Minecraft version 14w20b / Launcher version 1.3.11 or later? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

Just tested, confirmed as of 14w21b

Confirmed for 14w30c
This also happens sometimes when you press the mouse wheel to select a block
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.
Whenever you open a chest, furnace or any other objects like that, it updates and removes the torches.
https://bit.ly/2Hz9UGa

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?

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

@unknownIt was always cleared on server, but client was not informed about it. So fix was to trigger update.
Is this still a concern in the current Minecraft version 1.7.4 / Launcher version 1.3.8 or later? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.