Jump to content

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


Recommended Posts

Posted

"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!

Posted

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.

Posted

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!

Posted

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

×   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.