aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/xmod/gregtech/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/common')
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/turbine/LargeTurbineTextureHandler.java2
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java2
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java47
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java22
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java16
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java20
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java635
7 files changed, 519 insertions, 225 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/turbine/LargeTurbineTextureHandler.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/turbine/LargeTurbineTextureHandler.java
index ec93c4379d..7169861340 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/turbine/LargeTurbineTextureHandler.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/turbine/LargeTurbineTextureHandler.java
@@ -351,7 +351,7 @@ public class LargeTurbineTextureHandler {
if (aTile != null) {
final IMetaTileEntity aMetaTileEntity = aTile.getMetaTileEntity();
if (aMetaTileEntity != null && aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine) {
- aVal = ((GT_MetaTileEntity_Hatch_Turbine) aMetaTileEntity).isControllerActive();
+ aVal = ((GT_MetaTileEntity_Hatch_Turbine) aMetaTileEntity).getBaseMetaTileEntity().isActive();
//Logger.INFO("Returning "+aVal+" as Rotor Assembly controller status");
}
}
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java
index c5450fec5b..965b8bd70c 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java
@@ -63,7 +63,7 @@ extends GregtechMeta_MultiBlockBase {
.addCasingInfo("Sieve Grate", 18)
.addCasingInfo("Sieve Casings", 35)
.addInputBus("Any Casing", 1)
- .addOutputBus("Any Casing", 1)
+ .addOutputBus("Any Casing (x4)", 1)
.addEnergyHatch("Any Casing", 1)
.addMaintenanceHatch("Any Casing", 1)
.addMufflerHatch("Any Casing", 1)
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java
index 53b3f491cc..6221dba89d 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java
@@ -11,7 +11,6 @@ import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gregtech.api.util.GT_Utility;
-import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
@@ -43,15 +42,25 @@ public class GT_MTE_LargeTurbine_Gas extends GregtechMetaTileEntity_LargerTurbin
return 58;
}
+
+ @Override
+ protected boolean requiresOutputHatch() {
+ return false;
+ }
+
@Override
- public int getPollutionPerTick(ItemStack aStack) {
- return 15;
+ public int getPollutionPerSecond(ItemStack aStack) {
+ return 5000;
}
public int getFuelValue(FluidStack aLiquid) {
- if (aLiquid == null) return 0;
+ if (aLiquid == null) {
+ return 0;
+ }
GT_Recipe tFuel = GT_Recipe_Map.sTurbineFuels.findFuel(aLiquid);
- if (tFuel != null) return tFuel.mSpecialValue;
+ if (tFuel != null) {
+ return tFuel.mSpecialValue;
+ }
return 0;
}
@@ -63,7 +72,7 @@ public class GT_MTE_LargeTurbine_Gas extends GregtechMetaTileEntity_LargerTurbin
FluidStack firstFuelType = new FluidStack(aFluids.get(0), 0); // Identify a SINGLE type of fluid to process. Doesn't matter which one. Ignore the rest!
int fuelValue = getFuelValue(firstFuelType);
-
+ //log("Fuel Value of "+aFluids.get(0).getLocalizedName()+" is "+fuelValue+"eu");
if (aOptFlow < fuelValue) {
// turbine too weak and/or fuel too powerful
// at least consume 1L
@@ -94,6 +103,11 @@ public class GT_MTE_LargeTurbine_Gas extends GregtechMetaTileEntity_LargerTurbin
if (totalFlow <= 0) return 0;
tEU = GT_Utility.safeInt((long) totalFlow * fuelValue);
+ //log("Total Flow: "+totalFlow);
+ //log("Real Optimal Flow: "+actualOptimalFlow);
+ //log("Flow: "+flow);
+ //log("Remaining Flow: "+remainingFlow);
+
if (totalFlow == actualOptimalFlow) {
tEU = GT_Utility.safeInt((long) tEU * (long) aBaseEff / 10000L);
} else {
@@ -110,26 +124,17 @@ public class GT_MTE_LargeTurbine_Gas extends GregtechMetaTileEntity_LargerTurbin
@Override
public int getDamageToComponent(ItemStack aStack) {
- return (looseFit && RANDOM.nextInt(4)==0)?0:1;
- }
-
-
- @Override
- public String[] getExtraInfoData() {
- super.looseFit = looseFit;
- return super.getInfoData();
+ return (RANDOM.nextInt(4) == 0) ? 0 : 1;
}
@Override
public void saveNBTData(NBTTagCompound aNBT) {
super.saveNBTData(aNBT);
- aNBT.setBoolean("turbineFitting",looseFit);
}
@Override
public void loadNBTData(NBTTagCompound aNBT) {
super.loadNBTData(aNBT);
- looseFit=aNBT.getBoolean("turbineFitting");
}
@Override
@@ -139,27 +144,27 @@ public class GT_MTE_LargeTurbine_Gas extends GregtechMetaTileEntity_LargerTurbin
@Override
public String getMachineType() {
- return "Large Steam Turbine";
+ return "Large Gas Turbine";
}
@Override
protected String getTurbineType() {
- return "Steam";
+ return "Gas";
}
@Override
protected String getCasingName() {
- return "Reinforced Steam Turbine Casing";
+ return "Reinforced Gas Turbine Casing";
}
@Override
protected ITexture getTextureFrontFace() {
- return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_ST5);
+ return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_SS5);
}
@Override
protected ITexture getTextureFrontFaceActive() {
- return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_ST_ACTIVE5);
+ return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_SS_ACTIVE5);
}
}
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java
index f815811ece..fbb9f4b92c 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java
@@ -40,8 +40,13 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur
return 60;
}
+ @Override
+ protected boolean requiresOutputHatch() {
+ return true;
+ }
+
@Override
- public int getPollutionPerTick(ItemStack aStack) {
+ public int getPollutionPerSecond(ItemStack aStack) {
return 0;
}
@@ -115,11 +120,6 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur
public int getDamageToComponent(ItemStack aStack) {
return 1;
}
-
- @Override
- public String[] getExtraInfoData() {
- return super.getInfoData();
- }
@Override
public String getCustomGUIResourceName() {
@@ -128,28 +128,28 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur
@Override
public String getMachineType() {
- return "Large Steam Turbine";
+ return "Large Plasma Turbine";
}
@Override
protected String getTurbineType() {
- return "Steam";
+ return "Plasma";
}
@Override
protected String getCasingName() {
- return "Reinforced Steam Turbine Casing";
+ return "Reinforced Plasma Turbine Casing";
}
@Override
protected ITexture getTextureFrontFace() {
- return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_ST5);
+ return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_TU5);
}
@Override
protected ITexture getTextureFrontFaceActive() {
- return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_ST_ACTIVE5);
+ return new GT_RenderedTexture(gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_TU_ACTIVE5);
}
}
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java
index d657c627d6..d1e3e35938 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java
@@ -11,7 +11,6 @@ import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.math.MathUtils;
-import gtPlusPlus.xmod.gregtech.common.blocks.textures.turbine.LargeTurbineTextureHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -46,8 +45,13 @@ public class GT_MTE_LargeTurbine_SHSteam extends GregtechMetaTileEntity_LargerTu
return 59;
}
+ @Override
+ protected boolean requiresOutputHatch() {
+ return true;
+ }
+
@Override
- public int getPollutionPerTick(ItemStack aStack) {
+ public int getPollutionPerSecond(ItemStack aStack) {
return 0;
}
@@ -125,11 +129,9 @@ public class GT_MTE_LargeTurbine_SHSteam extends GregtechMetaTileEntity_LargerTu
return (looseFit && CORE.RANDOM.nextInt(4)==0)?0:1;
}
- @Override
- public String[] getExtraInfoData() {
- super.looseFit = looseFit;
- return super.getInfoData();
- }
+ public boolean isLooseMode() {
+ return looseFit;
+ }
@Override
public void saveNBTData(NBTTagCompound aNBT) {
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java
index 9929a583a8..f285d3e8de 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java
@@ -10,9 +10,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_ModHandler;
-import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
-import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gtPlusPlus.core.util.math.MathUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -50,8 +48,13 @@ public class GT_MTE_LargeTurbine_Steam extends GregtechMetaTileEntity_LargerTurb
return 16;
}
+ @Override
+ protected boolean requiresOutputHatch() {
+ return true;
+ }
+
@Override
- public int getPollutionPerTick(ItemStack aStack) {
+ public int getPollutionPerSecond(ItemStack aStack) {
return 0;
}
@@ -132,13 +135,10 @@ public class GT_MTE_LargeTurbine_Steam extends GregtechMetaTileEntity_LargerTurb
public int getDamageToComponent(ItemStack aStack) {
return (looseFit && RANDOM.nextInt(4)==0)?0:1;
}
-
-
- @Override
- public String[] getExtraInfoData() {
- super.looseFit = looseFit;
- return super.getInfoData();
- }
+
+ public boolean isLooseMode() {
+ return looseFit;
+ }
@Override
public void saveNBTData(NBTTagCompound aNBT) {
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java
index 02d7268c0c..f34b744384 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java
@@ -2,14 +2,16 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.t
import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass;
import static gregtech.api.util.GT_StructureUtility.ofHatchAdder;
-import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional;
import java.util.ArrayList;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
import com.gtnewhorizon.structurelib.structure.StructureDefinition;
+import gregtech.api.enums.Materials;
import gregtech.api.enums.Textures;
import gregtech.api.gui.GT_GUIContainer_MultiMachine;
import gregtech.api.interfaces.ITexture;
@@ -24,9 +26,11 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maint
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output;
import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
+import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import gregtech.common.items.GT_MetaGenerated_Tool_01;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.AutoMap;
import gtPlusPlus.api.objects.minecraft.BlockPos;
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.lib.CORE;
@@ -51,14 +55,15 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
protected double realOptFlow = 0;
protected int storedFluid = 0;
protected int counter = 0;
- protected boolean looseFit=false;
-
+ protected int mCasing;
+
public ITexture frontFace;
public ITexture frontFaceActive;
public ArrayList<GT_MetaTileEntity_Hatch_Turbine> mTurbineRotorHatches = new ArrayList<GT_MetaTileEntity_Hatch_Turbine>();
+
public GregtechMetaTileEntity_LargerTurbineBase(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
frontFace = getTextureFrontFace();
@@ -70,37 +75,43 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
frontFace = getTextureFrontFace();
frontFaceActive = getTextureFrontFaceActive();
}
-
+
protected abstract ITexture getTextureFrontFace();
-
+
protected abstract ITexture getTextureFrontFaceActive();
-
+
protected abstract String getTurbineType();
-
+
protected abstract String getCasingName();
+ protected abstract boolean requiresOutputHatch();
+
@Override
protected final GT_Multiblock_Tooltip_Builder createTooltip() {
GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
tt.addMachineType(getMachineType())
- .addInfo("Controller Block for the XL "+getTurbineType()+" Turbine")
- .addPollutionAmount(getPollutionPerSecond(null))
- .addSeparator()
- .beginStructureBlock(3, 3, 9, false)
- .addController("Top Middle")
- .addCasingInfo(getCasingName(), 64)
- .addOtherStructurePart("Rotor Assembly", "Any 1 dot hint", 1)
- .addInputBus("Any 4 dot hint", 4)
- .addInputHatch("Any 4 dot hint", 4)
- .addOutputHatch("Any 4 dot hint", 4)
- .addDynamoHatch("Any 4 dot hint", 4)
- .addMaintenanceHatch("Any 4 dot hint", 4)
- .addMufflerHatch("Any 7 dot hint x4", 7)
- .toolTipFinisher(CORE.GT_Tooltip_Builder);
+ .addInfo("Controller Block for the XL "+getTurbineType()+" Turbine")
+ .addPollutionAmount(getPollutionPerSecond(null))
+ .addSeparator()
+ .beginStructureBlock(3, 9, 3, false)
+ .addController("Top Middle")
+ .addCasingInfo(getCasingName(), 360)
+ .addOtherStructurePart("Rotor Assembly", "Any 1 dot hint", 1)
+ .addInputBus("Any 4 dot hint (min 1)", 4)
+ .addInputHatch("Any 4 dot hint(min 1)", 4);
+ if (requiresOutputHatch()) {
+ tt.addOutputHatch("Any 4 dot hint(min 1)", 4);
+ }
+ tt.addDynamoHatch("Any 4 dot hint(min 1)", 4)
+ .addMaintenanceHatch("Any 4 dot hint(min 1)", 4);
+ if (requiresMufflers()) {
+ tt.addMufflerHatch("Any 7 dot hint (x4)", 7);
+ }
+ tt.toolTipFinisher(CORE.GT_Tooltip_Builder);
return tt;
}
-
+
private static final String STRUCTURE_PIECE_MAIN = "main";
private static final ClassValue<IStructureDefinition<GregtechMetaTileEntity_LargerTurbineBase>> STRUCTURE_DEFINITION = new ClassValue<IStructureDefinition<GregtechMetaTileEntity_LargerTurbineBase>>() {
@Override
@@ -121,12 +132,18 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
{"ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc"},
{"ctchctc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "cscccsc", "ctchctc"},
{"ccchccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccccccc", "ccchccc"},
- }))
- .addElement('c', lazy(t -> ofBlock(t.getCasingBlock(), t.getCasingMeta())))
+ }))
+
+ .addElement('c', lazy(t -> onElementPass(x -> ++x.mCasing, ofBlock(t.getCasingBlock(), t.getCasingMeta()))))
.addElement('s', lazy(t -> ofBlock(t.getCasingBlock(), t.getTurbineShaftMeta())))
.addElement('t', lazy(t -> ofHatchAdder(GregtechMetaTileEntity_LargerTurbineBase::addTurbineHatch, t.getCasingTextureIndex(), 1)))
- .addElement('h', lazy(t -> ofHatchAdderOptional(GregtechMetaTileEntity_LargerTurbineBase::addGenericHatch, t.getCasingTextureIndex(), 4, t.getCasingBlock(), t.getCasingMeta())))
- .addElement('m', lazy(t -> ofHatchAdderOptional(GregtechMetaTileEntity_LargerTurbineBase::addMuffler, t.getCasingTextureIndex(), 7, t.getCasingBlock(), t.getCasingMeta())))
+ .addElement('h', lazy(t -> ofChain(
+ ofHatchAdder(GregtechMetaTileEntity_LargerTurbineBase::addGenericHatch, t.getCasingTextureIndex(), 4),
+ onElementPass(x -> ++x.mCasing, ofBlock(t.getCasingBlock(), t.getCasingMeta()))
+ )))
+ .addElement('m', lazy(t -> ofChain(
+ ofHatchAdder(GregtechMetaTileEntity_LargerTurbineBase::addMuffler, t.getCasingTextureIndex(), 7),
+ onElementPass(x -> ++x.mCasing, ofBlock(t.getCasingBlock(), t.getCasingMeta())))))
.build();
}
};
@@ -136,25 +153,36 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
return STRUCTURE_DEFINITION.get(getClass());
}
+ private boolean requiresMufflers() {
+ return getPollutionPerSecond(null) > 0;
+ }
+
@Override
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
this.mDynamoHatches.clear();
this.mTurbineRotorHatches.clear();
this.mMaintenanceHatches.clear();
- this.mMufflerHatches.clear();
+ if (requiresMufflers()) {
+ this.mMufflerHatches.clear();
+ }
this.mInputBusses.clear();
this.mInputHatches.clear();
- this.mOutputHatches.clear();
-
+ if (requiresOutputHatch()) {
+ this.mOutputHatches.clear();
+ }
+ mCasing = 0;
+
boolean aStructure = checkPiece(STRUCTURE_PIECE_MAIN, 3, 3, 0);
+ boolean aCasingCount = mCasing >= 360;
log("Structure Check: "+aStructure);
- if (mTurbineRotorHatches.size() != 12 ||
+ if (!aCasingCount ||
+ mTurbineRotorHatches.size() != 12 ||
mMaintenanceHatches.size() != 1 ||
mDynamoHatches.size() < 1 ||
- mMufflerHatches.size() != 4 ||
+ (requiresMufflers() && mMufflerHatches.size() != 4) ||
mInputBusses.size() < 1 ||
mInputHatches.size() < 1 ||
- mOutputHatches.size() < 1
+ (requiresOutputHatch() && mOutputHatches.size() < 1)
) {
log("Bad Hatches - Turbine Housings: "+mTurbineRotorHatches.size()+
", Maint: "+mMaintenanceHatches.size()+
@@ -163,11 +191,11 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
", Input Buses: "+mInputBusses.size()+
", Input Hatches: "+mInputHatches.size()+
", Output Hatches: "+mOutputHatches.size()+
- ", ");
+ ", Casing Count: "+aCasingCount+" | Found: "+mCasing);
return false;
}
- log("Built "+this.getLocalName());
- return aStructure;
+ log("Built "+this.getLocalName()+" with "+mCasing+"/360 casings.");
+ return aCasingCount && aStructure;
}
@Override
@@ -189,8 +217,9 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
GT_MetaTileEntity_Hatch_Turbine aTurbineHatch = (GT_MetaTileEntity_Hatch_Turbine) aMetaTileEntity;
IGregTechTileEntity g = this.getBaseMetaTileEntity();
if (aTurbineHatch.setController(new BlockPos(g.getXCoord(), g.getYCoord(), g.getZCoord(), g.getWorld()))) {
- Logger.INFO("Injected Controller into Turbine Assembly.");
- return this.mTurbineRotorHatches.add(aTurbineHatch);
+ boolean aDidAdd = this.mTurbineRotorHatches.add(aTurbineHatch);
+ Logger.INFO("Injected Controller into Turbine Assembly. Found: "+this.mTurbineRotorHatches.size());
+ return aDidAdd;
}
else {
Logger.INFO("Failed to inject controller into Turbine Assembly Hatch.");
@@ -209,7 +238,6 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
return addToMachineList(aTileEntity, aBaseCasingIndex);
}
}
- log("Bad Muffler");
return false;
}
@@ -264,10 +292,10 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
public final Block getCasingBlock() {
return ModBlocks.blockSpecialMultiCasings;
}
-
+
@Override
public final boolean hasSlotInGUI() {
- return false;
+ return true;
}
public abstract int getCasingMeta();
@@ -278,104 +306,292 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
public abstract byte getCasingTextureIndex();
- public abstract int getFuelValue(FluidStack aLiquid);
-
- public static boolean isValidTurbine(ItemStack aTurbine) {
- return (aTurbine !=null && aTurbine.getItem() instanceof GT_MetaGenerated_Tool && aTurbine.getItemDamage() >= 170 && aTurbine.getItemDamage() <= 176);
- }
-
- private ArrayList<ItemStack> getAllBufferedTurbines(){
- ArrayList<ItemStack> aTurbinesInStorage = new ArrayList<ItemStack>();
- for (GT_MetaTileEntity_Hatch_InputBus aBus: this.mInputBusses) {
- if (isValidMetaTileEntity(aBus)) {
- for (ItemStack aContent : aBus.mInventory) {
- if (isValidTurbine(aContent)) {
- aTurbinesInStorage.add(aContent);
- }
- }
- }
- }
- return aTurbinesInStorage;
- }
-
- @Override
- public boolean checkRecipe(ItemStack aStack) {
-
+ public abstract int getFuelValue(FluidStack aLiquid);
+
+ public static boolean isValidTurbine(ItemStack aTurbine) {
+ return (aTurbine !=null && aTurbine.getItem() instanceof GT_MetaGenerated_Tool && aTurbine.getItemDamage() >= 170 && aTurbine.getItemDamage() <= 176);
+ }
+
+ private ArrayList<ItemStack> getAllBufferedTurbines(){
+ ArrayList<ItemStack> aTurbinesInStorage = new ArrayList<ItemStack>();
+ for (GT_MetaTileEntity_Hatch_InputBus aBus: this.mInputBusses) {
+ if (isValidMetaTileEntity(aBus)) {
+ for (ItemStack aContent : aBus.mInventory) {
+ if (isValidTurbine(aContent)) {
+ aTurbinesInStorage.add(aContent);
+ }
+ }
+ }
+ }
+ return aTurbinesInStorage;
+ }
+
+ public boolean areAllTurbinesTheSame() {
+ ArrayList<GT_MetaTileEntity_Hatch_Turbine> aTurbineAssemblies = getFullTurbineAssemblies();
+ if (aTurbineAssemblies.size() < 12) {
+ log("Found "+aTurbineAssemblies.size()+", expected 12.");
+ return false;
+ }
+ AutoMap<Materials> aTurbineMats = new AutoMap<Materials>();
+ AutoMap<Integer> aTurbineSizes = new AutoMap<Integer>();
+ for (GT_MetaTileEntity_Hatch_Turbine aHatch : aTurbineAssemblies) {
+ aTurbineMats.add(GT_MetaGenerated_Tool.getPrimaryMaterial(aHatch.getTurbine()));
+ aTurbineSizes.add(getTurbineSize(aHatch.getTurbine()));
+ }
+ Materials aBaseMat = aTurbineMats.get(0);
+ int aBaseSize = aTurbineSizes.get(0);
+ for (int aSize : aTurbineSizes) {
+ if (aBaseSize != aSize) {
+ return false;
+ }
+ }
+ for (Materials aMat : aTurbineMats) {
+ if (aBaseMat != aMat) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static int getTurbineSize(ItemStack aTurbine) {
+ if (isValidTurbine(aTurbine)) {
+ if (aTurbine.getItemDamage() >= 170 && aTurbine.getItemDamage() < 172) {
+ return 1;
+ }
+ else if (aTurbine.getItemDamage() >= 172 && aTurbine.getItemDamage() < 174) {
+ return 2;
+ }
+ else if (aTurbine.getItemDamage() >= 174 && aTurbine.getItemDamage() < 176) {
+ return 3;
+ }
+ else if (aTurbine.getItemDamage() >= 176 && aTurbine.getItemDamage() < 178) {
+ return 4;
+ }
+ }
+ return 0;
+ }
+
+ public static String getTurbineSizeString(int aSize) {
+ switch (aSize) {
+ case 1:
+ return "Small Turbine";
+ case 2:
+ return "Turbine";
+ case 3:
+ return "Large Turbine";
+ case 4:
+ return "Huge Turbine";
+ default:
+ return "";
+ }
+ }
+
+ private ArrayList<GT_MetaTileEntity_Hatch_Turbine> getEmptyTurbineAssemblies() {
ArrayList<GT_MetaTileEntity_Hatch_Turbine> aEmptyTurbineRotorHatches = new ArrayList<GT_MetaTileEntity_Hatch_Turbine>();
+ //log("Checking "+mTurbineRotorHatches.size()+" Assemblies for empties.");
for (GT_MetaTileEntity_Hatch_Turbine aTurbineHatch : this.mTurbineRotorHatches) {
if (!aTurbineHatch.hasTurbine()) {
+ //log("Found Assembly without Turbine.");
aEmptyTurbineRotorHatches.add(aTurbineHatch);
}
}
- if (aEmptyTurbineRotorHatches.size() > 0) {
- ArrayList<ItemStack> aTurbines = getAllBufferedTurbines();
- for (GT_MetaTileEntity_Hatch_Turbine aHatch : aEmptyTurbineRotorHatches) {
- for (ItemStack aTurbineItem : aTurbines) {
- if (aHatch.insertTurbine(aTurbineItem) && this.depleteInput(aTurbineItem)) {
- continue;
- }
- else {
- break;
- }
- }
+ return aEmptyTurbineRotorHatches;
+ }
+
+ private ArrayList<GT_MetaTileEntity_Hatch_Turbine> getFullTurbineAssemblies() {
+ ArrayList<GT_MetaTileEntity_Hatch_Turbine> aTurbineRotorHatches = new ArrayList<GT_MetaTileEntity_Hatch_Turbine>();
+ //log("Checking "+mTurbineRotorHatches.size()+" Assemblies for Turbines.");
+ for (GT_MetaTileEntity_Hatch_Turbine aTurbineHatch : this.mTurbineRotorHatches) {
+ if (aTurbineHatch.hasTurbine()) {
+ //log("Found Assembly with Turbine.");
+ aTurbineRotorHatches.add(aTurbineHatch);
}
- }
-
- if((counter&7)==0 && (aStack==null || !(aStack.getItem() instanceof GT_MetaGenerated_Tool) || aStack.getItemDamage() < 170 || aStack.getItemDamage() >179)) {
- stopMachine();
- return false;
}
- ArrayList<FluidStack> tFluids = getStoredFluids();
- if (tFluids.size() > 0) {
- if (baseEff == 0 || optFlow == 0 || counter >= 512 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()
- || this.getBaseMetaTileEntity().hasInventoryBeenModified()) {
- counter = 0;
- baseEff = MathUtils.safeInt((long)((5F + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack)) * 1000F));
- optFlow = MathUtils.safeInt((long)Math.max(Float.MIN_NORMAL,
- ((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack).getSpeedMultiplier()
- * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolSpeed
- * 50));
- if(optFlow<=0 || baseEff<=0){
- stopMachine();//in case the turbine got removed
- return false;
+ return aTurbineRotorHatches;
+ }
+
+ private boolean depleteTurbineFromStock(ItemStack aTurbine) {
+ for (GT_MetaTileEntity_Hatch_InputBus aInputBus : this.mInputBusses) {
+ for (int slot = 0; slot < aInputBus.mInventory.length; slot++) {
+ ItemStack aStack = aInputBus.getStackInSlot(slot);
+ if (aStack != null && GT_Utility.areStacksEqual(aStack, aTurbine)) {
+ aInputBus.setInventorySlotContents(slot, null);
+ updateSlots();
+ return true;
}
- } else {
- counter++;
}
}
- else {
- Logger.INFO("Did not find any valid input fluids.");
- }
+ return false;
+ }
+
+ @Override
+ public boolean checkRecipe(final ItemStack aStack) {
+ return checkRecipeGeneric(new ItemStack[] {}, getStoredFluids().toArray(new FluidStack[] {}), 1, 100, 100, 10000);
+ }
+
+ public boolean checkRecipeGeneric(
+ ItemStack[] aItemInputs, FluidStack[] aFluidInputs,
+ int aMaxParallelRecipes, int aEUPercent,
+ int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe, boolean isPerpectOC) {
+
+ try {
+ ArrayList<GT_MetaTileEntity_Hatch_Turbine> aEmptyTurbineRotorHatches = getEmptyTurbineAssemblies();
+ if (aEmptyTurbineRotorHatches.size() > 0) {
+ log("Found "+aEmptyTurbineRotorHatches.size()+" Assemblies without Turbine.");
+ ArrayList<ItemStack> aTurbines = getAllBufferedTurbines();
+ hatch : for (GT_MetaTileEntity_Hatch_Turbine aHatch : aEmptyTurbineRotorHatches) {
+ for (ItemStack aTurbineItem : aTurbines) {
+ if (aTurbineItem == null) {
+ continue;
+ }
+ if (aTurbineItem != null && aHatch.insertTurbine(aTurbineItem.copy())) {
+ boolean aDidDeplete = depleteTurbineFromStock(aTurbineItem);
+ log("Put Turbine into Assembly - "+aDidDeplete);
+ continue hatch;
+ }
+ }
+ }
+ }
+ //log("Found "+getFullTurbineAssemblies().size()+" Assemblies with a Turbine.");
- int newPower = fluidIntoPower(tFluids, optFlow, baseEff); // How much the turbine should be producing with this flow
- int difference = newPower - this.mEUt; // difference between current output and new output
+ if (getEmptyTurbineAssemblies().size() > 0 || !areAllTurbinesTheSame()) {
+ log("BAD RETURN - 1");
+ stopMachine();
+ return false;
+ }
- // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the difference in power level (per tick)
- // This is how much the turbine can actually change during this tick
- int maxChangeAllowed = Math.max(10, MathUtils.safeInt((long)Math.abs(difference)/100));
+ //log("Running checkRecipeGeneric(0)");
+
+ ArrayList<FluidStack> tFluids = getStoredFluids();
+
+ if (tFluids.size() > 0) {
+ if (baseEff == 0 || optFlow == 0 || counter >= 512 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()
+ || this.getBaseMetaTileEntity().hasInventoryBeenModified()) {
+ counter = 0;
+
+ //log("Running checkRecipeGeneric(1)");
+ float aTotalBaseEff = 0;
+ float aTotalOptimalFlow = 0;
+
+ ItemStack aStack = getFullTurbineAssemblies().get(0).getTurbine();
+ for (int i=0;i<18;i++) {
+ if (i == 0) {
+ aTotalBaseEff += GT_Utility.safeInt((long) ((5F + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack)) * 1000F));
+ //log("Bumped base eff to "+aTotalBaseEff);
+ }
+ aTotalOptimalFlow += GT_Utility.safeInt((long) Math.max(Float.MIN_NORMAL,
+ ((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack).getSpeedMultiplier()
+ * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolSpeed
+ * 50));
+ //log("Bumped base optimal flow to "+aTotalOptimalFlow);
+ }
- if (Math.abs(difference) > maxChangeAllowed) { // If this difference is too big, use the maximum allowed change
- int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative.
- this.mEUt += change; // Apply the change
- } else {
- this.mEUt = newPower;
+ //log("Running checkRecipeGeneric(2)");
+ //log("Total base eff: "+aTotalBaseEff);
+ //log("Total base optimal flow: "+aTotalOptimalFlow);
+ baseEff = MathUtils.roundToClosestInt(aTotalBaseEff);
+ optFlow = MathUtils.roundToClosestInt(aTotalOptimalFlow);
+ //log("Total eff: "+baseEff);
+ //log("Total optimal flow: "+optFlow);
+ if(optFlow<=0 || baseEff<=0){
+ log("Running checkRecipeGeneric(bad-1)");
+ stopMachine();//in case the turbine got removed
+ return false;
+ }
+ } else {
+ counter++;
+ }
+ }
+
+ //log("Total eff: "+baseEff);
+ //log("Total optimal flow: "+optFlow);
+
+ // How much the turbine should be producing with this flow
+ int newPower = fluidIntoPower(tFluids, optFlow, baseEff);
+ //log("Bumped newPower to "+newPower);
+ //log("New Power: "+newPower);
+ int difference = newPower - this.mEUt; // difference between current output and new output
+ //log("diff: "+difference);
+
+ // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the difference in power level (per tick)
+ // This is how much the turbine can actually change during this tick
+ int maxChangeAllowed = Math.max(10, GT_Utility.safeInt((long)Math.abs(difference)/100));
+ //log("Max Change Allowed: "+maxChangeAllowed);
+
+ if (Math.abs(difference) > maxChangeAllowed) { // If this difference is too big, use the maximum allowed change
+ int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative.
+ this.mEUt += change; // Apply the change
+ //log("Applied power change.");
+ }
+ else {
+ this.mEUt = newPower;
+ //log("Using same value.");
+ }