I have something like this:
ItemStack stack = new ItemStack(Material.INK_SACK));
stack.setData(new Dye(DyeColor.LIME));
Data won't set, i got default ink sack.
Latest paperspigot build.
Dye d = new Dye(DyeColor.LIME)
ItemStack stack = d.toItemStack
CraftItemStack ignores the MaterialData:
private CraftItemStack(ItemStack item) {
this(item.getTypeId(), item.getAmount(), item.getDurability(), item.hasItemMeta() ? item.getItemMeta() : null);
}
As a workaround you could use the durability of the itemstack, as it'll fail with 1.13 anyway.
This doesn't work in CraftBukkit and hasn't in sometime if I remember correctly.
Can this be fixed? Need just to set damage in setData method.
Can we "fix" it, yes; ~it would be more akin to a bodge job than an actual fix~ (Actually, tell a lie... For Dye it would be technically okay, however it would leave issues for stuff like Glass, which doesn't have an implementation....), it would also create an API disparity between spigot and paper. The proper fix would be to implement the missing MaterialData classes in CB, which considering 1.13s release potentially going to break stuff like the MaterialData API, really isn't ideal.
the Dye class has a toItemStack method which takes an amount which should do what you want
We can't fix this without creating a disparity between ourselves and upstream. If you'd like to pursue this, report upstream.