Posted August 20, 201510 yr Is there a way to make an item "Durable" like, it gets destroyed after a certain amount of time, no matter if it's on the players inventory, or in a chest, or wherever... Thanks a lot for any help.
August 20, 201510 yr My idea would be to use a tickhandler to count ticks, add the item to a list, after a specific amount of ticks look if the stack still exists, if it does destroy it. that way you can bypass that they stop ticking when they are in a chest
August 20, 201510 yr Set an expiry date in the ItemStack NBT, e.g. world.getWorldTime() + duration_in_ticks, then compare the current world time to the expiration date. You won't really be able to reliably 'destroy' the ItemStack if it's in some random container, though, since you'd need to have a reference to the container (i.e. the IInventory) in order to set the contents of the slot to null - just setting the ItemStack to null won't actually affect the container or any other place that has a reference to it. You could, however, decrement the stack size. Once the stack size is 0, it should (I think...) get removed when a player interacts with it, but to make sure you can override the Item's update tick (which fires every tick the item is in a player's inventory) to remove the itemstack if the stack size is 0. http://i.imgur.com/NdrFdld.png[/img]
August 20, 201510 yr Author Thanks for the help guys Sounds complicate, gonna do some testing and see how I can handle it.
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.