Jump to content

Recommended Posts

Posted

[1.16.5] Hello, when I parse a JSON string to an ItemStack using JsonToNBT#parseTag with JSON seen beneath, the texture of the skull does not get applied. Any way to fix this?

All other attributes / properties are being applied just fine. Here is the JSON I am using:

{
      "id": "player_head",
      "Count": 1,
      "tag": {
        "CustomModelData": 100001,
        "HideFlags": -1,
        "SkullOwner": {
          "Id": [
            1334301174,
            1630424667,
            -1957730237,
            1373073981
          ],
          "Properties": {
            "textures": [
              {
                "Value": "ewogICJ0aW1lc3RhbXAiIDogMTYwMTU4MDc5MjcyMiwKICAicHJvZmlsZUlkIiA6ICJlZDUzZGQ4MTRmOWQ0YTNjYjRlYjY1MWRjYmE3N2U2NiIsCiAgInByb2ZpbGVOYW1lIiA6ICIwMTAwMDExMDAxMDAwMDExIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2FmMzgyMzQ1ZmQ3OWZjNzgzNjFjNjFjOTYyMzBjNjk0YzM0NDc5MzU4YWMwYWU0OWM0ZGI3YTYyNGE1YWZlNTQiCiAgICB9CiAgfQp9"
              }
            ]
          }
        },
        "display": {
          "Name": "{\"italic\":false,\"color\":\"yellow\",\"text\":\"Next \\u003e\"}"
        }
      }
    }

Kind regards,

Kyllian

Posted
5 minutes ago, diesieben07 said:

Why are you using JsonToNBT for this?

Because I have a bunch of JSON data of items and I want to turn them into actual ItemStacks. JsonToNBT is the first working class I found that does this.

Posted
12 minutes ago, diesieben07 said:

Have you verified that the NBT is created correctly?

Do you mean when going from ItemStack to JSON or from JSON to ItemStack?

Posted
Just now, diesieben07 said:

From JSON to ItemStack.

Why are you doing the reverse?

Okay let me explain a bit further: So the idea is you create a gui, it will then store all items from the gui as json and then you can load the exact same gui again. If that makes sense.

As for how I create the ItemStack:

ItemStack item = ItemStack.of(JsonToNBT.parseTag(itemObject.toString()));

with itemObject being a JsonObject (the JSON for example showed in my OP)

Posted
8 minutes ago, diesieben07 said:

Just store it as NBT then? Why JSON?

Alright, but how would I get the root NBT tag of an ItemStack? If I just use #getOrCreateTag it will just give me the tag and not the item ID etc right?

Posted
6 minutes ago, diesieben07 said:

ItemStack#save to save it to NBT and ItemStack.of to restore it.

Oh, thanks. This also indeed fixed my texture problem. Thank you very much.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.