[SPIGOT-2821] ItemStack.setData() is not working? Created: 22/Nov/16  Updated: 22/Nov/16  Resolved: 22/Nov/16

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

Type: Bug Priority: Minor
Reporter: wysohn Assignee: Unassigned
Resolution: Invalid Votes: 0
Labels: 1.11
Environment:

[21:13:38] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-16c940b-0b154b1 (MC: 1.11) (Implementing API version 1.11-R0.1-SNAPSHOT)
[21:13:38] [Server thread/INFO]: Checking version, please wait...
[21:13:38] [Thread-14/INFO]: You are 6 version(s) behind



 Description   

because the DyeColor enum's getData() method is separated into two getWoolData() and getDyeData() (they are deprecated anyway), I recently changed my code like below:

new ItemStack(Material.WOOL, 1, DyeColor.GREEN.getData());

to

new ItemStack(Material.WOOL, 1){{
setData(new Wool(DyeColor.GREEN));
}};

and the actual item I see is just a white wool instead of green wool

did I do something wrong? or is it a bug in 1.11?



 Comments   
Comment by wysohn [ 22/Nov/16 ]

Hmm I thought it was quite legit change :/

I will go back to getWoolData()

and I have to use inner class just because I have to provide ItemStack right in the constructor

a new additional overloaded ItemStack constructor will be really help whenevr MaterialData problem is sorted out

Comment by md_5 [ 22/Nov/16 ]

Well for starters getData called getWoolData, so your original code can just be getWoolData.
As for setData 1) You are calling it from within an inner class which is weird, 2) I don't believe calling setData has ever worked due to quirks with how the API was written. Happy to be proved wrong.

Generated at Tue Apr 15 09:41:47 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.