PaperMC / Paper

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

0 amount `ItemStack`s #10902

Open tal5 opened 2 weeks ago

tal5 commented 2 weeks ago

Expected behavior

Before the recent ItemStack changes, you could new ItemStack(AIR, 0) to create an empty ItemStack (an ItemStack#empty, basically).

Observed/Actual behavior

amount is limited to above 0 now, even though places like ItemStack#empty/ItemType#createItemStack still allow that, which breaks old code from before ItemStack#empty using an amount of 0 to create empty stacks & is a bit of a weird inconsistency in general.

Steps/models to reproduce

new ItemStack(Material.AIR, 0)

Plugin and Datapack List

> plugins
[11:23:01 INFO]: Server Plugins (1):
[11:23:01 INFO]: Bukkit Plugins:
[11:23:01 INFO]:  - PaperTestPlugin
> datapack list
[11:23:16 INFO]: There are 3 data pack(s) enabled: [vanilla (built-in)], [file/bukkit (world)], [paper (built-in)]
[11:23:16 INFO]: There are no more data packs available

Paper version

> version
[11:23:29 INFO]: Checking version, please wait...
[11:23:29 INFO]: This server is running Paper version 1.21-3-master@4514f41 (2024-06-18T09:17:48Z) (Implementing API version 1.21-R0.1-SNAPSHOT)
You are running the latest version

Other

See Discord discussion: https://discord.com/channels/289587909051416579/555462289851940864/1252563371635638272 Like lynx suggested there, having an amount of 0 delgate to ItemStack#empty might be a good solution to both keep compatibility & still not allow creating random 0 amount stacks