Allow repairing gem tools and armor in anvil

This commit is contained in:
modmuss50 2018-06-08 18:33:26 +01:00
parent 93e324cc11
commit 548d393820
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82
7 changed files with 144 additions and 36 deletions

View file

@ -227,84 +227,84 @@ public class ModItems {
registerItem(ADVANCED_JACKHAMMER, "ironjackhammer");
if (ConfigTechReborn.enableGemArmorAndTools) {
BRONZE_SWORD = new ItemTRSword(Reference.BRONZE);
BRONZE_SWORD = new ItemTRSword(Reference.BRONZE, "ingotBronze");
registerItem(BRONZE_SWORD, "bronzeSword");
BRONZE_PICKAXE = new ItemTRPickaxe(Reference.BRONZE);
BRONZE_PICKAXE = new ItemTRPickaxe(Reference.BRONZE, "ingotBronze");
registerItem(BRONZE_PICKAXE, "bronzePickaxe");
BRONZE_SPADE = new ItemTRSpade(Reference.BRONZE);
BRONZE_SPADE = new ItemTRSpade(Reference.BRONZE, "ingotBronze");
registerItem(BRONZE_SPADE, "bronzeSpade");
BRONZE_AXE = new ItemTRAxe(Reference.BRONZE);
BRONZE_AXE = new ItemTRAxe(Reference.BRONZE, "ingotBronze");
registerItem(BRONZE_AXE, "bronzeAxe");
BRONZE_HOE = new ItemTRHoe(Reference.BRONZE);
BRONZE_HOE = new ItemTRHoe(Reference.BRONZE, "ingotBronze");
registerItem(BRONZE_HOE, "bronzeHoe");
BRONZE_HELMET = new ItemTRArmour(Reference.BRONZE_ARMOUR, EntityEquipmentSlot.HEAD);
BRONZE_HELMET = new ItemTRArmour(Reference.BRONZE_ARMOUR, EntityEquipmentSlot.HEAD, "ingotBronze");
registerItem(BRONZE_HELMET, "bronzeHelmet");
BRONZE_CHESTPLATE = new ItemTRArmour(Reference.BRONZE_ARMOUR, EntityEquipmentSlot.CHEST);
BRONZE_CHESTPLATE = new ItemTRArmour(Reference.BRONZE_ARMOUR, EntityEquipmentSlot.CHEST, "ingotBronze");
registerItem(BRONZE_CHESTPLATE, "bronzeChestplate");
BRONZE_LEGGINGS = new ItemTRArmour(Reference.BRONZE_ARMOUR, EntityEquipmentSlot.LEGS);
BRONZE_LEGGINGS = new ItemTRArmour(Reference.BRONZE_ARMOUR, EntityEquipmentSlot.LEGS, "ingotBronze");
registerItem(BRONZE_LEGGINGS, "bronzeLeggings");
BRONZE_BOOTS = new ItemTRArmour(Reference.BRONZE_ARMOUR, EntityEquipmentSlot.FEET);
BRONZE_BOOTS = new ItemTRArmour(Reference.BRONZE_ARMOUR, EntityEquipmentSlot.FEET, "ingotBronze");
registerItem(BRONZE_BOOTS, "bronzeBoots");
RUBY_SWORD = new ItemTRSword(Reference.RUBY);
RUBY_SWORD = new ItemTRSword(Reference.RUBY, "gemRuby");
registerItem(RUBY_SWORD, "rubySword");
RUBY_PICKAXE = new ItemTRPickaxe(Reference.RUBY);
RUBY_PICKAXE = new ItemTRPickaxe(Reference.RUBY, "gemRuby");
registerItem(RUBY_PICKAXE, "rubyPickaxe");
RUBY_SPADE = new ItemTRSpade(Reference.RUBY);
RUBY_SPADE = new ItemTRSpade(Reference.RUBY, "gemRuby");
registerItem(RUBY_SPADE, "rubySpade");
RUBY_AXE = new ItemTRAxe(Reference.RUBY);
RUBY_AXE = new ItemTRAxe(Reference.RUBY, "gemRuby");
registerItem(RUBY_AXE, "rubyAxe");
RUBY_HOE = new ItemTRHoe(Reference.RUBY);
RUBY_HOE = new ItemTRHoe(Reference.RUBY, "gemRuby");
registerItem(RUBY_HOE, "rubyHoe");
RUBY_HELMET = new ItemTRArmour(Reference.RUBY_ARMOUR, EntityEquipmentSlot.HEAD);
RUBY_HELMET = new ItemTRArmour(Reference.RUBY_ARMOUR, EntityEquipmentSlot.HEAD, "gemRuby");
registerItem(RUBY_HELMET, "rubyHelmet");
RUBY_CHESTPLATE = new ItemTRArmour(Reference.RUBY_ARMOUR, EntityEquipmentSlot.CHEST);
RUBY_CHESTPLATE = new ItemTRArmour(Reference.RUBY_ARMOUR, EntityEquipmentSlot.CHEST, "gemRuby");
registerItem(RUBY_CHESTPLATE, "rubyChestplate");
RUBY_LEGGINGS = new ItemTRArmour(Reference.RUBY_ARMOUR, EntityEquipmentSlot.LEGS);
RUBY_LEGGINGS = new ItemTRArmour(Reference.RUBY_ARMOUR, EntityEquipmentSlot.LEGS, "gemRuby");
registerItem(RUBY_LEGGINGS, "rubyLeggings");
RUBY_BOOTS = new ItemTRArmour(Reference.RUBY_ARMOUR, EntityEquipmentSlot.FEET);
RUBY_BOOTS = new ItemTRArmour(Reference.RUBY_ARMOUR, EntityEquipmentSlot.FEET, "gemRuby");
registerItem(RUBY_BOOTS, "rubyBoots");
SAPPHIRE_SWORD = new ItemTRSword(Reference.SAPPHIRE);
SAPPHIRE_SWORD = new ItemTRSword(Reference.SAPPHIRE, "gemSapphire");
registerItem(SAPPHIRE_SWORD, "sapphireSword");
SAPPHIRE_PICKAXE = new ItemTRPickaxe(Reference.SAPPHIRE);
SAPPHIRE_PICKAXE = new ItemTRPickaxe(Reference.SAPPHIRE, "gemSapphire");
registerItem(SAPPHIRE_PICKAXE, "sapphirePickaxe");
SAPPHIRE_SPADE = new ItemTRSpade(Reference.SAPPHIRE);
SAPPHIRE_SPADE = new ItemTRSpade(Reference.SAPPHIRE, "gemSapphire");
registerItem(SAPPHIRE_SPADE, "sapphireSpade");
SAPPHIRE_AXE = new ItemTRAxe(Reference.SAPPHIRE);
SAPPHIRE_AXE = new ItemTRAxe(Reference.SAPPHIRE, "gemSapphire");
registerItem(SAPPHIRE_AXE, "sapphireAxe");
SAPPHIRE_HOE = new ItemTRHoe(Reference.SAPPHIRE);
SAPPHIRE_HOE = new ItemTRHoe(Reference.SAPPHIRE, "gemSapphire");
registerItem(SAPPHIRE_HOE, "sapphireHoe");
SAPPHIRE_HELMET = new ItemTRArmour(Reference.SAPPHIRE_ARMOUR, EntityEquipmentSlot.HEAD);
SAPPHIRE_HELMET = new ItemTRArmour(Reference.SAPPHIRE_ARMOUR, EntityEquipmentSlot.HEAD, "gemSapphire");
registerItem(SAPPHIRE_HELMET, "sapphireHelmet");
SAPPHIRE_CHSTPLATE = new ItemTRArmour(Reference.SAPPHIRE_ARMOUR, EntityEquipmentSlot.CHEST);
SAPPHIRE_CHSTPLATE = new ItemTRArmour(Reference.SAPPHIRE_ARMOUR, EntityEquipmentSlot.CHEST, "gemSapphire");
registerItem(SAPPHIRE_CHSTPLATE, "sapphireChestplate");
SAPPHIRE_LEGGINGS = new ItemTRArmour(Reference.SAPPHIRE_ARMOUR, EntityEquipmentSlot.LEGS);
SAPPHIRE_LEGGINGS = new ItemTRArmour(Reference.SAPPHIRE_ARMOUR, EntityEquipmentSlot.LEGS, "gemSapphire");
registerItem(SAPPHIRE_LEGGINGS, "sapphireLeggings");
SAPPHIRE_BOOTS = new ItemTRArmour(Reference.SAPPHIRE_ARMOUR, EntityEquipmentSlot.FEET);
SAPPHIRE_BOOTS = new ItemTRArmour(Reference.SAPPHIRE_ARMOUR, EntityEquipmentSlot.FEET, "gemSapphire");
registerItem(SAPPHIRE_BOOTS, "sapphireBoots");
PERIDOT_SWORD = new ItemTRSword(Reference.PERIDOT);
PERIDOT_SWORD = new ItemTRSword(Reference.PERIDOT, "gemPeridot");
registerItem(PERIDOT_SWORD, "peridotSword");
PERIDOT_PICKAXE = new ItemTRPickaxe(Reference.PERIDOT);
PERIDOT_PICKAXE = new ItemTRPickaxe(Reference.PERIDOT, "gemPeridot");
registerItem(PERIDOT_PICKAXE, "peridotPickaxe");
PERIDOT_SAPPHIRE = new ItemTRSpade(Reference.PERIDOT);
PERIDOT_SAPPHIRE = new ItemTRSpade(Reference.PERIDOT, "gemPeridot");
registerItem(PERIDOT_SAPPHIRE, "peridotSpade");
PERIDOT_AXE = new ItemTRAxe(Reference.PERIDOT);
PERIDOT_AXE = new ItemTRAxe(Reference.PERIDOT, "gemPeridot");
registerItem(PERIDOT_AXE, "peridotAxe");
PERIDOT_HOE = new ItemTRHoe(Reference.PERIDOT);
PERIDOT_HOE = new ItemTRHoe(Reference.PERIDOT, "gemPeridot");
registerItem(PERIDOT_HOE, "peridotHoe");
PERIDOT_HELMET = new ItemTRArmour(Reference.PERIDOT_ARMOUR, EntityEquipmentSlot.HEAD);
PERIDOT_HELMET = new ItemTRArmour(Reference.PERIDOT_ARMOUR, EntityEquipmentSlot.HEAD, "gemPeridot");
registerItem(PERIDOT_HELMET, "peridotHelmet");
PERIDOT_CHESTPLATE = new ItemTRArmour(Reference.PERIDOT_ARMOUR, EntityEquipmentSlot.CHEST);
PERIDOT_CHESTPLATE = new ItemTRArmour(Reference.PERIDOT_ARMOUR, EntityEquipmentSlot.CHEST, "gemPeridot");
registerItem(PERIDOT_CHESTPLATE, "peridotChestplate");
PERIDOT_LEGGINGS = new ItemTRArmour(Reference.PERIDOT_ARMOUR, EntityEquipmentSlot.LEGS);
PERIDOT_LEGGINGS = new ItemTRArmour(Reference.PERIDOT_ARMOUR, EntityEquipmentSlot.LEGS, "gemPeridot");
registerItem(PERIDOT_LEGGINGS, "peridotLeggings");
PERIDOT_BOOTS = new ItemTRArmour(Reference.PERIDOT_ARMOUR, EntityEquipmentSlot.FEET);
PERIDOT_BOOTS = new ItemTRArmour(Reference.PERIDOT_ARMOUR, EntityEquipmentSlot.FEET, "gemPeridot");
registerItem(PERIDOT_BOOTS, "peridotBoots");
}

View file

@ -26,6 +26,8 @@ package techreborn.items.armor;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import reborncore.common.util.ItemUtils;
import techreborn.client.TechRebornCreativeTabMisc;
import techreborn.events.TRRecipeHandler;
@ -34,8 +36,15 @@ import techreborn.events.TRRecipeHandler;
*/
public class ItemTRArmour extends ItemArmor {
String repairOreDict = "";
public ItemTRArmour(ArmorMaterial material, EntityEquipmentSlot slot) {
this(material, slot, "");
}
public ItemTRArmour(ArmorMaterial material, EntityEquipmentSlot slot, String repairOreDict) {
super(material, material.getDamageReductionAmount(slot), slot);
this.repairOreDict = repairOreDict;
if (slot == EntityEquipmentSlot.HEAD)
setUnlocalizedName(material.name().toLowerCase() + "Helmet");
if (slot == EntityEquipmentSlot.CHEST)
@ -47,4 +56,12 @@ public class ItemTRArmour extends ItemArmor {
setCreativeTab(TechRebornCreativeTabMisc.instance);
TRRecipeHandler.hideEntry(this);
}
@Override
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
if(toRepair.getItem() == this && !repairOreDict.isEmpty()){
return ItemUtils.isInputEqual(repairOreDict, repair, false, false, true);
}
return super.getIsRepairable(toRepair, repair);
}
}

View file

@ -25,14 +25,32 @@
package techreborn.items.tools;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import reborncore.common.util.ItemUtils;
import techreborn.client.TechRebornCreativeTabMisc;
import techreborn.events.TRRecipeHandler;
public class ItemTRAxe extends ItemAxe {
String repairOreDict = "";
public ItemTRAxe(ToolMaterial material) {
this(material, "");
}
public ItemTRAxe(ToolMaterial material, String repairOreDict) {
super(material, material.getAttackDamage() + 5.75F, (material.getAttackDamage() + 6.75F) * -0.344444F);
this.repairOreDict = repairOreDict;
setUnlocalizedName(material.name().toLowerCase() + "Axe");
setCreativeTab(TechRebornCreativeTabMisc.instance);
TRRecipeHandler.hideEntry(this);
}
@Override
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
if(toRepair.getItem() == this && !repairOreDict.isEmpty()){
return ItemUtils.isInputEqual(repairOreDict, repair, false, false, true);
}
return super.getIsRepairable(toRepair, repair);
}
}

