Colored items MINECRAFT Java?

Fe
27

Shark people

I'm currently programming a Minecraft lobby system and of course this also includes a player hider.

My question:

How can I in the item stack e.g. Add green dye?

Things like Dye_green / green_dye etc. Didn't work.

an

Which Minecraft version?

Depending on the version, it works differently.

Fe

1.8. *

Eg

Would the IDs go too?

Fe

I don't know - depending on how you integrate them into the plugin

cl

By passing a subID when creating the item stack. Example:

ItemStack itemStack = new ItemStack (Material, amount, (short) subId);

Eg

Try lime_dye and dye: 2

Fe

Can you give an example please

Fe

Does not work…

When I search for dye, come only dye and no color selection

an

SubId should be (byte) or not?

Eg

Um, then I have no idea: /

Fe

Sry am a beginner…

an

You just have to take the dye material for the material, instead of writing down the number, and instead of subId the number for the color…

ItemStack color = new ItemStack (Material.DYE, 1, (byte) 5);

gives you e.g. A purple color.

an

Maybe instead of that

(short) have to write a (byte). Like my answer.

an

ItemStack redcolor = new ItemStack (Material.DYE, 1, (byte) 1);

for red color.

ItemStack greencolor = new ItemStack (Material.DYE, 1, (byte) 10);

for green color.

If you want any other color, just swap the number behind byte. You can see which color has which number here, in "Item Data": https://minecraftitemids.com/types/dye

an

When asked, he stands on 1.8 …

Then why do you give him an answer for 1.13 …

Fe

How should I use / change this:

if (e.getItem (). GetType () == Material.BLAZE_ROD && e.getItem (). GetItemMeta (). GetDisplayName (). EqualsIgnoreCase ("6lHide player")) {
final inventory inv = Bukkit.createInventory ((InventoryHolder) e.getPlayer (), 27, this.nameHide);
final ItemStack itemSee = new ItemStack (Material.BLAZE_ROD);
final ItemMeta itemmetaSee = itemSee.getItemMeta ();
itemmetaSee.setDisplayName (this.nameHideSee);
itemSee.setItemMeta (itemmetaSee);

final ItemStack itemVIP = new ItemStack (Material.NETHER_STAR);
final ItemMeta itemmetaVIP = itemVIP.getItemMeta ();
itemmetaVIP.setDisplayName (this.nameHideVIP);
itemVIP.setItemMeta (itemmetaVIP);

final ItemStack itemNone = new ItemStack (Material.BARRIER);
final ItemMeta itemmetaNone = itemNone.getItemMeta ();
itemmetaNone.setDisplayName (this.nameHideVIP);
itemNone.setItemMeta (itemmetaNone);

cl

Should be both - I always use a short anyway.

Fe

It does not work
DYE can't be resolved or is not a field

an

Oh sorry!

take

Material.INK_SACK

instead of Material.DYE

Fe

No problem.

Then can I also dye it green? So in the code yk wim

an

Jo, you can.

Simply the same code as above.

Just INK_SACK instead of DYE

Fe

So?:

ItemStack greencolor = new ItemStack (Material.INK_SACK, 1, (byte) 10);
ItemStack purplecolor = new ItemStack (Material.INK_SACK, 1, (byte) 5);
ItemStack redcolor = new ItemStack (Material.INK_SACK, 1, (byte) 1);

Fe

How am I supposed to get this in here?

if (e.getItem (). GetType () == Material.BLAZE_ROD && e.getItem (). GetItemMeta (). GetDisplayName (). EqualsIgnoreCase ("6lHide player")) {
final inventory inv = Bukkit.createInventory ((InventoryHolder) e.getPlayer (), 27, this.nameHide);
final ItemStack itemSee = new ItemStack (Material.BLAZE_ROD);
final ItemMeta itemmetaSee = itemSee.getItemMeta ();
itemmetaSee.setDisplayName (this.nameHideSee);
itemSee.setItemMeta (itemmetaSee);

final ItemStack itemVIP = new ItemStack (Material.NETHER_STAR);
final ItemMeta itemmetaVIP = itemVIP.getItemMeta ();
itemmetaVIP.setDisplayName (this.nameHideVIP);
itemVIP.setItemMeta (itemmetaVIP);

final ItemStack itemNone = new ItemStack (Material.BARRIER);
final ItemMeta itemmetaNone = itemNone.getItemMeta ();
itemmetaNone.setDisplayName (this.nameHideVIP);
itemNone.setItemMeta (itemmetaNone);

an

Simply replace all three "final item stack name = new item stack (…)" in brackets.

so (Material.BLAZE_ROD) with (Material.INK_SACK, 1, (byte) 10)

an

Jo, exactly like that

Eg

I just googled. I don't play Minecraft anymore.

Lo

Exactly. Byte is just too short compatible