Jump to content

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


Recommended Posts

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)

Posted

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

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

  • Thanks 1

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

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

Posted (edited)
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
Posted (edited)
 
 
 
 
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
Posted
 
 
 
 
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...

×   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.