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

I am getting the nbtcompound from ItemStack, and I would like to edit one entry in the Lore array without needing to recreate everything..

Is editing one entry in the Lore array inside the item NBT possible? Perhaps somehow converting the existing nbt to a variable and changing it that way?

  • Author
40 minutes ago, diesieben07 said:

NBTTagList has a set method which you can use.

Is there a way I can edit the exact entry?

Doesn't that mean all other tags will be deleted? Or you can somehow directly go to the Lore taglist

  • Author
1 minute ago, diesieben07 said:

I am sorry, but I am not quite following what your issue is. The set method I mentioned sets the entry at a specific position in the list.

I would like to change one Lore array entry inside an existing item (Lore set by server, not in my control), so I get the ItemStack and what I would like to do it enter display > Lore > index of my choice, and set it to something else.

  • Author
Just now, diesieben07 said:

You say "set by server". Does that mean you are writing a client-only mod? If so, this cannot work. You could set it temporarily for this specific client using ItemTooltipEvent. If you want to actually change the NBT in the stack, it must be done on the server. And in that case I still do not understand what the problem with the proposed method is.

Yeah I know, I would like this to be client side only for the session only (or to whenever the server changes it).

  • Author

Let's say I get the tag comp from ToolTipEvent.getItemStack().getTagCompound(), then store it inside a variable.

Can I change one entry inside that array and push it back to the tag compound?

3 minutes ago, Coder said:

Let's say I get the tag comp from ToolTipEvent.getItemStack().getTagCompound(), then store it inside a variable.

Can I change one entry inside that array and push it back to the tag compound?

No.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author
2 minutes ago, Draco18s said:

No.

So I should just recreate it. Alright.

  • Author
Just now, diesieben07 said:

No.

You cannot change the NBT on the client. At all.

Changing the Lore client side? why not? I just did it.

  • Author
Just now, diesieben07 said:

The data is going to get overridden by the server as soon as you move anything in your inventory.

I know, it's fine. I just want to know how to change it for the moment.

It would be much easier if I could just target the entry and change it. But looks like it's not possible, thus meaning I need to recreate the nbt compound.

  • Author
1 minute ago, diesieben07 said:

What are you even talking about... Yes, you can "target the entry and change it". I told you which method you need to use like 5 times already. You failed to mention why it does not work for you.

And I fail to understand how this is in any way useful. If you are unlucky your change will not even survive for one tick.

That's what I don't understand here. How can I get the full Lore array modify it and set it back again, without messing around with the "Name" or anything else.

As I said, it's inside display and inside Lore, how can I get it using the other stuff you mentioned, from what I see there you enter the nbt comp and an index.

One thing you're not understanding is that you can think of NBT as a map data structure that has keys (called "tags"). So it is not just one tagged entry, rather it is a "compound" of multiple tagged entries. When you use the set method, it just edits the entry for the thing that is tagged with the same tag key. No need to recreate the whole compound, the single entry can be edited directly.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.