Potato
Potato

Reputation: 49

Lapis Lazuli ItemStack ID

Currently I'm trying to make an autosmelt plugin and every time the player breaks the block, it reads the block broken and gives the block smelted to the player. Now, lapis lazuli may not need to be smelted in game, but since, when the block is broken, it cancels the block breaking and manually breaks it then gives the item, I need to do:

player.getInventory().addItem(new ItemStack(Material.LAPIS, 1));
player.updateInventory();

But as some of you may know, Material.LAPIS is not a bukkit/spigot Material. Meaning that I would need to do:

player.getInventory().addItem(new ItemStack(Material.INK_SACK, 1, (short) 4));
player.updateInventory();

Since lapis is technically a dye item. But of course this does not work for a reason I do not know. I am using the 1.10.2 spigot API so maybe it works in 1.11 or 1.12 API but I'm not sure. So if anyone has a solution to give the player the lapis, please let me know.

Upvotes: 0

Views: 1121

Answers (2)

LuckyZeeRo
LuckyZeeRo

Reputation: 1

1st variant

ItemStack yourInkSack = new ItemStack(Material.INK_SACK, 1, (short) 4);

2nd variant

ItemStack yourInkSack = new ItemStack(Material.INK_SACK);
yourInkSack.setDurability((short) 4);

Upvotes: 0

user5307594
user5307594

Reputation:

Try this:

Dye dye = new Dye(); dye.setColor(DyeColor.BLUE); ItemStack lapis = dye.toItemStack();

Upvotes: 2

Related Questions