How to get the name of a named item?

Started by EndPlayz_ on

Topic category: Help with modding (Java Edition)

Last seen on 08:06, 29. Jan 2024
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to get the name of a named item?

How would I be able to get the name of the item in my mainhand, and if it's named then the named item?

Sorry if that was a poor explanation, but Thanks in advance!

 

Last seen on 20:49, 23. Jun 2023
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'd make a procedure. Within…
Sun, 06/18/2023 - 21:42

I'd make a procedure. Within the procedure, create a local String variable, I named it DisplayName. Custom variables -> Set Local: DisplayName. It requires an argument, so what we will use is "Get display name of" which you can find at Item procedures (scroll down to the bottom). Remove the block argument that's already in it, and replace that with Entity data -> "Item in main-hand of", which should be connected to Event/target entity. Once you have Get display name of [Item in main-hand of: Event/target entity], attach that block to the Set Local: DisplayName.

 

Now that you have the variable, you can reference it wherever you need to within the procedure, or you can of course call the procedure/use it in a trigger. It may be worth making a Global variable instead if you're wanting to access it from other procedures. I hope this helps!

Last seen on 08:06, 29. Jan 2024
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks! It works fine, but I…
Thu, 06/22/2023 - 09:17

Thanks! It works fine, but I'm using it in a command and I need to get rid of the brackets. Anyway to do that?

 

Thanks in advance!