How do I tell MC the string variable I'm tagging an item with is - actually - a compound data tag?

Started by DoubleJointedI… on

Topic category: Help with MCreator software

Last seen on 17:58, 6. Aug 2021
Joined Aug 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I tell MC the string variable I'm tagging an item with is - actually - a compound data tag?

I use a local string variable to dynamically store the results of several if statements.*

I've built the string so it has a similar structure to an already-existing Minecraft item's data tag (which has sub-tags, including an integer array, integers, booleans...). My procedure, which uses:

Set NBT text tag <the_tag> of <item> to <the_string_variable>

...is too literal! It applies one variable under the tag, and doesn't realise it's a compound data tag. So, testing with /data get, the result is:

{id: "mymod:<item>", Count: 1b, tag: {<the_tag>: "{<subtag_a, subtag_b, ...}"}}

When I want:

{id: "mymod:<item>", Count: 1b, tag: {<the_tag>: {<subtag_a, subtag_b, ...}}}

I've tried many ways of removing the quotes. I've trawled the forums and found "solutions" which don't appear to work. I've read Forge docs and Stringified NBT and it's all way, way over my head =D

 

*Due to the item I'm adding, I can't dynamically build up tags without absurd complexity. That's why I'm using a string (since /data get returns a string, I figured it could work)

Last seen on 09:42, 5. Sep 2023
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Try using a different var…
Fri, 08/06/2021 - 06:27

Try using a different var.

Your local var will get reset every time you start a new game. If your storing data via 0,1,2 etc and want to keep it after player quits. You have to use another var. 

Quotes in java code cant be changed. You can erase what is inside the scope of the quotes but you can not remove them. You can remove the entire line or lines of code. I think this would go for most cases. 

GL

Chew

Last seen on 17:58, 6. Aug 2021
Joined Aug 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I want the " marks removed,…
Fri, 08/06/2021 - 14:14

I want the " marks removed, the bit inside applied as a compound data tag.

I'm open to using another var type. However it must be able to store Ints, Int Arrays, and booleans. Which is why I used a string.