diff --git a/resources/assets/tinker/textures/gui/newhearts.png b/resources/assets/tinker/textures/gui/newhearts.png index be6b93ae..aa6b187d 100644 Binary files a/resources/assets/tinker/textures/gui/newhearts.png and b/resources/assets/tinker/textures/gui/newhearts.png differ diff --git a/src/main/java/tconstruct/armor/ArmorProxyClient.java b/src/main/java/tconstruct/armor/ArmorProxyClient.java index 2461b505..c9288d71 100644 --- a/src/main/java/tconstruct/armor/ArmorProxyClient.java +++ b/src/main/java/tconstruct/armor/ArmorProxyClient.java @@ -308,6 +308,8 @@ public class ArmorProxyClient extends ArmorProxyCommon potion = mc.thePlayer.getActivePotionEffect(Potion.poison); if (potion != null) potionOffset = 9; + if (mc.theWorld.getWorldInfo().isHardcoreModeEnabled()) + potionOffset += 27; // Extra hearts this.mc.getTextureManager().bindTexture(hearts); diff --git a/src/main/java/tconstruct/library/tools/ToolCore.java b/src/main/java/tconstruct/library/tools/ToolCore.java index 03dbd84b..996d1106 100644 --- a/src/main/java/tconstruct/library/tools/ToolCore.java +++ b/src/main/java/tconstruct/library/tools/ToolCore.java @@ -788,8 +788,11 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IMo { int energy = tags.getInteger("Energy"); int max = getMaxEnergyStored(stack); - if(energy > 0) - return ((max - energy)*100)/max; + if(energy > 0) { + int damage = ((max - energy) * 100) / max; + super.setDamage(stack, damage); + return damage; + } } int dur = tags.getCompoundTag("InfiTool").getInteger("Damage"); int max = tags.getCompoundTag("InfiTool").getInteger("TotalDurability"); @@ -799,8 +802,11 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IMo // rounding. if(damage == 0 && dur > 0) - return 1; + damage = 1; + + // synchronize values with stack.. + super.setDamage(stack, damage); return damage; } @@ -813,6 +819,7 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IMo @Override public void setDamage(ItemStack stack, int damage) { AbilityHelper.damageTool(stack, damage - stack.getItemDamage(), null, false); + getDamage(stack); // called to synchronize with itemstack value } /* Prevent tools from dying */ diff --git a/src/main/java/tconstruct/plugins/nei/RecipeHandlerToolMaterials.java b/src/main/java/tconstruct/plugins/nei/RecipeHandlerToolMaterials.java index 51b6f0be..39166a32 100644 --- a/src/main/java/tconstruct/plugins/nei/RecipeHandlerToolMaterials.java +++ b/src/main/java/tconstruct/plugins/nei/RecipeHandlerToolMaterials.java @@ -176,7 +176,9 @@ public class RecipeHandlerToolMaterials extends RecipeHandlerBase } } } - this.arecipes.add(new CachedToolMaterialsRecipe(toolParts, matID)); + + if(toolParts.size() > 0) + this.arecipes.add(new CachedToolMaterialsRecipe(toolParts, matID)); } } else @@ -193,13 +195,17 @@ public class RecipeHandlerToolMaterials extends RecipeHandlerBase int materialID = ((IToolPart) ingred.getItem()).getMaterialID(ingred); if (materialID >= 0) { - this.arecipes.add(new CachedToolMaterialsRecipe(getSingleList(ingred), materialID)); + List toolParts = getSingleList(ingred); + if(toolParts.size() > 0) + this.arecipes.add(new CachedToolMaterialsRecipe(toolParts, materialID)); } } else if (PatternBuilder.instance.getPartID(ingred) < Short.MAX_VALUE) { int materialID = PatternBuilder.instance.getPartID(ingred); - this.arecipes.add(new CachedToolMaterialsRecipe(getSingleList(ingred), materialID)); + List toolParts = getSingleList(ingred); + if(toolParts.size() > 0) + this.arecipes.add(new CachedToolMaterialsRecipe(toolParts, materialID)); } else { diff --git a/src/main/java/tconstruct/smeltery/TinkerSmeltery.java b/src/main/java/tconstruct/smeltery/TinkerSmeltery.java index dad82c49..e6a74568 100644 --- a/src/main/java/tconstruct/smeltery/TinkerSmeltery.java +++ b/src/main/java/tconstruct/smeltery/TinkerSmeltery.java @@ -1077,11 +1077,11 @@ public class TinkerSmeltery protected static void addRecipesForSmeltery () { // Smeltery fuels - Smeltery.addSmelteryFuel(FluidRegistry.LAVA, 1300, 10); + Smeltery.addSmelteryFuel(FluidRegistry.LAVA, 1300, 12); // lava lasts 4 seconds per 15 mb // register pyrotheum if it's present Fluid pyrotheum = FluidRegistry.getFluid("pyrotheum"); if (pyrotheum != null) - Smeltery.addSmelteryFuel(pyrotheum, 5000, 9); + Smeltery.addSmelteryFuel(pyrotheum, 5000, 9); // pyrotheum lasts 3 seconds per 15 mb // BLOOD FOR THE BLOOD GOD if (TinkerWorld.meatBlock != null) diff --git a/src/main/java/tconstruct/smeltery/gui/SmelteryGui.java b/src/main/java/tconstruct/smeltery/gui/SmelteryGui.java index 2f7671e9..57f8c827 100644 --- a/src/main/java/tconstruct/smeltery/gui/SmelteryGui.java +++ b/src/main/java/tconstruct/smeltery/gui/SmelteryGui.java @@ -45,7 +45,7 @@ public class SmelteryGui extends ActiveContainerGui super.initGui(); if (logic != null) - logic.updateFuelGague(); + logic.updateFuelDisplay(); } @Override diff --git a/src/main/java/tconstruct/smeltery/logic/SmelteryLogic.java b/src/main/java/tconstruct/smeltery/logic/SmelteryLogic.java index c660b9a1..dbc987e4 100644 --- a/src/main/java/tconstruct/smeltery/logic/SmelteryLogic.java +++ b/src/main/java/tconstruct/smeltery/logic/SmelteryLogic.java @@ -292,15 +292,22 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci * if (worldObj.isRemote) return; */ + + if(validStructure) + if (tick % 4 == 0) { + checkHasItems(); + heatItems(); + } + if (tick % 20 == 0) { if (!validStructure) checkValidPlacement(); - if (useTime > 0 && inUse) + if (useTime > 0) useTime -= 3; - if (validStructure && useTime <= 0) + if (validStructure && useTime <= 0 && inUse) { updateFuelGague(); } @@ -311,10 +318,6 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } } - - if(validStructure) - if (tick % 4 == 0) - heatItems(); } void detectEntities () @@ -438,6 +441,17 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci } } + private void checkHasItems() + { + inUse = false; + for (int i = 0; i < maxBlockCapacity; i++) + if(this.isStackInSlot(i) && meltingTemps[i] > 200) + { + inUse = true; + break; + } + } + private void heatItems () { if (useTime > 0) @@ -542,7 +556,6 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci private void updateTemperatures () { - inUse = true; for (int i = 0; i < maxBlockCapacity; i++) { meltingTemps[i] = Smeltery.getLiquifyTemperature(inventory[i]) * 10; // temperatures are *10 for more progress control @@ -551,138 +564,92 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci public void updateFuelDisplay () { - if (activeLavaTank == null) - return; - - if (!worldObj.blockExists(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z)) - { + // ensure our active tank is valid + verifyFuelTank(); + if (activeLavaTank == null) { fuelAmount = 0; fuelGague = 0; return; } - TileEntity tankContainer = worldObj.getTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z); - if (tankContainer == null) - { - fuelAmount = 0; - fuelGague = 0; - return; - } - - if (tankContainer instanceof IFluidHandler) - { - FluidStack liquid = ((IFluidHandler) tankContainer).drain(ForgeDirection.DOWN, 4000, false); - if (liquid != null && Smeltery.isSmelteryFuel(liquid.getFluid())) - { - FluidTankInfo[] info = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN); - if (info.length > 0) - { - int capacity = info[0].capacity; - fuelAmount = liquid.amount; - fuelGague = liquid.amount * 52 / capacity; - } - } - else - { - fuelAmount = 0; - fuelGague = 0; - } - } + // checks are all done before in verifyFuelTank. Don't do this without checks! + IFluidHandler tankContainer = (IFluidHandler) worldObj.getTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z); + FluidTankInfo[] info = tankContainer.getTankInfo(ForgeDirection.DOWN); + int capacity = info[0].capacity; + fuelAmount = info[0].fluid.amount; + fuelGague = (int)((float)fuelAmount * 52f / (float)capacity); } + // actually is updateFuel. public void updateFuelGague () { - if(activeLavaTank == null && lavaTanks.size() > 0) - activeLavaTank = lavaTanks.get(0); - if (activeLavaTank == null || useTime > 0) + // no need to update + if(useTime > 0 || !inUse) return; - if (!worldObj.blockExists(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z)) + // ensure active lava tank + verifyFuelTank(); + + // checks are all done before in verifyFuelTank. Don't do this without checks! + IFluidHandler tankContainer = (IFluidHandler) worldObj.getTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z); + + // get liquid from the tank + FluidStack liquid = tankContainer.drain(ForgeDirection.DOWN, 15, false); + if (liquid != null && Smeltery.isSmelteryFuel(liquid.getFluid())) // doublecheck that everything is ok { - fuelAmount = 0; - fuelGague = 0; - return; + // drain actual liquid, non simulated + liquid = tankContainer.drain(ForgeDirection.DOWN, 15, true); + useTime += (int)((float)Smeltery.getFuelDuration(liquid.getFluid())*15f/(float)liquid.amount); + internalTemp = Smeltery.getFuelPower(liquid.getFluid()); + + // update fuel display + updateFuelDisplay(); // this also ensures that the next fuel tank is displayed if this drain made the current one empty + } + } + + protected void verifyFuelTank() + { + // is our current tank still good? + if(activeLavaTank != null && worldObj.blockExists(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z)) + { + TileEntity tankContainer = worldObj.getTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z); + if (tankContainer instanceof IFluidHandler) + { + FluidStack liquid = ((IFluidHandler) tankContainer).drain(ForgeDirection.DOWN, 15, false); + // current tank still has liquid and it's a fuel. everythin ok. + if (liquid != null && Smeltery.isSmelteryFuel(liquid.getFluid())) + return; + } } - TileEntity tankContainer = worldObj.getTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z); - if (tankContainer == null) + + // our tank got derped or is empty. time to look for a new one! + activeLavaTank = null; + for(CoordTuple tank : lavaTanks) { - fuelAmount = 0; - fuelGague = 0; + // does the tank still exist? + if (!worldObj.blockExists(tank.x, tank.y, tank.z)) + continue; + + // yes, it does, but is it a tank? + TileEntity tankContainer = worldObj.getTileEntity(tank.x, tank.y, tank.z); + if (! (tankContainer instanceof IFluidHandler)) + continue; + + // yes it is, but does it contain a liquid? + FluidTankInfo[] info = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN); + if(info.length <= 0 || info[0].fluid == null || info[0].fluid.amount <= 0) + continue; + + // is it also a smeltery fuel? + if(!Smeltery.isSmelteryFuel(info[0].fluid.getFluid())) + continue; + + // we found a tank! :) + activeLavaTank = tank; return; } - if (tankContainer instanceof IFluidHandler) - { - needsUpdate = true; - FluidStack liquid = ((IFluidHandler) tankContainer).drain(ForgeDirection.DOWN, 15, false); - if (liquid != null && Smeltery.isSmelteryFuel(liquid.getFluid())) - { - liquid = ((IFluidHandler) tankContainer).drain(ForgeDirection.DOWN, 15, true); - useTime += Smeltery.getFuelDuration(liquid.getFluid()); - internalTemp = Smeltery.getFuelPower(liquid.getFluid()); - - FluidTankInfo[] info = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN); - liquid = info[0].fluid; - int capacity = info[0].capacity; - if (liquid != null) - { - fuelAmount = liquid.amount; - fuelGague = liquid.amount * 52 / capacity; - } - else - { - fuelAmount = 0; - fuelGague = 0; - } - } - else - { - boolean foundTank = false; - int iter = 0; - while (!foundTank && iter < lavaTanks.size()) - { - CoordTuple possibleTank = lavaTanks.get(iter); - TileEntity newTankContainer = worldObj.getTileEntity(possibleTank.x, possibleTank.y, possibleTank.z); - if (newTankContainer instanceof IFluidHandler) - { - // TConstruct.logger.info("Tank: "+possibleTank.toString()); - FluidStack newliquid = ((IFluidHandler) newTankContainer).drain(ForgeDirection.UNKNOWN, 150, false); - if (newliquid != null && Smeltery.isSmelteryFuel(newliquid.getFluid()) && newliquid.amount > 0) - { - // TConstruct.logger.info("Tank: "+possibleTank.toString()); - foundTank = true; - activeLavaTank = possibleTank; - iter = lavaTanks.size(); - - /* - * IFluidTank newTank = ((IFluidHandler) - * newTankContainer).getTank(ForgeDirection.UNKNOWN, - * liquid); liquid = newTank.getFluid(); int - * capacity = newTank.getCapacity(); - */ - FluidTankInfo[] info = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN); - liquid = info[0].fluid; - int capacity = info[0].capacity; - if (liquid != null) - { - fuelAmount = liquid.amount; - fuelGague = liquid.amount * 52 / capacity; - } - else - { - fuelAmount = 0; - fuelGague = 0; - } - } - } - iter++; - if (iter >= lavaTanks.size()) - foundTank = true; - } - // TConstruct.logger.info("Searching for tank, size: "+lavaTanks.size()); - } - } } @SideOnly(Side.CLIENT) diff --git a/src/main/java/tconstruct/tools/TinkerToolEvents.java b/src/main/java/tconstruct/tools/TinkerToolEvents.java index f7c7ca60..de760763 100644 --- a/src/main/java/tconstruct/tools/TinkerToolEvents.java +++ b/src/main/java/tconstruct/tools/TinkerToolEvents.java @@ -5,6 +5,7 @@ import cpw.mods.fml.common.eventhandler.*; import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; import java.util.List; import net.minecraft.entity.*; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.monster.*; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; @@ -13,6 +14,7 @@ import net.minecraft.item.*; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.*; import net.minecraftforge.event.entity.living.*; +import net.minecraftforge.event.entity.player.PlayerDropsEvent; import net.minecraftforge.oredict.*; import net.minecraftforge.oredict.OreDictionary.OreRegisterEvent; import tconstruct.TConstruct; @@ -381,4 +383,26 @@ public class TinkerToolEvents TinkerTools.modAttack.addStackToMatchList(evt.Ore, 24); } } + + + @SubscribeEvent + public void damageToolsOnDeath (PlayerDropsEvent event) + { + if(!PHConstruct.deathPenality) + return; + + for(EntityItem drop : event.drops) + { + // we're only interested in tools + if(!(drop.getEntityItem().getItem() instanceof ToolCore) || !drop.getEntityItem().hasTagCompound()) + continue; + + // damage tools by 10% of their total durability! + NBTTagCompound tags = drop.getEntityItem().getTagCompound().getCompoundTag("InfiTool"); + int dur = tags.getInteger("TotalDurability"); + dur /= 10; + + AbilityHelper.damageTool(drop.getEntityItem(), dur, event.entityPlayer, true); + } + } } diff --git a/src/main/java/tconstruct/tools/TinkerTools.java b/src/main/java/tconstruct/tools/TinkerTools.java index 0bf2cd92..cbbc3a96 100644 --- a/src/main/java/tconstruct/tools/TinkerTools.java +++ b/src/main/java/tconstruct/tools/TinkerTools.java @@ -729,7 +729,7 @@ public class TinkerTools TConstructRegistry.addToolMaterial(MaterialID.Manyullyn, "Manyullyn", 5, 1200, 900, 4, 2.5F, 0, 0f, DARK_PURPLE.toString(), 0x7338A5); TConstructRegistry.addToolMaterial(MaterialID.Copper, "Copper", 1, 180, 500, 2, 1.15F, 0, 0f, RED.toString(), 0xCC6410); TConstructRegistry.addToolMaterial(MaterialID.Bronze, "Bronze", 2, 550, 800, 2, 1.3F, 1, 0f, GOLD.toString(), 0xCA9956); - TConstructRegistry.addToolMaterial(MaterialID.Alumite, "Alumite", 4, 700, 800, 3, 1.3F, 2, 0f, LIGHT_PURPLE.toString(), 0xffddff); + TConstructRegistry.addToolMaterial(MaterialID.Alumite, "Alumite", 4, 700, 800, 3, 1.3F, 2, 0f, LIGHT_PURPLE.toString(), 0xffa7e9); TConstructRegistry.addToolMaterial(MaterialID.Steel, "Steel", 4, 750, 1000, 4, 1.3F, 2, 0f, GRAY.toString(), 0xA0A0A0); TConstructRegistry.addToolMaterial(MaterialID.BlueSlime, "BlueSlime", 0, 1200, 150, 0, 2.0F, 0, 0f, AQUA.toString(), 0x66AEB0); TConstructRegistry.addToolMaterial(MaterialID.PigIron, "PigIron", 3, 250, 600, 2, 1.3F, 1, 0f, RED.toString(), 0xF0A8A4); @@ -772,7 +772,7 @@ public class TinkerTools if (PHConstruct.enableTPaper) pb.registerFullMaterial(new ItemStack(materials, 1, 0), 2, "Paper", new ItemStack(Items.paper, 2), new ItemStack(toolRod, 1, 9), 9); else - pb.registerMaterialSet("BlueSlime", new ItemStack(Items.paper, 2), new ItemStack(TinkerTools.toolRod, 1, 9), 9); + pb.registerMaterialSet("Paper", new ItemStack(Items.paper, 2), new ItemStack(TinkerTools.toolRod, 1, 9), 9); pb.registerMaterialSet("Cobalt", new ItemStack(toolShard, 1, 10), new ItemStack(toolRod, 1, 10), 10); pb.registerMaterialSet("Ardite", new ItemStack(toolShard, 1, 11), new ItemStack(toolRod, 1, 11), 11); pb.registerMaterialSet("Manyullyn", new ItemStack(toolShard, 1, 12), new ItemStack(toolRod, 1, 12), 12); diff --git a/src/main/java/tconstruct/tools/model/TableRender.java b/src/main/java/tconstruct/tools/model/TableRender.java index d35c592c..c8b38fb7 100644 --- a/src/main/java/tconstruct/tools/model/TableRender.java +++ b/src/main/java/tconstruct/tools/model/TableRender.java @@ -5,6 +5,7 @@ import net.minecraft.block.Block; import net.minecraft.client.renderer.*; import net.minecraft.world.IBlockAccess; import org.lwjgl.opengl.GL11; +import tconstruct.tools.TinkerTools; public class TableRender implements ISimpleBlockRenderingHandler { @@ -16,7 +17,7 @@ public class TableRender implements ISimpleBlockRenderingHandler if (modelID == model) { // until we get the new model.. finally... - if(metadata >= 5 && metadata <= 9) { + if(block == TinkerTools.toolStationWood && metadata >= 5 && metadata <= 9) { // pattern chest renderer.setRenderBounds(0,0,0,1,0.875,1); renderStandardInvBlock(renderer, block, metadata); @@ -43,7 +44,7 @@ public class TableRender implements ISimpleBlockRenderingHandler { int metadata = world.getBlockMetadata(x,y,z); // until we get the new model.. finally... - if(metadata >= 5 && metadata <= 9) { + if(block == TinkerTools.toolStationWood && metadata >= 5 && metadata <= 9) { // pattern chest renderer.setRenderBounds(0,0,0,1,0.875,1); renderer.renderStandardBlock(block, x,y,z); diff --git a/src/main/java/tconstruct/util/config/PHConstruct.java b/src/main/java/tconstruct/util/config/PHConstruct.java index 826fe100..315d72b9 100644 --- a/src/main/java/tconstruct/util/config/PHConstruct.java +++ b/src/main/java/tconstruct/util/config/PHConstruct.java @@ -43,6 +43,7 @@ public class PHConstruct keepHunger = config.get("Difficulty Changes", "Keep hunger on death", true).getBoolean(true); keepLevels = config.get("Difficulty Changes", "Keep levels on death", true).getBoolean(true); beginnerBook = config.get("Difficulty Changes", "Spawn beginner book", true).getBoolean(true); + deathPenality = config.get("Difficulty Changes", "Tools lose 10% durability on death", true).getBoolean(true); enableTWood = config.get("Difficulty Changes", "Enable mod wooden tools", true).getBoolean(true); enableTStone = config.get("Difficulty Changes", "Enable mod stone tools", true).getBoolean(true); @@ -285,6 +286,7 @@ public class PHConstruct // Difficulty modifiers public static boolean keepHunger; public static boolean keepLevels; + public static boolean deathPenality; public static boolean alphaRegen; public static boolean alphaHunger; diff --git a/src/main/java/tconstruct/world/items/StrangeFood.java b/src/main/java/tconstruct/world/items/StrangeFood.java index 03ae6ed4..8e9127b9 100644 --- a/src/main/java/tconstruct/world/items/StrangeFood.java +++ b/src/main/java/tconstruct/world/items/StrangeFood.java @@ -13,6 +13,7 @@ public class StrangeFood extends SpecialFood public StrangeFood() { super(new int[] { 2, 2, 4 }, new float[] { 1f, 1f, 0.6f }, new String[] { "edibleslime", "edibleblood", "bacon" }, new String[] { "food/edibleslime", "food/edibleblood", "food/bacon" }); + this.setHasSubtypes(true); } @Override