Added repair capabilities to armor and tools

This commit is contained in:
Aidan C. Brady 2014-06-10 13:25:12 +02:00
parent 3992a6ae46
commit f3894f220c
4 changed files with 91 additions and 4 deletions

View file

@ -13,12 +13,11 @@ import mekanism.api.transmitters.DynamicNetwork;
import mekanism.api.transmitters.IGridTransmitter;
import mekanism.api.transmitters.ITransmitterNetwork;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.Mekanism;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.Event;
/**
* A DynamicNetwork extension created specifically for the transfer of Gasses. By default this is server-only, but if ticked on
@ -215,7 +214,6 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
if(FMLCommonHandler.instance().getEffectiveSide().isServer())
{
Mekanism.logger.info(gasStored);
prevTransferAmount = 0;
if(transferDelay == 0)

View file

@ -4,12 +4,14 @@ import java.util.List;
import mekanism.client.render.ModelCustomArmor;
import mekanism.common.Mekanism;
import mekanism.common.util.StackUtils;
import mekanism.tools.common.MekanismTools;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.relauncher.Side;
@ -40,6 +42,42 @@ public class ItemMekanismArmor extends ItemArmor
{
return "mekanism:armor/" + getArmorMaterial().name().toLowerCase() + "_" + type + ".png";
}
@Override
public boolean getIsRepairable(ItemStack stack1, ItemStack stack2)
{
return StackUtils.equalsWildcard(getRepairStack(), stack2) ? true : super.getIsRepairable(stack1, stack2);
}
private ItemStack getRepairStack()
{
if(getArmorMaterial() == MekanismTools.armorOBSIDIAN)
{
return new ItemStack(Mekanism.Ingot, 1, 0);
}
else if(getArmorMaterial() == MekanismTools.armorLAZULI)
{
return new ItemStack(Items.dye, 1, 4);
}
else if(getArmorMaterial() == MekanismTools.armorOSMIUM)
{
return new ItemStack(Mekanism.Ingot, 1, 1);
}
else if(getArmorMaterial() == MekanismTools.armorBRONZE)
{
return new ItemStack(Mekanism.Ingot, 1, 2);
}
else if(getArmorMaterial() == MekanismTools.armorGLOWSTONE)
{
return new ItemStack(Mekanism.Ingot, 1, 3);
}
else if(getArmorMaterial() == MekanismTools.armorSTEEL)
{
return new ItemStack(Mekanism.Ingot, 1, 4);
}
return new ItemStack(getArmorMaterial().func_151685_b());
}
@Override
@SideOnly(Side.CLIENT)

View file

@ -3,6 +3,7 @@ package mekanism.tools.item;
import java.util.List;
import mekanism.common.item.ItemMekanism;
import mekanism.common.util.StackUtils;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
@ -27,6 +28,12 @@ public class ItemMekanismHoe extends ItemMekanism
setMaxDamage(enumtoolmaterial.getMaxUses());
setCreativeTab(CreativeTabs.tabTools);
}
@Override
public boolean getIsRepairable(ItemStack stack1, ItemStack stack2)
{
return StackUtils.equalsWildcard(ItemMekanismTool.getRepairStack(toolMaterial), stack2) ? true : super.getIsRepairable(stack1, stack2);
}
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side, float entityX, float entityY, float entityZ)

View file

@ -5,9 +5,12 @@ import java.util.HashSet;
import java.util.List;
import mekanism.common.Mekanism;
import mekanism.common.util.StackUtils;
import mekanism.tools.common.MekanismTools;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;
@ -24,6 +27,47 @@ public class ItemMekanismTool extends ItemTool
{
list.add("HP: " + (itemstack.getMaxDamage() - itemstack.getItemDamage()));
}
@Override
public boolean getIsRepairable(ItemStack stack1, ItemStack stack2)
{
return StackUtils.equalsWildcard(getRepairStack(), stack2) ? true : super.getIsRepairable(stack1, stack2);
}
private ItemStack getRepairStack()
{
return getRepairStack(toolMaterial);
}
public static ItemStack getRepairStack(ToolMaterial material)
{
if(material == MekanismTools.toolOBSIDIAN || material == MekanismTools.toolOBSIDIAN2)
{
return new ItemStack(Mekanism.Ingot, 1, 0);
}
else if(material == MekanismTools.toolLAZULI || material == MekanismTools.toolLAZULI2)
{
return new ItemStack(Items.dye, 1, 4);
}
else if(material == MekanismTools.toolOSMIUM || material == MekanismTools.toolOSMIUM2)
{
return new ItemStack(Mekanism.Ingot, 1, 1);
}
else if(material == MekanismTools.toolBRONZE || material == MekanismTools.toolBRONZE2)
{
return new ItemStack(Mekanism.Ingot, 1, 2);
}
else if(material == MekanismTools.toolGLOWSTONE || material == MekanismTools.toolGLOWSTONE2)
{
return new ItemStack(Mekanism.Ingot, 1, 3);
}
else if(material == MekanismTools.toolSTEEL || material == MekanismTools.toolSTEEL2)
{
return new ItemStack(Mekanism.Ingot, 1, 4);
}
return new ItemStack(material.func_150995_f());
}
@Override
public void registerIcons(IIconRegister register)