Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
isOre() is now handled by the MeltData
Browse files Browse the repository at this point in the history
instead of the oredict
  • Loading branch information
ephys committed Jan 17, 2015
1 parent c04a34a commit 6cc449c
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 72 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/tsteelworks/client/gui/DeepTankGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/tsteelworks/client/gui/HighOvenGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}

Expand Down
42 changes: 14 additions & 28 deletions src/main/java/tsteelworks/common/blocks/logic/HighOvenLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
*
Expand Down
9 changes: 2 additions & 7 deletions src/main/java/tsteelworks/common/core/TSContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down
38 changes: 19 additions & 19 deletions src/main/java/tsteelworks/common/core/TSRecipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -133,7 +133,7 @@ public static void createRecipes() {
craftStorageBlocks();
craftSteel();
craftPigIron();
//craftObsidian();
craftObsidian();
craftGlass();
craftWater();
craftMachines();
Expand Down Expand Up @@ -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" };

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

Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tsteelworks/lib/TSRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
32 changes: 22 additions & 10 deletions src/main/java/tsteelworks/lib/registry/AdvancedSmelting.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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) {
Expand Down Expand Up @@ -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() {
Expand All @@ -221,6 +229,10 @@ public int getMeltingPoint() {
public FluidStack getResult() {
return result;
}

public boolean isOre() {
return isOre;
}
}

// ======================= mixs =========================
Expand Down

0 comments on commit 6cc449c

Please sign in to comment.