Rewrote parts of the Oil Cracker so that it's in line with the new

recipes
This commit is contained in:
Johannes Gäßler 2017-05-25 18:34:00 +02:00
parent 66c957a21e
commit 4c02055503
2 changed files with 63 additions and 44 deletions

View file

@ -796,7 +796,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer {
public boolean mHasParentMod = true, mHasPlasma = false, mHasGas = false, mCustomOre = false; public boolean mHasParentMod = true, mHasPlasma = false, mHasGas = false, mCustomOre = false;
public Fluid mSolid = null, mFluid = null, mGas = null, mPlasma = null; public Fluid mSolid = null, mFluid = null, mGas = null, mPlasma = null;
private boolean hasCorrespondingFluid = false, hasCorrespondingGas = false, canBeCracked = false, canBeSteamCracked = false; private boolean hasCorrespondingFluid = false, hasCorrespondingGas = false, canBeCracked = false;
private Fluid[] hydroCrackedFluids = new Fluid[3], steamCrackedFluids = new Fluid[3]; private Fluid[] hydroCrackedFluids = new Fluid[3], steamCrackedFluids = new Fluid[3];
/** /**

View file

@ -9,6 +9,7 @@ import gregtech.api.gui.GT_GUIContainer_MultiMachine;
import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_ModHandler;
@ -20,10 +21,9 @@ import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBase { public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBase {
private final FluidStack fluidToDecreaseEu = GT_ModHandler.getSteam(128); private ForgeDirection orientation;
private final FluidStack fluidToIncreaseOutput = Materials.Hydrogen.getGas(64); private int controllerX, controllerZ;
public GT_MetaTileEntity_OilCracker(int aID, String aName, String aNameRegional) { public GT_MetaTileEntity_OilCracker(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional); super(aID, aName, aNameRegional);
} }
@ -35,16 +35,15 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa
public String[] getDescription() { public String[] getDescription() {
return new String[]{ return new String[]{
"Controller Block for the Oil Cracking Unit", "Controller Block for the Oil Cracking Unit",
"Cracks heavy oil into lighter parts", "Thermally cracks heavy hydrocarbons into lighter fractions",
"Size(WxHxD): 5x3x3 (Hollow), Controller (Front center)", "Size(WxHxD): 5x3x3 (Hollow), Controller (Front center)",
"Ring of 8 Cupronickel Coils (Each side of Controller)", "Ring of 8 Cupronickel Coils (Each side of Controller)",
"1x Input Hatch (Any left side casing)", "1x Hydrocarbon Input Bus/Hatch (Any left side casing)",
"1x Input Hatch (Any middle ring casing)", "1x Steam/Hydrogen Input Hatch (Any middle ring casing)",
"1x Output Hatch (Any right side casing)", "1x Cracked Hydrocarbon Output Hatch (Any right side casing)",
"1x Maintenance Hatch (Any middle ring casing)", "1x Maintenance Hatch (Any middle ring casing)",
"1x Energy Hatch (Any middle ring casing)", "1x Energy Hatch (Any middle ring casing)",
"Clean Stainless Steel Machine Casings for the rest (18 at least!)", "Clean Stainless Steel Machine Casings for the rest (18 at least!)"};
"Optional Steam(50% less EU/t) or Hydrogen(30% more output)"};
} }
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
@ -62,47 +61,38 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa
@Override @Override
public boolean checkRecipe(ItemStack aStack) { public boolean checkRecipe(ItemStack aStack) {
ArrayList<FluidStack> tInputList = getStoredFluids(); ArrayList<FluidStack> tInputList = getStoredFluids();
for (FluidStack tInput : tInputList) { FluidStack[] tFluidInputs = tInputList.toArray(new FluidStack[tInputList.size()]);
long tVoltage = getMaxInputVoltage(); long tVoltage = getMaxInputVoltage();
byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sCrakingRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], new FluidStack[]{tInput}, new ItemStack[]{}); GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sCrakingRecipes.findRecipe(
if (tRecipe != null) { getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluidInputs ,new ItemStack[]{mInventory[1]});
if (tRecipe.isRecipeInputEqual(true, new FluidStack[]{tInput}, new ItemStack[]{})) { if (tRecipe != null && tRecipe.isRecipeInputEqual(true, tFluidInputs, new ItemStack[]{mInventory[1]})) {
boolean needDecreaseEu = depleteInput(fluidToDecreaseEu); this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
boolean needIncreaseOutput = !needDecreaseEu && depleteInput(fluidToIncreaseOutput); this.mEfficiencyIncrease = 10000;
this.mEUt = tRecipe.mEUt;
this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mMaxProgresstime = tRecipe.mDuration;
this.mEfficiencyIncrease = 10000; while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) {
if (tRecipe.mEUt <= 16) { this.mEUt *= 4;
this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); this.mMaxProgresstime /= 2;
this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1));
} else {
this.mEUt = tRecipe.mEUt;
this.mMaxProgresstime = tRecipe.mDuration;
while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) {
this.mEUt *= 4;
this.mMaxProgresstime /= 2;
}
}
if (needDecreaseEu) this.mEUt = this.mEUt / 2;
if (this.mEUt > 0) {
this.mEUt = (-this.mEUt);
}
this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)};
if (needIncreaseOutput) this.mOutputFluids[0].amount = this.mOutputFluids[0].amount * 130 / 100;
return true;
}
} }
if (this.mEUt > 0) {
this.mEUt = (-this.mEUt);
}
this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)};
return true;
} }
return false; return false;
} }
@Override @Override
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; this.orientation = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing());
int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; this.controllerX = aBaseMetaTileEntity.getXCoord();
this.controllerZ = aBaseMetaTileEntity.getZCoord();
int xDir = this.orientation.offsetX;
int zDir = this.orientation.offsetZ;
int amount = 0; int amount = 0;
replaceDeprecatedCoils(aBaseMetaTileEntity); replaceDeprecatedCoils(aBaseMetaTileEntity);
if (xDir != 0) { if (xDir != 0) {
@ -252,4 +242,33 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa
} }
} }
} }
@Override
public ArrayList<FluidStack> getStoredFluids() {
ArrayList<FluidStack> rList = new ArrayList<FluidStack>();
for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) {
tHatch.mRecipeMap = getRecipeMap();
if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) {
FluidStack tStack = tHatch.getFillableStack();
if (tStack.isFluidEqual(GT_ModHandler.getSteam(1000)) || tStack.isFluidEqual(Materials.Hydrogen.getGas(1000))) {
if (isHatchInMiddleRing(tHatch)) {
rList.add(tStack);
}
} else {
if (!isHatchInMiddleRing(tHatch)) {
rList.add(tStack);
}
}
}
}
return rList;
}
private boolean isHatchInMiddleRing(GT_MetaTileEntity_Hatch_Input inputHatch){
if (orientation == ForgeDirection.NORTH || orientation == ForgeDirection.SOUTH) {
return inputHatch.getBaseMetaTileEntity().getXCoord() == this.controllerX;
} else {
return inputHatch.getBaseMetaTileEntity().getZCoord() == this.controllerZ;
}
}
} }