Posted July 10, 201510 yr Hello. I was just wondering how you would go about making a custom tool repairable. Let's say I have an Obsidian Pickaxe (ModItems.obsidian_pickaxe) and I want to repair it with Obsidian (Blocks.obsidian) in an anvil. How might I do that? Best regards, Jarod Beau [email protected]
July 10, 201510 yr Try overriding the getIsRepairable method, not sure if it still works Don't blame me if i always ask for your help. I just want to learn to be better
July 10, 201510 yr To override the getRepairItemStack he need to create a custom Tool Material class, i guess Don't blame me if i always ask for your help. I just want to learn to be better
July 10, 201510 yr I bunce into this discussion, so we can solve two problems at once I have my custom ItemArmor class, now to say at the game "if i have a ruby armor and i'm using a ruby in the anvil than repair my armor" how could i do? I think is the same question that the guy above is making package mw.items; import mw.core.MW; import mw.core.MWItems; import mw.core.utils.Utils; import net.minecraft.entity.Entity; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; public class ItemArmorMW extends ItemArmor { private String material; public ItemArmorMW(ArmorMaterial par1, int par2, int par3, String name) { super(par1, par2, par3); Utils.setCombatItemInfo(this, name); this.material = par1.name().toLowerCase(); } public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { if(slot == 2) return MW.MODID + ":" + "textures/models/armor/" + this.material + "_2.png"; else return MW.MODID + ":" + "textures/models/armor/" + this.material + "_1.png"; } @Override public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { if(repair.equals(MWItems.ruby) && toRepair.equals(this)) return true; else return false; } } I've tried overriding the getIsRepairable method but is not working Don't blame me if i always ask for your help. I just want to learn to be better
July 10, 201510 yr Ok, so i found the solution. You need to add to override the function getIsRepairable in your ItemArmor class (wich of course it must extend the vanilla ItemArmor class) or in your custom Tool class. To do this you need to add this lines @Override public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { if(repair.getItem().equals(-MY ARMOR ITEM (example: Obsidian))) return true; else return false; } Basically what you need to check is if the Item in the second andvil slot is equal to an item that you want (in this case you check if that item is an obsidian block, so you can repair an obsidian armor/tool). Hope this helped, at least for armor it works for me Don't blame me if i always ask for your help. I just want to learn to be better
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.