Jump to content

Difficulty updating vanilla item damage


captainmk

Recommended Posts

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

Link to comment
Share on other sites

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)

  • Thanks 1

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.

Link to comment
Share on other sites

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.