mega12345mega / NBT-Editor

Edit items, blocks, and entities in-game.
MIT License
46 stars 14 forks source link

Allow editing air items #16

Closed HyperSoop closed 2 years ago

HyperSoop commented 2 years ago

It makes little to no sence to prohibit editing air with /nbt. It's an item like any other, and can be made into another item through the Item ID field.

mega12345mega commented 2 years ago

Air is a bit of an outlier - it can be represented by ItemStack.EMPTY or simply null (null is the absence of an item), depending on what part of Minecraft you ask. It also can't really have nbt. That's actually what inspired the /get command, and is the intended way to create new items. In fact, the ability to convert an item into air via the Item ID field was unintended, and could lead to 'nbt loss' for that item, if you don't convert it back - I should probably add in a warning when saving an air item.

Considering allowing /nbt on an empty slot would be different behavior compared to all the other commands, do you think I should:

HyperSoop commented 2 years ago

Air is a bit of an outlier - it can be represented by ItemStack.EMPTY or simply null (null is the absence of an item), depending on what part of Minecraft you ask. It also can't really have nbt. That's actually what inspired the /get command, and is the intended way to create new items. In fact, the ability to convert an item into air via the Item ID field was unintended, and could lead to 'nbt loss' for that item, if you don't convert it back - I should probably add in a warning when saving an air item.

Considering allowing /nbt on an empty slot would be different behavior compared to all the other commands, do you think I should:

* Add a config option to allow /nbt on air

* Allow /nbt on air (no config)

* Don't change anything

I think there could be a config option for this, enabled by default.

mega12345mega commented 2 years ago

Yesterday I started to implement this, but I ran into some glitches. While I believe I have everything fixed, working with air is always going to be a bit dangerous. So here's what I ended up deciding to do:

Hopefully that is a good compromise! The update should be out very soon.

mega12345mega commented 2 years ago

I've just released v1.8.0, which includes the above features!