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

Hello, first of all I'd like to lay out that I'm a brand new modder who is working on their first mod in 1.12, coming in with at least some amount of basic Java knowledge.

I'm trying to add behavior that will negate any damage taken to tools/armor if it is a certain tool material. From what I can tell, there aren't any forge hooks that will fire if an item changes its damage value, so at the moment I only have implemented a block break event that will detect if the mainhand held item is DIAMOND and if so, set the items damage to 0, which works perfectly.
So what's the problem?

The event handler executes the code and then hands it over to the vanilla methods, which proceed to attempt to damage the item, essentially giving the tool a permanent 1 item damage. I wouldn't mind this since it does indeed make the tool unbreakable, but it also renders the durability bar over the item, which I dislike. Trying to figure out this problem has honestly been a head scratcher, especially since I'm still very new to modding and don't fully understand what Forge is fully capable of yet. I've considered the following options:

1. Somehow cancel the client rendering the durability bar
2. Cancel the block break event and then put in my own implementation so that the tool isn't damaged
3. Every tick check to see if a diamond tool is damaged and then reverse it (Which seems like a very wasteful use of resources)
4. See if a library exists which can handle item durability better (I currently have no idea when to use libraries like Mantle, Bookshelf, Crafttweaker, ect.)
5. Create a custom forge hook that will fire when Item.setDamage() executes (No idea where to even start on this one)

Feedback would be a godsend since I've had little luck finding information related to this particular problem

7 hours ago, captainmk said:

Feedback would be a godsend since I've had little luck finding information related to this particular problem

Here's a suggestion that I've come up with remove diamond tools from having damage. In your PreInit event in your @Mod class do Items.DIAMOND_SOMETHING.setMaxDamage(0)

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

  • Author

This is exactly what I was looking for, and infinitely simpler and way more efficient than what I was trying to do.
Thank you!!

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.