PaperMC / Paper

The most widely used, high performance Minecraft server that aims to fix gameplay and mechanics inconsistencies
https://papermc.io/
Other
9.7k stars 2.26k forks source link

Setting itemstack amount to 0 #11392

Open JHarris12345 opened 5 days ago

JHarris12345 commented 5 days ago

Expected behavior

In pre 1.21 if you create an item stack with amount 0 then it simply removes the item. But in 1.21 it throws an error. Is this ability to remove an item something that can return or is it gone for good? I use this method of setting the amount to 0 a lot for my "limited use" items that deplete after each use. So it's easy for me to just set the amount to currentUses - 1. Here's a screenshot of the error https://gyazo.com/19a00bb855851bcb4aeb99a951ff93b8

Observed/Actual behavior

It should remove the item (like it used to) and not throw an error

Steps/models to reproduce

Set an item's amount to 0

Plugin and Datapack List

N/A

Paper version

Any 1.21 ver

Other

No response

masmc05 commented 5 days ago

You can set amount to 0 on existing items, but you can't create new ones with amount 0, use https://jd.papermc.io/paper/1.21.1/org/bukkit/inventory/ItemStack.html#empty() if you need an empty item stack

JHarris12345 commented 5 days ago

It created an air item stack if you tried to make one with amount 0 in pre 1.21. I am just asking if it's possible to get this back in 1.21 as it was a nice feature and saves needing to change all the code xD

electronicboy commented 5 days ago

ItemStack type is immutable in vanilla, and the goal here is generally to confirm closer to vanilla archtypes here, especially with ItemMeta already having caused general issues around changing types, which will only get to become more fun as people dive into components for doing stuff