diff --git a/src/main/java/ellpeck/actuallyadditions/items/tools/table/EnchantmentCombo.java b/src/main/java/ellpeck/actuallyadditions/items/tools/table/EnchantmentCombo.java new file mode 100644 index 000000000..d164f587f --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/items/tools/table/EnchantmentCombo.java @@ -0,0 +1,24 @@ +/* + * This file ("EnchantmentCombo.java") is part of the Actually Additions Mod for Minecraft. + * It is created and owned by Ellpeck and distributed + * under the Actually Additions License to be found at + * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015 Ellpeck + */ + +package ellpeck.actuallyadditions.items.tools.table; + +import net.minecraft.enchantment.Enchantment; + +public class EnchantmentCombo{ + + public Enchantment enchantment; + public int level; + + public EnchantmentCombo(Enchantment ench, int level){ + this.enchantment = ench; + this.level = level; + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/items/tools/table/IToolTableRepairItem.java b/src/main/java/ellpeck/actuallyadditions/items/tools/table/IToolTableRepairItem.java new file mode 100644 index 000000000..59afecc2c --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/items/tools/table/IToolTableRepairItem.java @@ -0,0 +1,20 @@ +/* + * This file ("IToolTableRepairItem.java") is part of the Actually Additions Mod for Minecraft. + * It is created and owned by Ellpeck and distributed + * under the Actually Additions License to be found at + * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015 Ellpeck + */ + +package ellpeck.actuallyadditions.items.tools.table; + +import net.minecraft.item.ItemStack; + +public interface IToolTableRepairItem{ + + ItemStack getRepairStack(); + + int repairPerStack(); +} diff --git a/src/main/java/ellpeck/actuallyadditions/items/tools/table/InitToolTableTools.java b/src/main/java/ellpeck/actuallyadditions/items/tools/table/InitToolTableTools.java index ae142dab1..e9e386549 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/tools/table/InitToolTableTools.java +++ b/src/main/java/ellpeck/actuallyadditions/items/tools/table/InitToolTableTools.java @@ -10,22 +10,30 @@ package ellpeck.actuallyadditions.items.tools.table; -import ellpeck.actuallyadditions.items.tools.table.ItemPickaxeFixedEnchants.EnchantmentCombo; import ellpeck.actuallyadditions.util.ItemUtil; import net.minecraft.enchantment.Enchantment; +import net.minecraft.init.Items; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; public class InitToolTableTools{ public static Item itemMinersPickaxe; public static Item itemSilkyMinersPickaxe; - public static void init(){ - itemMinersPickaxe = new ItemPickaxeFixedEnchants(Item.ToolMaterial.EMERALD, "itemMinersPickaxe", EnumRarity.rare, new EnchantmentCombo(Enchantment.fortune, 2), new EnchantmentCombo(Enchantment.efficiency, 2), new EnchantmentCombo(Enchantment.unbreaking, 1)); - ItemUtil.register(itemMinersPickaxe); + public static Item itemDiggersShovel; + public static Item itemFastDiggersShovel; - itemSilkyMinersPickaxe = new ItemPickaxeFixedEnchants(Item.ToolMaterial.EMERALD, "itemSilkyMinersPickaxe", EnumRarity.rare, new EnchantmentCombo(Enchantment.silkTouch, 1), new EnchantmentCombo(Enchantment.efficiency, 2), new EnchantmentCombo(Enchantment.unbreaking, 1)); + public static void init(){ + itemMinersPickaxe = new ItemPickaxeFixedEnchants(Item.ToolMaterial.EMERALD, "itemMinersPickaxe", EnumRarity.rare, new ItemStack(Items.diamond), 400, new EnchantmentCombo(Enchantment.fortune, 2), new EnchantmentCombo(Enchantment.efficiency, 2), new EnchantmentCombo(Enchantment.unbreaking, 1)); + ItemUtil.register(itemMinersPickaxe); + itemSilkyMinersPickaxe = new ItemPickaxeFixedEnchants(Item.ToolMaterial.EMERALD, "itemSilkyMinersPickaxe", EnumRarity.epic, new ItemStack(Items.diamond), 400, new EnchantmentCombo(Enchantment.silkTouch, 1), new EnchantmentCombo(Enchantment.efficiency, 2), new EnchantmentCombo(Enchantment.unbreaking, 1)); ItemUtil.register(itemSilkyMinersPickaxe); + + itemDiggersShovel = new ItemShovelFixedEnchants(Item.ToolMaterial.EMERALD, "itemDiggersShovel", EnumRarity.rare, new ItemStack(Items.diamond), 400, new EnchantmentCombo(Enchantment.efficiency, 2), new EnchantmentCombo(Enchantment.unbreaking, 2)); + ItemUtil.register(itemDiggersShovel); + itemFastDiggersShovel = new ItemShovelFixedEnchants(Item.ToolMaterial.EMERALD, "itemFastDiggersShovel", EnumRarity.epic, new ItemStack(Items.diamond), 400, new EnchantmentCombo(Enchantment.efficiency, 4), new EnchantmentCombo(Enchantment.unbreaking, 1)); + ItemUtil.register(itemFastDiggersShovel); } } diff --git a/src/main/java/ellpeck/actuallyadditions/items/tools/table/ItemAxeFixedEnchants.java b/src/main/java/ellpeck/actuallyadditions/items/tools/table/ItemAxeFixedEnchants.java index 730aecc9c..a167629b4 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/tools/table/ItemAxeFixedEnchants.java +++ b/src/main/java/ellpeck/actuallyadditions/items/tools/table/ItemAxeFixedEnchants.java @@ -13,33 +13,47 @@ package ellpeck.actuallyadditions.items.tools.table; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.items.tools.ItemAxeAA; +import ellpeck.actuallyadditions.util.ItemUtil; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.StringUtil; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.enchantment.Enchantment; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; import net.minecraft.world.World; import java.util.List; -public class ItemAxeFixedEnchants extends ItemAxeAA{ +public class ItemAxeFixedEnchants extends ItemAxeAA implements IToolTableRepairItem{ - public static class EnchantmentCombo{ - public Enchantment enchantment; - public int level; + private final int maxToolDamage; + private final EnchantmentCombo[] enchantments; - public EnchantmentCombo(Enchantment ench, int level){ - this.enchantment = ench; - this.level = level; - } - } + private ItemStack repairStack; + private int repairPerStack; - private EnchantmentCombo[] enchantments; + private IIcon iconBroken; - public ItemAxeFixedEnchants(ToolMaterial toolMat, String unlocalizedName, EnumRarity rarity, EnchantmentCombo... enchantments){ + public ItemAxeFixedEnchants(ToolMaterial toolMat, String unlocalizedName, EnumRarity rarity, ItemStack repairStack, int repairPerStack, EnchantmentCombo... enchantments){ super(toolMat, "", unlocalizedName, rarity); this.enchantments = enchantments; + this.maxToolDamage = this.getMaxDamage(); + this.setMaxDamage(this.maxToolDamage+1); + this.repairStack = repairStack; + this.repairPerStack = repairPerStack; + } + + public boolean isBroken(ItemStack stack){ + return this.isBroken(stack.getItemDamage()); + } + + private boolean isBroken(int damage){ + return damage > this.maxToolDamage; } @Override @@ -69,6 +83,15 @@ public class ItemAxeFixedEnchants extends ItemAxeAA{ } } + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5){ + for(EnchantmentCombo combo : this.enchantments){ + if(!ItemUtil.hasEnchantment(stack, combo.enchantment)){ + stack.addEnchantment(combo.enchantment, combo.level); + } + } + } + @SuppressWarnings("unchecked") @Override @SideOnly(Side.CLIENT) @@ -79,4 +102,47 @@ public class ItemAxeFixedEnchants extends ItemAxeAA{ } list.add(stack); } + + @Override + public String getItemStackDisplayName(ItemStack stack){ + return super.getItemStackDisplayName(stack)+(this.isBroken(stack) ? " ("+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".broken.desc")+")" : ""); + } + + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta){ + return this.isBroken(stack) ? 0.0F : super.getDigSpeed(stack, block, meta); + } + + @Override + public boolean canHarvestBlock(Block block, ItemStack stack){ + return !this.isBroken(stack) && super.canHarvestBlock(block, stack); + } + + @Override + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack useItem, int useRemaining){ + return this.isBroken(stack) ? this.iconBroken : this.itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int damage){ + return this.isBroken(damage) ? this.iconBroken : this.itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconReg){ + this.iconBroken = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()+"Broken"); + this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()); + } + + @Override + public ItemStack getRepairStack(){ + return this.repairStack; + } + + @Override + public int repairPerStack(){ + return this.repairPerStack; + } } diff --git a/src/main/java/ellpeck/actuallyadditions/items/tools/table/ItemPickaxeFixedEnchants.java b/src/main/java/ellpeck/actuallyadditions/items/tools/table/ItemPickaxeFixedEnchants.java index 68a2625e1..ae6c476e8 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/tools/table/ItemPickaxeFixedEnchants.java +++ b/src/main/java/ellpeck/actuallyadditions/items/tools/table/ItemPickaxeFixedEnchants.java @@ -13,33 +13,47 @@ package ellpeck.actuallyadditions.items.tools.table; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.items.tools.ItemPickaxeAA; +import ellpeck.actuallyadditions.util.ItemUtil; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.StringUtil; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.enchantment.Enchantment; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; import net.minecraft.world.World; import java.util.List; -public class ItemPickaxeFixedEnchants extends ItemPickaxeAA{ +public class ItemPickaxeFixedEnchants extends ItemPickaxeAA implements IToolTableRepairItem{ - public static class EnchantmentCombo{ - public Enchantment enchantment; - public int level; + private final int maxToolDamage; + private final EnchantmentCombo[] enchantments; - public EnchantmentCombo(Enchantment ench, int level){ - this.enchantment = ench; - this.level = level; - } - } + private ItemStack repairStack; + private int repairPerStack; - private EnchantmentCombo[] enchantments; + private IIcon iconBroken; - public ItemPickaxeFixedEnchants(ToolMaterial toolMat, String unlocalizedName, EnumRarity rarity, EnchantmentCombo... enchantments){ + public ItemPickaxeFixedEnchants(ToolMaterial toolMat, String unlocalizedName, EnumRarity rarity, ItemStack repairStack, int repairPerStack, EnchantmentCombo... enchantments){ super(toolMat, "", unlocalizedName, rarity); this.enchantments = enchantments; + this.maxToolDamage = this.getMaxDamage(); + this.setMaxDamage(this.maxToolDamage+1); + this.repairStack = repairStack; + this.repairPerStack = repairPerStack; + } + + public boolean isBroken(ItemStack stack){ + return this.isBroken(stack.getItemDamage()); + } + + private boolean isBroken(int damage){ + return damage > this.maxToolDamage; } @Override @@ -69,6 +83,15 @@ public class ItemPickaxeFixedEnchants extends ItemPickaxeAA{ } } + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5){ + for(EnchantmentCombo combo : this.enchantments){ + if(!ItemUtil.hasEnchantment(stack, combo.enchantment)){ + stack.addEnchantment(combo.enchantment, combo.level); + } + } + } + @SuppressWarnings("unchecked") @Override @SideOnly(Side.CLIENT) @@ -79,4 +102,47 @@ public class ItemPickaxeFixedEnchants extends ItemPickaxeAA{ } list.add(stack); } + + @Override + public String getItemStackDisplayName(ItemStack stack){ + return super.getItemStackDisplayName(stack)+(this.isBroken(stack) ? " ("+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".broken.desc")+")" : ""); + } + + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta){ + return this.isBroken(stack) ? 0.0F : super.getDigSpeed(stack, block, meta); + } + + @Override + public boolean canHarvestBlock(Block block, ItemStack stack){ + return !this.isBroken(stack) && super.canHarvestBlock(block, stack); + } + + @Override + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack useItem, int useRemaining){ + return this.isBroken(stack) ? this.iconBroken : this.itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int damage){ + return this.isBroken(damage) ? this.iconBroken : this.itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconReg){ + this.iconBroken = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()+"Broken"); + this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()); + } + + @Override + public ItemStack getRepairStack(){ + return this.repairStack; + } + + @Override + public int repairPerStack(){ + return this.repairPerStack; + } } diff --git a/src/main/java/ellpeck/actuallyadditions/items/tools/table/ItemShovelFixedEnchants.java b/src/main/java/ellpeck/actuallyadditions/items/tools/table/ItemShovelFixedEnchants.java index e81f66945..afb4187ac 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/tools/table/ItemShovelFixedEnchants.java +++ b/src/main/java/ellpeck/actuallyadditions/items/tools/table/ItemShovelFixedEnchants.java @@ -13,33 +13,47 @@ package ellpeck.actuallyadditions.items.tools.table; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.items.tools.ItemShovelAA; +import ellpeck.actuallyadditions.util.ItemUtil; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.StringUtil; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.enchantment.Enchantment; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; import net.minecraft.world.World; import java.util.List; -public class ItemShovelFixedEnchants extends ItemShovelAA{ +public class ItemShovelFixedEnchants extends ItemShovelAA implements IToolTableRepairItem{ - public static class EnchantmentCombo{ - public Enchantment enchantment; - public int level; + private final int maxToolDamage; + private final EnchantmentCombo[] enchantments; - public EnchantmentCombo(Enchantment ench, int level){ - this.enchantment = ench; - this.level = level; - } - } + private ItemStack repairStack; + private int repairPerStack; - private EnchantmentCombo[] enchantments; + private IIcon iconBroken; - public ItemShovelFixedEnchants(ToolMaterial toolMat, String unlocalizedName, EnumRarity rarity, EnchantmentCombo... enchantments){ + public ItemShovelFixedEnchants(ToolMaterial toolMat, String unlocalizedName, EnumRarity rarity, ItemStack repairStack, int repairPerStack, EnchantmentCombo... enchantments){ super(toolMat, "", unlocalizedName, rarity); this.enchantments = enchantments; + this.maxToolDamage = this.getMaxDamage(); + this.setMaxDamage(this.maxToolDamage+1); + this.repairStack = repairStack; + this.repairPerStack = repairPerStack; + } + + public boolean isBroken(ItemStack stack){ + return this.isBroken(stack.getItemDamage()); + } + + private boolean isBroken(int damage){ + return damage > this.maxToolDamage; } @Override @@ -69,6 +83,15 @@ public class ItemShovelFixedEnchants extends ItemShovelAA{ } } + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5){ + for(EnchantmentCombo combo : this.enchantments){ + if(!ItemUtil.hasEnchantment(stack, combo.enchantment)){ + stack.addEnchantment(combo.enchantment, combo.level); + } + } + } + @SuppressWarnings("unchecked") @Override @SideOnly(Side.CLIENT) @@ -79,4 +102,47 @@ public class ItemShovelFixedEnchants extends ItemShovelAA{ } list.add(stack); } + + @Override + public String getItemStackDisplayName(ItemStack stack){ + return super.getItemStackDisplayName(stack)+(this.isBroken(stack) ? " ("+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".broken.desc")+")" : ""); + } + + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta){ + return this.isBroken(stack) ? 0.0F : super.getDigSpeed(stack, block, meta); + } + + @Override + public boolean canHarvestBlock(Block block, ItemStack stack){ + return !this.isBroken(stack) && super.canHarvestBlock(block, stack); + } + + @Override + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack useItem, int useRemaining){ + return this.isBroken(stack) ? this.iconBroken : this.itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int damage){ + return this.isBroken(damage) ? this.iconBroken : this.itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconReg){ + this.iconBroken = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()+"Broken"); + this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()); + } + + @Override + public ItemStack getRepairStack(){ + return this.repairStack; + } + + @Override + public int repairPerStack(){ + return this.repairPerStack; + } } diff --git a/src/main/java/ellpeck/actuallyadditions/items/tools/table/ItemSwordFixedEnchants.java b/src/main/java/ellpeck/actuallyadditions/items/tools/table/ItemSwordFixedEnchants.java index 1ce51a1fb..434757c3a 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/tools/table/ItemSwordFixedEnchants.java +++ b/src/main/java/ellpeck/actuallyadditions/items/tools/table/ItemSwordFixedEnchants.java @@ -13,33 +13,47 @@ package ellpeck.actuallyadditions.items.tools.table; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.items.tools.ItemSwordAA; +import ellpeck.actuallyadditions.util.ItemUtil; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.StringUtil; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.enchantment.Enchantment; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; import net.minecraft.world.World; import java.util.List; -public class ItemSwordFixedEnchants extends ItemSwordAA{ +public class ItemSwordFixedEnchants extends ItemSwordAA implements IToolTableRepairItem{ - public static class EnchantmentCombo{ - public Enchantment enchantment; - public int level; + private final int maxToolDamage; + private final EnchantmentCombo[] enchantments; - public EnchantmentCombo(Enchantment ench, int level){ - this.enchantment = ench; - this.level = level; - } - } + private ItemStack repairStack; + private int repairPerStack; - private EnchantmentCombo[] enchantments; + private IIcon iconBroken; - public ItemSwordFixedEnchants(ToolMaterial toolMat, String unlocalizedName, EnumRarity rarity, EnchantmentCombo... enchantments){ + public ItemSwordFixedEnchants(ToolMaterial toolMat, String unlocalizedName, EnumRarity rarity, ItemStack repairStack, int repairPerStack, EnchantmentCombo... enchantments){ super(toolMat, "", unlocalizedName, rarity); this.enchantments = enchantments; + this.maxToolDamage = this.getMaxDamage(); + this.setMaxDamage(this.maxToolDamage+1); + this.repairStack = repairStack; + this.repairPerStack = repairPerStack; + } + + public boolean isBroken(ItemStack stack){ + return this.isBroken(stack.getItemDamage()); + } + + private boolean isBroken(int damage){ + return damage > this.maxToolDamage; } @Override @@ -69,6 +83,15 @@ public class ItemSwordFixedEnchants extends ItemSwordAA{ } } + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5){ + for(EnchantmentCombo combo : this.enchantments){ + if(!ItemUtil.hasEnchantment(stack, combo.enchantment)){ + stack.addEnchantment(combo.enchantment, combo.level); + } + } + } + @SuppressWarnings("unchecked") @Override @SideOnly(Side.CLIENT) @@ -79,4 +102,47 @@ public class ItemSwordFixedEnchants extends ItemSwordAA{ } list.add(stack); } + + @Override + public String getItemStackDisplayName(ItemStack stack){ + return super.getItemStackDisplayName(stack)+(this.isBroken(stack) ? " ("+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".broken.desc")+")" : ""); + } + + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta){ + return this.isBroken(stack) ? 0.0F : super.getDigSpeed(stack, block, meta); + } + + @Override + public boolean canHarvestBlock(Block block, ItemStack stack){ + return !this.isBroken(stack) && super.canHarvestBlock(block, stack); + } + + @Override + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack useItem, int useRemaining){ + return this.isBroken(stack) ? this.iconBroken : this.itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int damage){ + return this.isBroken(damage) ? this.iconBroken : this.itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconReg){ + this.iconBroken = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()+"Broken"); + this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()); + } + + @Override + public ItemStack getRepairStack(){ + return this.repairStack; + } + + @Override + public int repairPerStack(){ + return this.repairPerStack; + } } diff --git a/src/main/java/ellpeck/actuallyadditions/recipe/ToolTableHandler.java b/src/main/java/ellpeck/actuallyadditions/recipe/ToolTableHandler.java index 05c604ba2..c6cd2eb9e 100644 --- a/src/main/java/ellpeck/actuallyadditions/recipe/ToolTableHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/recipe/ToolTableHandler.java @@ -10,6 +10,7 @@ package ellpeck.actuallyadditions.recipe; +import ellpeck.actuallyadditions.items.tools.table.IToolTableRepairItem; import ellpeck.actuallyadditions.util.ItemUtil; import net.minecraft.item.ItemStack; @@ -29,11 +30,23 @@ public class ToolTableHandler{ } public static Recipe getRecipeFromSlots(ItemStack[] slots){ + //Normal Recipes for(Recipe recipe : recipes){ if(ItemUtil.containsAll(slots, recipe.itemsNeeded)){ return recipe; } } + + //Repair Recipes + for(ItemStack slot : slots){ + if(slot != null && slot.getItem() instanceof IToolTableRepairItem){ + if(ItemUtil.contains(slots, ((IToolTableRepairItem)slot.getItem()).getRepairStack()) && slot.getItemDamage() > 0){ + ItemStack returnStack = slot.copy(); + returnStack.setItemDamage(Math.max(0, returnStack.getItemDamage()-((IToolTableRepairItem)returnStack.getItem()).repairPerStack())); + return new Recipe(returnStack, slot, ((IToolTableRepairItem)returnStack.getItem()).getRepairStack()); + } + } + } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/util/ItemUtil.java b/src/main/java/ellpeck/actuallyadditions/util/ItemUtil.java index 665388084..de07220c3 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/ItemUtil.java +++ b/src/main/java/ellpeck/actuallyadditions/util/ItemUtil.java @@ -92,4 +92,17 @@ public class ItemUtil{ } } } + + public static boolean hasEnchantment(ItemStack stack, Enchantment e){ + NBTTagList ench = stack.getEnchantmentTagList(); + if(ench != null){ + for(int i = 0; i < ench.tagCount(); i++){ + short id = ench.getCompoundTagAt(i).getShort("id"); + if(id == e.effectId){ + return true; + } + } + } + return false; + } } diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index fa0c4283b..c5c2dcc43 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -276,6 +276,7 @@ tooltip.actuallyadditions.disablingInfo.desc=If you don't want this Information tooltip.actuallyadditions.ctrlForMoreInfo.desc=Press CTRL for Advanced Info tooltip.actuallyadditions.extraInfo.desc=Advanced Info tooltip.actuallyadditions.blockPhantomRange.desc=Range +tooltip.actuallyadditions.broken.desc=Broken #Gui Information info.actuallyadditions.gui.animals=Animals