Posted November 16, 20195 yr 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. 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)
November 16, 20195 yr 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.
November 16, 20195 yr 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 November 16, 20195 yr by Squidsword
November 16, 20195 yr 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 November 16, 20195 yr by Squidsword
November 16, 20195 yr 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 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.