public static final ItemStack EMPTY = new ItemStack((Void)null);
This EMPTY cause some problem. First - programmer or modder dont know that instance is "EMPTY", if no check. Than he can set nbt to EMPTY item.
And it cause some bug:
Select item with nbt. Drop item. run in java System.out.println(Minecraft.getInstance().player.getMainHandItem().save(new CompoundTag()));
Expect - {id:"minecraft:air",Count:1b}
Got - {id:"minecraft:air",Count:1b,tag:{...}}
How to fix it?
replace EMPTY = new ItemStack((Void)null); to
new ItemStack((Void)null) {
public void setTag(@Nullable CompoundTag compoundTag) {}
public CompoundTag getOrCreateTag() {return new CompoundTag();}
public CompoundTag save(CompoundTag compoundTag) {compoundTag.putString("id","minecraft:air");compoundTag.putByte("Count",(byte)1)}
}
It will help modding and Mojang.
Comments 4
Nothing, but while i creating mod, i check item nbt and ignore count of item and id of item. Than got error - after drop item check empty slot, see nbt, run some functions. And it will optimize minecraft.
What's the gameplay impact of this? How can one experience this in-game without mods?