[SPIGOT-3361] toItemStack() method in Dye is confusing/misleading Created: 21/Jun/17  Updated: 11/Dec/17  Resolved: 21/Jun/17

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Linus Närkling Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None


 Description   

Sample code:

ItemStack stack = new Dye(DyeColor.LIME).toItemStack()

Trying to give this stack to the player or dropping it into the world leads to nothing happening. It took me a while to figure out why it wasn't working, but it's because toItemStack() creates a stack with an amount of 0.

 

Changing the code to use the method which takes an amount fixed my problem:

ItemStack stack = new Dye(DyeColor.LIME).toItemStack(1)

 

This might not be a bug, but I expected the first method to create a stack of 1, which I feel is a reasonable thing to expect. Even if this can't be changed, I feel like it should at least be mentioned in the Javadoc as a caution to it being a stack of 0 and not 1.


Generated at Sat Dec 13 15:25:44 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.