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 custom item which i want to apply damage to when i click a custom block. The whole point to it is that after clicking a block, it takes one more damage until its damage is at 0 and must click another block for it to "refill" the damage before being used again. In the items constructor i set the max damage to 16. In the items use method, after all other logic is done, i call the items set damage method and set it as 1 lower than what it currently is. Also when i click on another certain block im calling the set damage method to the items max damage, as in the item gets fully repaired (without using anvils). In game this doesnt work, and no damage bar is shown on the item. I cannot post my code as im not home on my computer. So basically the question is how do i allow an item to lower its damage when clicked on a certain block, and how can the items damage "refill" after clicking another block. Or in better terms, how does minecraft handle item damage to items that are not considered tools?

Damage is incremental, not decremental. When the item's damage value equals the max damage value, that is displayed as '0/max' and the item breaks, but really it is 'max/max'. An undamaged item is '0/max', but displays the opposite.

 

Normally you use ItemStack#damageItem to damage an itemstack, not #setItemDamage.

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.