mojira.dev
MC-172272

/clear removes all items from crafting grid regardless of item type

This was caused by the fix for MC-75328.

How to reproduce

  1. Insert the following command in a repeating command block and power it

    clear @p diamond
  2. Go into survival

  3. Get any other item in your inventory and move it into the crafting slots
    ❌  The item gets cleared even though it is not a diamond

Code analysis

The reason for this is that the method net.minecraft.server.commands.ClearInventoryCommand#clearInventory(CommandSourceStack, Collection, Predicate, int) simply calls InventoryMenu#clearCraftingContent() without making use of the ItemPredicateArgument or the maxCount properties.

Linked issues

MC-172081 /clear ignores filter parameters when clearing inventory crafting grid Resolved MC-172149 Player Crafting Grid Deletes Items Resolved MC-172202 Putting Items in your 2x2 crafting square makes them disappear Resolved MC-172754 the inventory crafting table aren't working Resolved MC-172900 Inventory Crafting Not Working Resolved

Comments 16

This is even worse than it first seems, because using clear with a maxCount of 0 is how maps/datapacks check how many of an item a player has.

With this bug causing maxCount to be ignored, checking how many items a player has will instantly delete the items they're crafting with.
 

This is really bad. I hope they fix this soon.

Confirmed for 20w12a as well.

also happening in snapshot 20w13b … whether multiple items (eg 53 bones) or non stackable item (fishing rod)

6 more comments

@Derek Wu You are supposed to be able to supply a specific item for it to clear. The issue is that it will clear all items in the crafting grid, regardless of the paramater.

@Derek Wu Like Penguin _Spy said. It's especially an issue with datapacks, many of which are broken because they run /clear minecraft:specific_item, but instead clear everything and might render players wholly unable to use the 2x2 crafting grid.

Confirmed for 20w20b

Despite what it says under "Affected Version(s)", it's already fixed in 20w21a.

Unlike @@unknown said, I can reproduce on 20w21a

Misode

mgatland

Confirmed

Important

Commands

20w07a, 20w08a, 20w09a, 20w10a, 20w12a, ..., 20w18a, 20w19a, 20w20a, 20w20b, 20w21a

20w22a

Retrieved