get item id in procedure

Started by T-cat2.0 on

Topic category: Advanced modding

Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
get item id in procedure

is there a way to get the item id from an item in a slot e.g. I put cobblestone in slot 0 and i make it print that to chat: it prints 1xminecraft:stone 2.

I need it to print minecraft:stone:2 not 1xminecraft:stone 2, is this posable?

Joined Nov 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
yes just remove each letter…
Sun, 07/24/2022 - 19:48

yes just remove each letter until the letter is x and then remove x

 

Joined Feb 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If you can use custom code…
Sun, 08/21/2022 - 20:44

If you can use custom code at all you can use this to get the namespace and then do whatever you want with the string. I couldn't figure out how to get the namespace of an item anymore I looked everywhere in minecraft's code that I could think of but I could only find getDesciptionId() which is different. There used to be plugins that did it but that code didn't work anymore. This will get the namespace of a block or item though.

Rename item to whatever the itemstack your using is.

//Get Item Namespace
                    String descriptionId = item.getDescriptionId().toString();
                    String[] stringSplit = descriptionId.split("\\.");
                    String modName = stringSplit[1];
                    String itemName = stringSplit[2];
                    String namespace = modName + ":" + itemName;

If anyone else has a better way to get the namespace in code than converting the desciption id please lmk.