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 have a question, I have an item that stores a boolean value when the player right clicks it.

I notice that the NBT isn't there until the first right click I use on it. I know we have the onCreated method. But it looks like that only gets called when the item is crafted. But not if I'm on Creative Mode and pick it from inventory.

Is there anything to do around this to get the NBT created even when the item is picked up on creative mode?

  • Author
3 hours ago, diesieben07 said:

Please no.

 

Have a method which lazily initializes the NBT tag and only use that method to access the tag. Pseudocode:


int getMyTag(stack) {
    if (stack does not have nbt tag) {
        add default nbt tag
    }
    return nbt tag from stack
}

 

But when and where from that method would get called?

And sorry for this question, I guess the answer is probably obvious, but... Can an item have NBT data "pre-loaded" like for example on the Creative Tab come already with the NBT on it?

  • Author

I believe I didn't explain the problem correctly. For example I call the NBT from "onItemRightClick" and there, if the NBT doesn't exists, it gets created. I'm looking for the NBT to exists right away. That's why I call that from onCreated, but the problem is that onCreated doesn't trigger when I pick the item in creative mode.

Sorry if it sounds repetitive, but maybe I didn't explain the problem correctly.

PS: I also read NBT from the method that display items description when you hover on them. But that runs only "Client Side" is that good to create the NBT there? Or it needs to be done on a method that runs both server and client side.

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.