Skip to content

0 amount ItemStacks #10902

@tal5

Description

@tal5

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions