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.

[1.7.2] how do i make an item replace itself with another item in onUpdate()?

Featured Replies

  • Author

"in a void" - No comment on that.

For this to work you need a tick counter in the ItemStack. You can use the NBT or the damage value for this. To do this use the onUpdate method, it is called as long as the Item is in your inventory.

i am using the onUpdate method, but it doesnt return anything (thats what i ment with void) so i dont know how i can do this there since its different from in methods like onEaten and onRightClick which returns the itemstack.

http://www.planetminecraft.com/member/sigurd4

I'm making the bioshock mod!

The return type of

onUpdate

has nothing to do with replacing the

ItemStack

.

 

As diesieben07 said, you need a tick counter in the

ItemStack

through either NBT or damage value.

 

It should be a matter of simply creating a new

ItemStack

and replacing the player's current item with this new stack after x ticks, as indicated by the NBT/damage value.

  • Author

The return type of

onUpdate

has nothing to do with replacing the

ItemStack

.

 

As diesieben07 said, you need a tick counter in the

ItemStack

through either NBT or damage value.

 

It should be a matter of simply creating a new

ItemStack

and replacing the player's current item with this new stack after x ticks, as indicated by the NBT/damage value.

thats excactly what i want to do, but i dont know how.

http://www.planetminecraft.com/member/sigurd4

I'm making the bioshock mod!

Hint: The quote functionality is mostly useful for quoting posts earlier than the most recent post, as well as quoting specific parts of posts :)

 

Anyway, pseudocode:

 

onUpdate() {
    if (ticks++ >= 100) {
        // Remove player's current ItemStack
        // Give player new ItemStack in that slot
    }
}

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.