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.

[1.14.4]How to make an Infinite Durability Item that CAN be enchanted.

Featured Replies

Posted

Hey guys, new modder and programmer here.

 

I am trying to make an item with infinite durability that can ALSO be enchanted. I set the durability value of my tools to -1, but now it cannot be enchanted. I'm not sure, it may have to do with this section of Item.class. Since my item isn't damageable, it isn't enchantable either.

 

image.png.b433bb8d09b8fcb350f7eda8d9c8bee5.png

 

I do not want to make the durability arbitrarily high, I would prefer there to be no green bar showing the durability to keep things clean and tidy.

 

In 1.12, there was a setMaxDamage option and you could setMaxDamage of an object to 0. Do you guys know any alternatives and how to implement them?

 

One of the items that I want to have infinite durability is stored in ItemList.amethyst_pickaxe if that will help.

 

(I'm a beginner programmer, code examples would be nice)

You can override Item#isEnchantable(), and alter the return conditions.

In your case, you'd probably just want to return true.

Fancy 3D Graphing Calculator mod, with many different coordinate systems.

Lightweight 3D/2D position/vector transformations library, also with support for different coordinate systems.

  • Author
11 hours ago, SerpentDagger said:

You can override Item#isEnchantable(), and alter the return conditions.

In your case, you'd probably just want to return true.

 

How would I override an already defined item's property? I've tried a bunch of stuff related to your suggestion on my own, but I get error messages.

 

This is what I tried:

 

ItemList.amethyst_pickaxe.isEnchantable(new ItemStack(ItemList.black_opal_pickaxe)) = true;

 

Obviously I'm not doing this right.

 

The Amethyst pickaxe I want to make infinite durability is already individually defined as a PickaxeItem with its own efficiency and attack damage etc.

 

Thanks.

 

Edited by Squidsword

  • Author
 
 
 
 
6 minutes ago, diesieben07 said:

This is your item, no? Do you know how to override methods? This is basic Java knowledge, which is required for modding.

No, I'm not sure. I started a few days ago. I'm learning from tutorials and open-source mods. May you show me an example of how to override a method? I have created my tools using the normal AxeItem PickaxeItem etc..., I'm willing to learn.

 

I apologize if I'm too uninformed.

 

Edited by Squidsword

  • Author
 
 
 
 
26 minutes ago, diesieben07 said:

This is not a Java school. Basic Java knowledge is required before writing a mod.

Basic information about inheritance: https://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html

The sub-chapter about overriding methods: https://docs.oracle.com/javase/tutorial/java/IandI/override.html

image.png.d7cd6b9ba595e19942ad3bc666f96df3.png

 

Alright, thanks for that, good read. I managed to fix the problem. Here's what I did for anyone else that has the same problem as me.

 

 

 

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.