mojira.dev
MC-133478

1.13 is mutating the constant EMPTY itemstack

I think we're saved mostly from really bad bugs by the strict instance equality check in ItemStack.isEmpty, but nonetheless this should be fixed.

You can see this happening by inserting the following code below the public ItemStack constructors:

private void E() {
    if (this.h && this == ItemStack.a) throw new AssertionError("TRAP"); // CraftBukkit
      this.h = false;
      this.h = this.isEmpty();
  }

And then right clicking a block with a sword.

Comments 2

Only confirmed that the method still exists in this form and could cause problems, but not that it is currently actually called.

It happens even more frequently in 1.15 because the ItemStack clone method was updated to return the EMPTY constant, so now it also shows up in places that were manipulating cloned stacks.

md_5

(Unassigned)

Confirmed

(Unassigned)

Minecraft 1.13-pre8, 1.15.1 Pre-release 1

Retrieved