Minecraft Spigot Plugin ItemStack with Id?

Ju
- in Mods
6

I'm currently programming a Spigot plugin for Minecraft, just to practice a random block mod, this is a mod where you get a random look when you dismantle another. Now the problem is that so far I have only used ItemStacks with Material.STONE, now Stone only as an example so:

ItemStack item = new ItemStack (Material.STONE)

could add, and it would be stupid if I had to add each item individually. That would be easier if I could add ItemStacks with the Item ID, i.e. Air: 0, stone: 1, granite: 1: 1 or something. Does jmd know how to do that?

pe

That's fine.

You can:

Use ItemStack item = new ItemStack (Material.getMaterial ([id]), 1, ([subid])).

(The square brackets are actually not included!)

The id in the square brackets stands for the normal id as for stone 1.

The subid in the square brackets stands for the number behind the: For example for granite 1: 1 and then you only have to put down a 1.

For example, for light green wool you then use:

ItemStack item = new ItemStack (Material.getMaterial (35), 1, (5)).

If you were to write this down exactly the same way you would get an error, then you only have to write @SuppressWarnings ("deprecation"), because of getMaterial (), over the ItemStack.

I hope I could help you and that was what you wanted to know.

Ju

Thanks, it worked.

Ba

And is that still possible in 1.14?

pe

I only did it for 1.8, but actually it should also work in 1.14 (just give it a try) if not just write again.

Ba

Jo i try. But this can't work normally because the IDs have been completely abolished since 1.13

pe

Oh ok I didn't know that, but thanks for the info.