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

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.

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

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.

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.