From 6cc449c42ba0cbe42054afffde6a924e5a26b5b6 Mon Sep 17 00:00:00 2001 From: ephys Date: Sat, 17 Jan 2015 18:30:06 +0100 Subject: [PATCH] isOre() is now handled by the MeltData instead of the oredict --- build.gradle | 2 +- .../tsteelworks/client/gui/DeepTankGui.java | 6 +-- .../tsteelworks/client/gui/HighOvenGui.java | 6 +-- .../common/blocks/logic/HighOvenLogic.java | 42 +++++++------------ .../tsteelworks/common/core/TSContent.java | 9 +--- .../tsteelworks/common/core/TSRecipes.java | 38 ++++++++--------- src/main/java/tsteelworks/lib/TSRepo.java | 2 +- .../lib/registry/AdvancedSmelting.java | 32 +++++++++----- 8 files changed, 65 insertions(+), 72 deletions(-) diff --git a/build.gradle b/build.gradle index ef91ad4..cd97179 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ ext { // _ts_mantle_version = "0.3.1.jenkins176" _ts_tcon_version = "1.8.2.build857" - _ts_steelworks_version = "1.1.0" + _ts_steelworks_version = "1.0.7" _ts_waila_version = "1.5.8a_1.7.10" _ts_ccc_version = "1.0.4.29" // CodeChickenCore diff --git a/src/main/java/tsteelworks/client/gui/DeepTankGui.java b/src/main/java/tsteelworks/client/gui/DeepTankGui.java index d5b78de..2834081 100644 --- a/src/main/java/tsteelworks/client/gui/DeepTankGui.java +++ b/src/main/java/tsteelworks/client/gui/DeepTankGui.java @@ -67,7 +67,7 @@ protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) FluidStack liquid = tank.getFluid(i); IIcon icon = liquid.getFluid().getStillIcon(); - float liquidSize = (float) liquid.amount / tank.getCapacity() * TANK_HEIGHT; + float liquidSize = (float) liquid.amount * TANK_HEIGHT / tank.getCapacity(); RenderHelper.drawTexturedRect(icon, guiLeft + TANK_XPOS, TANK_WIDTH, yBottom, liquidSize, zLevel); @@ -106,9 +106,9 @@ private FluidStack getFluidAtPos(int posX, int posY) { for (int i = 0; i < fluidTank.getNbFluids(); i++) { FluidStack stack = fluidTank.getFluid(i); - float liquidSize = (float) stack.amount / fluidTank.getCapacity() * TANK_HEIGHT; + float liquidSize = (float) stack.amount * TANK_HEIGHT / fluidTank.getCapacity(); - if (posY >= bottomY - (liquidSize + liquidOffset) && posY < bottomY - liquidOffset) { + if (posY >= bottomY - (liquidSize + liquidOffset) && posY <= bottomY - liquidOffset) { return stack; } diff --git a/src/main/java/tsteelworks/client/gui/HighOvenGui.java b/src/main/java/tsteelworks/client/gui/HighOvenGui.java index 07b91d9..e01d183 100644 --- a/src/main/java/tsteelworks/client/gui/HighOvenGui.java +++ b/src/main/java/tsteelworks/client/gui/HighOvenGui.java @@ -60,7 +60,7 @@ protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) FluidStack liquid = tank.getFluid(i); IIcon icon = liquid.getFluid().getStillIcon(); - float liquidSize = (float) liquid.amount / tank.getCapacity() * TANK_HEIGHT; + float liquidSize = (float) liquid.amount * TANK_HEIGHT / tank.getCapacity(); RenderHelper.drawTexturedRect(icon, guiLeft + TANK_XPOS, TANK_WIDTH, yBottom, liquidSize, zLevel); @@ -234,9 +234,9 @@ private FluidStack getFluidAtPos(int posX, int posY) { for (int i = 0; i < fluidTank.getNbFluids(); i++) { FluidStack stack = fluidTank.getFluid(i); - float liquidSize = (float) stack.amount / fluidTank.getCapacity() * TANK_HEIGHT; + float liquidSize = (float) stack.amount * TANK_HEIGHT / fluidTank.getCapacity(); - if (posY >= bottomY - (liquidSize + liquidOffset) && posY < bottomY - liquidOffset) { + if (posY >= bottomY - (liquidSize + liquidOffset) && posY <= bottomY - liquidOffset) { return stack; } diff --git a/src/main/java/tsteelworks/common/blocks/logic/HighOvenLogic.java b/src/main/java/tsteelworks/common/blocks/logic/HighOvenLogic.java index 140608d..c6404bc 100644 --- a/src/main/java/tsteelworks/common/blocks/logic/HighOvenLogic.java +++ b/src/main/java/tsteelworks/common/blocks/logic/HighOvenLogic.java @@ -305,20 +305,19 @@ private void heatItems() { } if (this.activeTemps[i] >= this.meltingTemps[i] && !worldObj.isRemote) { - final FluidStack result = this.getNormalResultFor(this.smeltableInventory.getStackInSlot(i)); - final ItemStack resultitemstack = this.getSolidMixedResultFor(result); - - if (resultitemstack != null) { - this.meltItemsSolidOutput(i, resultitemstack, true); - } else if (result != null) { - final FluidStack resultEx = this.getLiquidMixedResultFor(result); - - if (resultEx != null) { - this.meltItemsLiquidOutput(i, resultEx, true); - } else { - this.meltItemsLiquidOutput(i, result, false); - } + final AdvancedSmelting.MeltData result = AdvancedSmelting.getMeltData(this.smeltableInventory.getStackInSlot(i)); + + if (result == null) continue; + + final ItemStack resultItemstack = this.getSolidMixedResultFor(result.getResult()); + if (resultItemstack != null) { + this.meltItemsSolidOutput(i, resultItemstack, true); + continue; } + + final FluidStack mixResult = this.getLiquidMixedResultFor(result.getResult()); + final boolean hasMix = mixResult != null; + this.meltItemsLiquidOutput(i, hasMix ? mixResult : result.getResult(), hasMix, result.isOre()); } } @@ -357,10 +356,9 @@ private void heatFluids() { * @param fluid the fluid * @param doMix the do mix */ - private void meltItemsLiquidOutput(final int slot, final FluidStack fluid, final Boolean doMix) { + private void meltItemsLiquidOutput(final int slot, final FluidStack fluid, final boolean doMix, final boolean isOre) { if (this.addFluidToTank(fluid)) { - ItemStack stack = smeltableInventory.getStackInSlot(slot); - if (InventoryHelper.itemIsOre(stack)) + if (isOre) this.outputTE3Slag(); smeltableInventory.decrStackSize(slot, 1); @@ -390,18 +388,6 @@ private void meltItemsSolidOutput(final int slot, final ItemStack stack, final B this.addItem(stack); } - /** - * Gets the normal result for. - * - * @param itemstack the stack - * @return the normal result for - */ - public FluidStack getNormalResultFor(final ItemStack itemstack) { - AdvancedSmelting.MeltData data = AdvancedSmelting.getMeltData(itemstack); - - return data == null ? null : data.getResult(); - } - /** * Gets the liquid mixed result for. * diff --git a/src/main/java/tsteelworks/common/core/TSContent.java b/src/main/java/tsteelworks/common/core/TSContent.java index a5041e2..c44c90a 100644 --- a/src/main/java/tsteelworks/common/core/TSContent.java +++ b/src/main/java/tsteelworks/common/core/TSContent.java @@ -175,13 +175,8 @@ public static void oreRegistry() { // TConstuct OreDictionary.registerOre("blockGraveyardDirt", new ItemStack(TinkerTools.craftedSoil, 1, 3)); - // * Dual registry for smelting (slag) purposes (we need the ore prefix) - OreDictionary.registerOre("oreberryIron", new ItemStack(TinkerWorld.oreBerries, 1, 0)); - OreDictionary.registerOre("oreberryCopper", new ItemStack(TinkerWorld.oreBerries, 1, 2)); - OreDictionary.registerOre("oreberryTin", new ItemStack(TinkerWorld.oreBerries, 1, 3)); - OreDictionary.registerOre("oreberryAluminum", new ItemStack(TinkerWorld.oreBerries, 1, 4)); - OreDictionary.registerOre("oreberryAluminium", new ItemStack(TinkerWorld.oreBerries, 1, 4)); - OreDictionary.registerOre("oreberryEssence", new ItemStack(TinkerWorld.oreBerries, 1, 5)); + if (TinkerWorld.oreBerries != null) + OreDictionary.registerOre("oreberryEssence", new ItemStack(TinkerWorld.oreBerries, 1, 5)); } /** diff --git a/src/main/java/tsteelworks/common/core/TSRecipes.java b/src/main/java/tsteelworks/common/core/TSRecipes.java index 4accc10..f12f616 100644 --- a/src/main/java/tsteelworks/common/core/TSRecipes.java +++ b/src/main/java/tsteelworks/common/core/TSRecipes.java @@ -104,17 +104,17 @@ public static void addHighOvenSmelts() { AdvancedSmelting.addDictionaryMelting("block" + name, obsidian, temperatureMod, BLOCK_LIQUID_VALUE); } - AdvancedSmelting.addMelting(Items.emerald, 0, getFluidTempMod("Emerald"), new FluidStack(TinkerSmeltery.moltenEmeraldFluid, INGOT_LIQUID_VALUE)); - AdvancedSmelting.addMelting(TinkerSmeltery.glueBlock, 0, getFluidTempMod("Glue"), new FluidStack(TinkerSmeltery.glueFluid, BLOCK_LIQUID_VALUE)); + AdvancedSmelting.addMelting(Items.emerald, 0, getFluidTempMod("Emerald"), new FluidStack(TinkerSmeltery.moltenEmeraldFluid, INGOT_LIQUID_VALUE), false); + AdvancedSmelting.addMelting(TinkerSmeltery.glueBlock, 0, getFluidTempMod("Glue"), new FluidStack(TinkerSmeltery.glueFluid, BLOCK_LIQUID_VALUE), false); FluidType limestoneFluid = FluidType.getFluidType("Limestone"); Smeltery.addDictionaryMelting("blockLimestone", limestoneFluid, 825, INGOT_LIQUID_VALUE * 4); AdvancedSmelting.addDictionaryMelting("blockLimestone", limestoneFluid, 825, INGOT_LIQUID_VALUE * 4); Smeltery.addMelting(new ItemStack(TSContent.materialsTS, 1, 1), TSContent.limestoneBlock, 1, 0, new FluidStack(ModsData.Fluids.moltenLimestoneFluid, INGOT_LIQUID_VALUE)); - AdvancedSmelting.addMelting(new ItemStack(TSContent.materialsTS, 1, 1), 825, new FluidStack(ModsData.Fluids.moltenLimestoneFluid, INGOT_LIQUID_VALUE)); + AdvancedSmelting.addMelting(new ItemStack(TSContent.materialsTS, 1, 1), 825, new FluidStack(ModsData.Fluids.moltenLimestoneFluid, INGOT_LIQUID_VALUE), false); Smeltery.addMelting(new ItemStack(TSContent.materialsTS, 1, 2), TSContent.limestoneBlock, 1, 0, new FluidStack(ModsData.Fluids.moltenLimestoneFluid, INGOT_LIQUID_VALUE)); - AdvancedSmelting.addMelting(new ItemStack(TSContent.materialsTS, 1, 2), 825, new FluidStack(ModsData.Fluids.moltenLimestoneFluid, INGOT_LIQUID_VALUE)); + AdvancedSmelting.addMelting(new ItemStack(TSContent.materialsTS, 1, 2), 825, new FluidStack(ModsData.Fluids.moltenLimestoneFluid, INGOT_LIQUID_VALUE), false); } public static void createAlloys() { @@ -133,7 +133,7 @@ public static void createRecipes() { craftStorageBlocks(); craftSteel(); craftPigIron(); - //craftObsidian(); + craftObsidian(); craftGlass(); craftWater(); craftMachines(); @@ -258,12 +258,12 @@ public static void craftStone() { final String fluidName = "Stone"; final Fluid fluid = TinkerSmeltery.moltenStoneFluid; - AdvancedSmelting.addMelting(Blocks.stone, 0, getFluidTempMod(fluidName), new FluidStack(fluid, INGOT_LIQUID_VALUE / 18)); - AdvancedSmelting.addMelting(Blocks.cobblestone, 0, getFluidTempMod(fluidName), new FluidStack(fluid, INGOT_LIQUID_VALUE / 18)); - AdvancedSmelting.addMelting(TinkerTools.craftedSoil, 1, getFluidTempMod(fluidName), new FluidStack(fluid, INGOT_LIQUID_VALUE / 4)); + AdvancedSmelting.addMelting(Blocks.stone, 0, getFluidTempMod(fluidName), new FluidStack(fluid, INGOT_LIQUID_VALUE / 18), false); + AdvancedSmelting.addMelting(Blocks.cobblestone, 0, getFluidTempMod(fluidName), new FluidStack(fluid, INGOT_LIQUID_VALUE / 18), false); + AdvancedSmelting.addMelting(TinkerTools.craftedSoil, 1, getFluidTempMod(fluidName), new FluidStack(fluid, INGOT_LIQUID_VALUE / 4), false); Smeltery.addMelting(FluidType.getFluidType(fluidName), new ItemStack(TinkerTools.materials, 1, 2), 0, INGOT_LIQUID_VALUE); - AdvancedSmelting.addMelting(new ItemStack(TinkerTools.materials, 1, 2), getFluidTempMod(fluidName), new FluidStack(fluid, INGOT_LIQUID_VALUE)); + AdvancedSmelting.addMelting(new ItemStack(TinkerTools.materials, 1, 2), getFluidTempMod(fluidName), new FluidStack(fluid, INGOT_LIQUID_VALUE), false); final String[] dyes = new String[] { "dyeWhite", "dyeOrange", "dyeMagenta", "dyeLightBlue", "dyeYellow", "dyeLime", "dyePink", "dyeGray", "dyeLightGray", "dyeCyan", "dyePurple", "dyeBlue", "dyeBrown", "dyeGreen", "dyeRed", "dyeBlack" }; @@ -282,7 +282,7 @@ public static void craftStone() { continue; Smeltery.addMelting(new ItemStack(TinkerSmeltery.smeltery, 1, meta), getFluidTempMod(fluidName), new FluidStack(fluid, INGOT_LIQUID_VALUE)); - AdvancedSmelting.addMelting(new ItemStack(TinkerSmeltery.smeltery, 1, meta), getFluidTempMod(fluidName), new FluidStack(fluid, INGOT_LIQUID_VALUE)); + AdvancedSmelting.addMelting(new ItemStack(TinkerSmeltery.smeltery, 1, meta), getFluidTempMod(fluidName), new FluidStack(fluid, INGOT_LIQUID_VALUE), false); } } @@ -321,28 +321,28 @@ public static void craftPigIron() { } public static void craftObsidian() { - AdvancedSmelting.addMelting(Blocks.obsidian, 0, getFluidTempMod("Obsidian"), new FluidStack(TinkerSmeltery.moltenObsidianFluid, INGOT_LIQUID_VALUE * 2)); + AdvancedSmelting.addMelting(Blocks.obsidian, 0, getFluidTempMod("Obsidian"), new FluidStack(TinkerSmeltery.moltenObsidianFluid, INGOT_LIQUID_VALUE * 2), false); } public static void craftGlass() { final String fluidName = "Glass"; final Fluid glassFluid = TinkerSmeltery.moltenGlassFluid; - AdvancedSmelting.addMelting(Blocks.sand, 0, getFluidTempMod(fluidName), new FluidStack(glassFluid, FluidContainerRegistry.BUCKET_VOLUME)); - AdvancedSmelting.addMelting(Blocks.glass, 0, getFluidTempMod(fluidName), new FluidStack(glassFluid, FluidContainerRegistry.BUCKET_VOLUME)); - AdvancedSmelting.addMelting(Blocks.glass_pane, 0, getFluidTempMod(fluidName), new FluidStack(glassFluid, 250)); + AdvancedSmelting.addMelting(Blocks.sand, 0, getFluidTempMod(fluidName), new FluidStack(glassFluid, FluidContainerRegistry.BUCKET_VOLUME), false); + AdvancedSmelting.addMelting(Blocks.glass, 0, getFluidTempMod(fluidName), new FluidStack(glassFluid, FluidContainerRegistry.BUCKET_VOLUME), false); + AdvancedSmelting.addMelting(Blocks.glass_pane, 0, getFluidTempMod(fluidName), new FluidStack(glassFluid, 250), false); - AdvancedSmelting.addMelting(TinkerSmeltery.clearGlass, 0, getFluidTempMod(fluidName), new FluidStack(glassFluid, 1000)); - AdvancedSmelting.addMelting(TinkerSmeltery.glassPane, 0, getFluidTempMod(fluidName), new FluidStack(glassFluid, 250)); + AdvancedSmelting.addMelting(TinkerSmeltery.clearGlass, 0, getFluidTempMod(fluidName), new FluidStack(glassFluid, 1000), false); + AdvancedSmelting.addMelting(TinkerSmeltery.glassPane, 0, getFluidTempMod(fluidName), new FluidStack(glassFluid, 250), false); } public static void craftWater() { final String fluidName = "Water"; final Fluid fluidWater = FluidRegistry.WATER; - AdvancedSmelting.addMelting(Blocks.ice, 0, getFluidTempMod(fluidName), new FluidStack(fluidWater, 1000)); - AdvancedSmelting.addMelting(Blocks.snow, 0, getFluidTempMod(fluidName), new FluidStack(fluidWater, 500)); - AdvancedSmelting.addMelting(Items.snowball, 0, getFluidTempMod(fluidName), new FluidStack(fluidWater, 125)); + AdvancedSmelting.addMelting(Blocks.ice, 0, getFluidTempMod(fluidName), new FluidStack(fluidWater, 1000), false); + AdvancedSmelting.addMelting(Blocks.snow, 0, getFluidTempMod(fluidName), new FluidStack(fluidWater, 500), false); + AdvancedSmelting.addMelting(Items.snowball, 0, getFluidTempMod(fluidName), new FluidStack(fluidWater, 125), false); } public static void changeAnvil() { diff --git a/src/main/java/tsteelworks/lib/TSRepo.java b/src/main/java/tsteelworks/lib/TSRepo.java index 7a84573..4fb25d3 100644 --- a/src/main/java/tsteelworks/lib/TSRepo.java +++ b/src/main/java/tsteelworks/lib/TSRepo.java @@ -3,7 +3,7 @@ public class TSRepo { public static final String MOD_ID = "TSteelworks"; public static final String MOD_NAME = "Tinkers' Steelworks"; - public static final String MOD_VER = "1.7.10-1.1.0"; + public static final String MOD_VER = "1.7.10-1.0.7"; public static final String MOD_SERV_PROXY = "tsteelworks.common.core.TSCommonProxy"; public static final String MOD_CLIENT_PROXY = "tsteelworks.client.core.TSClientProxy"; public static final String MOD_REQUIRE = "required-after:TConstruct;required-after:Forge@[10.13,);required-after:cookiecore@[1.3.0,);after:CoFHCore,NotEnoughItems"; diff --git a/src/main/java/tsteelworks/lib/registry/AdvancedSmelting.java b/src/main/java/tsteelworks/lib/registry/AdvancedSmelting.java index a78fccb..0d2579f 100644 --- a/src/main/java/tsteelworks/lib/registry/AdvancedSmelting.java +++ b/src/main/java/tsteelworks/lib/registry/AdvancedSmelting.java @@ -34,9 +34,10 @@ public class AdvancedSmelting { * @param temperature How hot the block should be before liquifying. Max temp in the * Smeltery is 800, other structures may vary * @param output The result of the process in liquid form + * @param isOre The itemstack is an ore */ - public static void addMelting(Block block, int metadata, int temperature, FluidStack output) { - addMelting(new ItemStack(block, 1, metadata), temperature, output); + public static void addMelting(Block block, int metadata, int temperature, FluidStack output, boolean isOre) { + addMelting(new ItemStack(block, 1, metadata), temperature, output, isOre); } /** @@ -47,9 +48,10 @@ public static void addMelting(Block block, int metadata, int temperature, FluidS * @param temperature How hot the block should be before liquifying. Max temp in the * Smeltery is 800, other structures may vary * @param output The result of the process in liquid form + * @param isOre The itemstack is an ore */ - public static void addMelting(Item item, int metadata, int temperature, FluidStack output) { - addMelting(new ItemStack(item, 1, metadata), temperature, output); + public static void addMelting(Item item, int metadata, int temperature, FluidStack output, boolean isOre) { + addMelting(new ItemStack(item, 1, metadata), temperature, output, isOre); } /** @@ -61,8 +63,10 @@ public static void addMelting(Item item, int metadata, int temperature, FluidSta * @param fluidAmount Amount of Fluid */ public static void addDictionaryMelting(String oreName, FluidType type, int tempDiff, int fluidAmount) { + boolean isOre = oreName.startsWith("ore"); + for (final ItemStack is : OreDictionary.getOres(oreName)) - addMelting(is, tempDiff, type, fluidAmount); + addMelting(is, tempDiff, type, fluidAmount, isOre); } /** @@ -72,14 +76,15 @@ public static void addDictionaryMelting(String oreName, FluidType type, int temp * @param input The item to liquify * @param tempDiff Difference between FluidType BaseTemperature and the melting temperature * @param fluidAmount Amount of Fluid + * @param isOre The itemstack is an ore */ - public static void addMelting(ItemStack input, int tempDiff, FluidType type, int fluidAmount) { + public static void addMelting(ItemStack input, int tempDiff, FluidType type, int fluidAmount, boolean isOre) { int temp = type.baseTemperature + tempDiff; if (temp <= 20) temp = 20; - addMelting(input, temp, new FluidStack(type.fluid, fluidAmount)); + addMelting(input, temp, new FluidStack(type.fluid, fluidAmount), isOre); } /** @@ -89,9 +94,10 @@ public static void addMelting(ItemStack input, int tempDiff, FluidType type, int * @param itemstack : The item to liquify * @param temperature : How hot the block should be before liquifying * @param liquid : The result of the process + * @param isOre : The itemstack is an ore */ - public static void addMelting(ItemStack itemstack, int temperature, FluidStack liquid) { - meltingList.put(new HashedItemStack(itemstack), new MeltData(temperature, liquid)); + public static void addMelting(ItemStack itemstack, int temperature, FluidStack liquid, boolean isOre) { + meltingList.put(new HashedItemStack(itemstack), new MeltData(temperature, liquid, isOre)); } public static MeltData getMeltData(ItemStack stack) { @@ -208,10 +214,12 @@ public static ItemStack getMixItemSmeltingResult(Fluid fluid, ItemStack oxidizer public static class MeltData { private int meltingPoint; private FluidStack result; + private boolean isOre; - public MeltData(int meltingPoint, FluidStack result) { + public MeltData(int meltingPoint, FluidStack result, boolean isOre) { this.meltingPoint = meltingPoint; this.result = result; + this.isOre = isOre; } public int getMeltingPoint() { @@ -221,6 +229,10 @@ public int getMeltingPoint() { public FluidStack getResult() { return result; } + + public boolean isOre() { + return isOre; + } } // ======================= mixs =========================