View file

@ -25,14 +25,24 @@
package techreborn.items.tools;
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.common.util.ItemUtils;
import techreborn.client.TechRebornCreativeTabMisc;
import techreborn.events.TRRecipeHandler;
public class ItemTRHoe extends ItemHoe {
String repairOreDict = "";
public ItemTRHoe(ToolMaterial material) {
this(material, "");
}
public ItemTRHoe(ToolMaterial material, String repairOreDict) {
super(material);
this.repairOreDict = repairOreDict;
setUnlocalizedName(material.name().toLowerCase() + "Hoe");
setCreativeTab(TechRebornCreativeTabMisc.instance);
TRRecipeHandler.hideEntry(this);
@ -43,4 +53,12 @@ public class ItemTRHoe extends ItemHoe {
public boolean isFull3D() {
return true;
}
@Override
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
if(toRepair.getItem() == this && !repairOreDict.isEmpty()){
return ItemUtils.isInputEqual(repairOreDict, repair, false, false, true);
}
return super.getIsRepairable(toRepair, repair);
}
}

View file

@ -25,14 +25,33 @@
package techreborn.items.tools;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemStack;
import reborncore.common.util.ItemUtils;
import techreborn.client.TechRebornCreativeTabMisc;
import techreborn.events.TRRecipeHandler;
public class ItemTRPickaxe extends ItemPickaxe {
String repairOreDict = "";
public ItemTRPickaxe(ToolMaterial material) {
this(material, "");
}
public ItemTRPickaxe(ToolMaterial material, String repairOreDict) {
super(material);
this.repairOreDict = repairOreDict;
setUnlocalizedName(material.name().toLowerCase() + "Pickaxe");
setCreativeTab(TechRebornCreativeTabMisc.instance);
TRRecipeHandler.hideEntry(this);
}
@Override
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
if(toRepair.getItem() == this && !repairOreDict.isEmpty()){
return ItemUtils.isInputEqual(repairOreDict, repair, true, false, true);
}
return super.getIsRepairable(toRepair, repair);
}
}

