Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

  • Author
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.

  • Author

I read them from a file, it's supposed to be like a customizable thing.

  • Author
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?

  • Author
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)

  • Author
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?

  • Author
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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.