Posted May 15, 201510 yr Hey ! I have created a custom armor (actually, it's only a helmet), but it doesn't repairs. Here is the code: public class ItemMask extends ItemArmor{ public ItemMask(String nom) { super(Masks.armorMask, 1, 0); this.setMaxDamage(2); this.setUnlocalizedName("mask_"+nom); this.canRepair = true; this.setCreativeTab(Masks.tabMasks); } @Override public boolean getIsRepairable(ItemStack input, ItemStack repair) { return repair.getItem() == Items.clay_ball ? true : false; } } Here is the ArmorMaterial: static int[] a = {1,1,1,1}; public static ArmorMaterial armorMask = EnumHelper.addArmorMaterial("armorMask", "mask", 2, a, 0); And even this doesn't work: @Override public boolean getIsRepairable(ItemStack input, ItemStack repair) { return true; } And there is something else: the armor doesn't break when it has 0HP, it takes one more hit to break it. Thank you for your help !
May 15, 201510 yr I think it is normal that the armor breaks when it has -1HP. Try instead of return repair.getItem() == Items.clay_ball ? true : false;[/Code] [code] @Override public boolean getIsRepairable(ItemStack input, ItemStack repair) { //input is the itemStack to be repaired, repair is the itemStack that should repair this item. //Change the bronze items to your own. return input.getItem() == MyItems.bronze_helmet && repair.getItem() == MyItems.bronze_ingot; } Also, the ? true : false[/Code] is not necessary, "input.getItem() instanceof ItemBronzeArmor && repair.getItem() == MyItems.bronze_ingo" already returns false or true. Hope this helps. Creator of the Master Chef Mod and many more to come. If I helped you, please click the 'thank you' button.
May 15, 201510 yr Author @Override public boolean getIsRepairable(ItemStack input, ItemStack repair) { //input is the itemStack to be repaired, repair is the itemStack that should repair this item. //Change the bronze items to your own. return input.getItem() == MyItems.bronze_helmet && repair.getItem() == MyItems.bronze_ingot; } This is not working. The weird thing is that it didn't work with: @Override public boolean getIsRepairable(ItemStack input, ItemStack repair) { return true; } And I know adding ? true : false is useless, but I tried everything I could.
May 15, 201510 yr System.out.println("Trying to repair: " + input.getItem() == MyItems.bronze_helmet + " && " + repair.getItem() == MyItems.bronze_ingot); Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
May 15, 201510 yr Author What you sent me caused an error, so I used this: System.out.println("Trying to repair: "); System.out.println(input.getItem() == Masks.mask_cow); System.out.println("&&"); System.out.println(repair.getItem() == Items.clay_ball); return input.getItem() == Masks.mask_cow && repair.getItem() == Items.clay_ball; And it printed: Trying to repair true && true
May 16, 201510 yr Post your code of the ItemMask class again. Creator of the Master Chef Mod and many more to come. If I helped you, please click the 'thank you' button.
May 16, 201510 yr Author The latest version is: package com.hamsterfurtif.masks.masques; import net.minecraft.init.Items; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import com.hamsterfurtif.masks.Masks; public class ItemMask extends ItemArmor{ public ItemMask(String nom) { super(Masks.armorMask, 1, 0); this.setMaxDamage(2); this.setUnlocalizedName("mask_"+nom); this.canRepair = true; this.setCreativeTab(Masks.tabMasks); } @Override public boolean getIsRepairable(ItemStack input, ItemStack repair) { boolean compatible = false; for (int i=0; i < Masks.masques.length; i++) { System.out.println("Trying to repair: "); System.out.println(input.getItem() == Masks.masques[i]); System.out.println("&&"); System.out.println(repair.getItem() == Items.clay_ball); if (input.getItem() == Masks.masques[i] && repair.getItem() == Items.clay_ball) compatible = true; } return compatible; } } With this in the main class: public static Item mask_clay = new ItemMask("clay"); public static Item mask_spider = new ItemMaskSpider(); public static Item mask_cow = new ItemMaskCow(); public static Item mask_mouton = new ItemMaskMouton(); public static Item mask_gardien = new ItemMaskGardien(); public static Item mask_squelette = new ItemMaskSquelette(); public static Item[] masques= {mask_clay, mask_spider, mask_cow, mask_mouton, mask_gardien, mask_squelette};
July 7, 201510 yr I'm not sure if its true for 1.8 but after some lengthy research I came across the solution for 1.7.10. Remove that getIsRepairable from your itemarmor class and put this in your main registry class/method put the following. //your enum name fallowed by the .customCraftingMaterial, than just set it to your item you want it to repair. ARMORCOPPER.customCraftingMaterial = ingotCopper; I use a register method, and I put this after everything was set in that method. So [Made in short hand]: Main class @mod() public void preInit() MyModsItemClass.registerItems(); MyModsItemClass class public static final ItemArmor.ArmorMaterial ARMORCOPPER = EnumHelper.addArmorMaterial("COPPER", 10, new int[]{2,3,2,2}, 12); public static Item myArmor; public static Item ingotCopper public static void registerItems(){ myArmor = new MyArmor(ARMORCOPPER, 0, 0, "", ""); ingotCopper = new MyItems(); ARMORCOPPER.customCraftingMaterial = ingotCopper; }
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.