Started on actual diggers' tools, added repairing

This commit is contained in:
Ellpeck 2015-09-24 20:53:07 +02:00
parent 835e8734ab
commit 8c60f4110b
10 changed files with 396 additions and 53 deletions

View file

@ -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;
}
}

View file

@ -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();
}

View file

@ -10,22 +10,30 @@
package ellpeck.actuallyadditions.items.tools.table; package ellpeck.actuallyadditions.items.tools.table;
import ellpeck.actuallyadditions.items.tools.table.ItemPickaxeFixedEnchants.EnchantmentCombo;
import ellpeck.actuallyadditions.util.ItemUtil; import ellpeck.actuallyadditions.util.ItemUtil;
import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.Enchantment;
import net.minecraft.init.Items;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class InitToolTableTools{ public class InitToolTableTools{
public static Item itemMinersPickaxe; public static Item itemMinersPickaxe;
public static Item itemSilkyMinersPickaxe; public static Item itemSilkyMinersPickaxe;
public static void init(){ public static Item itemDiggersShovel;
itemMinersPickaxe = new ItemPickaxeFixedEnchants(Item.ToolMaterial.EMERALD, "itemMinersPickaxe", EnumRarity.rare, new EnchantmentCombo(Enchantment.fortune, 2), new EnchantmentCombo(Enchantment.efficiency, 2), new EnchantmentCombo(Enchantment.unbreaking, 1)); public static Item itemFastDiggersShovel;
ItemUtil.register(itemMinersPickaxe);
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); 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);
} }
} }

View file

@ -13,33 +13,47 @@ package ellpeck.actuallyadditions.items.tools.table;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.items.tools.ItemAxeAA; 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.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.List; import java.util.List;
public class ItemAxeFixedEnchants extends ItemAxeAA{ public class ItemAxeFixedEnchants extends ItemAxeAA implements IToolTableRepairItem{
public static class EnchantmentCombo{ private final int maxToolDamage;
public Enchantment enchantment; private final EnchantmentCombo[] enchantments;
public int level;
public EnchantmentCombo(Enchantment ench, int level){ private ItemStack repairStack;
this.enchantment = ench; private int repairPerStack;
this.level = level;
}
}
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); super(toolMat, "", unlocalizedName, rarity);
this.enchantments = enchantments; 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 @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") @SuppressWarnings("unchecked")
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@ -79,4 +102,47 @@ public class ItemAxeFixedEnchants extends ItemAxeAA{
} }
list.add(stack); 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;
}
} }

View file

@ -13,33 +13,47 @@ package ellpeck.actuallyadditions.items.tools.table;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.items.tools.ItemPickaxeAA; 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.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.List; import java.util.List;
public class ItemPickaxeFixedEnchants extends ItemPickaxeAA{ public class ItemPickaxeFixedEnchants extends ItemPickaxeAA implements IToolTableRepairItem{
public static class EnchantmentCombo{ private final int maxToolDamage;
public Enchantment enchantment; private final EnchantmentCombo[] enchantments;
public int level;
public EnchantmentCombo(Enchantment ench, int level){ private ItemStack repairStack;
this.enchantment = ench; private int repairPerStack;
this.level = level;
}
}
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); super(toolMat, "", unlocalizedName, rarity);
this.enchantments = enchantments; 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 @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") @SuppressWarnings("unchecked")
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@ -79,4 +102,47 @@ public class ItemPickaxeFixedEnchants extends ItemPickaxeAA{
} }
list.add(stack); 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;
}
} }

View file

@ -13,33 +13,47 @@ package ellpeck.actuallyadditions.items.tools.table;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.items.tools.ItemShovelAA; 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.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.List; import java.util.List;
public class ItemShovelFixedEnchants extends ItemShovelAA{ public class ItemShovelFixedEnchants extends ItemShovelAA implements IToolTableRepairItem{
public static class EnchantmentCombo{ private final int maxToolDamage;
public Enchantment enchantment; private final EnchantmentCombo[] enchantments;
public int level;
public EnchantmentCombo(Enchantment ench, int level){ private ItemStack repairStack;
this.enchantment = ench; private int repairPerStack;
this.level = level;
}
}
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); super(toolMat, "", unlocalizedName, rarity);
this.enchantments = enchantments; 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 @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") @SuppressWarnings("unchecked")
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@ -79,4 +102,47 @@ public class ItemShovelFixedEnchants extends ItemShovelAA{
} }
list.add(stack); 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;
}
} }

View file

@ -13,33 +13,47 @@ package ellpeck.actuallyadditions.items.tools.table;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.items.tools.ItemSwordAA; 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.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.List; import java.util.List;
public class ItemSwordFixedEnchants extends ItemSwordAA{ public class ItemSwordFixedEnchants extends ItemSwordAA implements IToolTableRepairItem{
public static class EnchantmentCombo{ private final int maxToolDamage;
public Enchantment enchantment; private final EnchantmentCombo[] enchantments;
public int level;
public EnchantmentCombo(Enchantment ench, int level){ private ItemStack repairStack;
this.enchantment = ench; private int repairPerStack;
this.level = level;
}
}
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); super(toolMat, "", unlocalizedName, rarity);
this.enchantments = enchantments; 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 @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") @SuppressWarnings("unchecked")
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@ -79,4 +102,47 @@ public class ItemSwordFixedEnchants extends ItemSwordAA{
} }
list.add(stack); 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;
}
} }

View file

@ -10,6 +10,7 @@
package ellpeck.actuallyadditions.recipe; package ellpeck.actuallyadditions.recipe;
import ellpeck.actuallyadditions.items.tools.table.IToolTableRepairItem;
import ellpeck.actuallyadditions.util.ItemUtil; import ellpeck.actuallyadditions.util.ItemUtil;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -29,11 +30,23 @@ public class ToolTableHandler{
} }
public static Recipe getRecipeFromSlots(ItemStack[] slots){ public static Recipe getRecipeFromSlots(ItemStack[] slots){
//Normal Recipes
for(Recipe recipe : recipes){ for(Recipe recipe : recipes){
if(ItemUtil.containsAll(slots, recipe.itemsNeeded)){ if(ItemUtil.containsAll(slots, recipe.itemsNeeded)){
return recipe; 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; return null;
} }

View file

@ -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;
}
} }

View file

@ -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.ctrlForMoreInfo.desc=Press CTRL for Advanced Info
tooltip.actuallyadditions.extraInfo.desc=Advanced Info tooltip.actuallyadditions.extraInfo.desc=Advanced Info
tooltip.actuallyadditions.blockPhantomRange.desc=Range tooltip.actuallyadditions.blockPhantomRange.desc=Range
tooltip.actuallyadditions.broken.desc=Broken
#Gui Information #Gui Information
info.actuallyadditions.gui.animals=Animals info.actuallyadditions.gui.animals=Animals