View file

@ -25,14 +25,32 @@
package techreborn.items.tools;
import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemStack;
import reborncore.common.util.ItemUtils;
import techreborn.client.TechRebornCreativeTabMisc;
import techreborn.events.TRRecipeHandler;
public class ItemTRSpade extends ItemSpade {
String repairOreDict = "";
public ItemTRSpade(ToolMaterial material) {
this(material, "");
}
public ItemTRSpade(ToolMaterial material, String repairOreDict) {
super(material);
this.repairOreDict = repairOreDict;
setUnlocalizedName(material.name().toLowerCase() + "Spade");
setCreativeTab(TechRebornCreativeTabMisc.instance);
TRRecipeHandler.hideEntry(this);
}
@Override
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
if(toRepair.getItem() == this && !repairOreDict.isEmpty()){
return ItemUtils.isInputEqual(repairOreDict, repair, false, false, true);
}
return super.getIsRepairable(toRepair, repair);
}
}

View file

@ -24,15 +24,33 @@
package techreborn.items.tools;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import reborncore.common.util.ItemUtils;
import techreborn.client.TechRebornCreativeTabMisc;
import techreborn.events.TRRecipeHandler;
public class ItemTRSword extends ItemSword {
String repairOreDict = "";
public ItemTRSword(ToolMaterial material) {
this(material, "");
}
public ItemTRSword(ToolMaterial material, String repairOreDict) {
super(material);
this.repairOreDict = repairOreDict;
setUnlocalizedName(material.name().toLowerCase() + "Sword");
setCreativeTab(TechRebornCreativeTabMisc.instance);
TRRecipeHandler.hideEntry(this);
}
@Override
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
if(toRepair.getItem() == this && !repairOreDict.isEmpty()){
return ItemUtils.isInputEqual(repairOreDict, repair, false, false, true);
}
return super.getIsRepairable(toRepair, repair);
}
}