aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java15
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java16
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java303
3 files changed, 270 insertions, 64 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java
index e57fbed1f8..c244831f6f 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java
@@ -3,12 +3,8 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.t
import java.util.ArrayList;
import gregtech.GT_Mod;
-import gregtech.api.GregTech_API;
-import gregtech.api.enums.Textures;
-import gregtech.api.interfaces.ITexture;
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_Utility;
import gtPlusPlus.core.block.ModBlocks;
@@ -33,14 +29,9 @@ public class GT_MTE_LargeTurbine_SHSteam extends GregtechMetaTileEntity_LargerTu
super(aName);
}
- @Override
- public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
- return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? new GT_RenderedTexture(Textures.BlockIcons.LARGETURBINE_TI_ACTIVE5) : new GT_RenderedTexture(Textures.BlockIcons.LARGETURBINE_TI5) : Textures.BlockIcons.CASING_BLOCKS[getTAE()]};
- }
-
public String[] getDescription() {
if (mCasingName.toLowerCase().contains(".name")) {
- mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, 7);
+ mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, 9);
}
return new String[]{
"Controller Block for the XL High Pressure Steam Turbine",
@@ -62,7 +53,7 @@ public class GT_MTE_LargeTurbine_SHSteam extends GregtechMetaTileEntity_LargerTu
@Override
public Block getCasingBlock() {
- return GregTech_API.sBlockCasings4;
+ return ModBlocks.blockCasings4Misc;
}
@Override
@@ -111,7 +102,7 @@ public class GT_MTE_LargeTurbine_SHSteam extends GregtechMetaTileEntity_LargerTu
totalFlow += flow; // track total input used
if (!achievement) {
try {
- GT_Mod.instance.achievements.issueAchievement(this.getBaseMetaTileEntity().getWorld().getPlayerEntityByName(this.getBaseMetaTileEntity().getOwnerName()), "efficientsteam");
+ GT_Mod.achievements.issueAchievement(this.getBaseMetaTileEntity().getWorld().getPlayerEntityByName(this.getBaseMetaTileEntity().getOwnerName()), "efficientsteam");
} catch (Exception e) {
}
achievement = true;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java
index 27b5f9a774..0d667575c5 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java
@@ -5,13 +5,8 @@ import static gtPlusPlus.core.lib.CORE.RANDOM;
import java.util.ArrayList;
import gregtech.GT_Mod;
-import gregtech.api.GregTech_API;
-import gregtech.api.enums.TAE;
-import gregtech.api.enums.Textures;
-import gregtech.api.interfaces.ITexture;
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_Utility;
import gtPlusPlus.core.block.ModBlocks;
@@ -37,14 +32,9 @@ public class GT_MTE_LargeTurbine_Steam extends GregtechMetaTileEntity_LargerTurb
super(aName);
}
- @Override
- public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
- return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? new GT_RenderedTexture(Textures.BlockIcons.LARGETURBINE_ST_ACTIVE5) : new GT_RenderedTexture(Textures.BlockIcons.LARGETURBINE_ST5) : Textures.BlockIcons.CASING_BLOCKS[getTAE()]};
- }
-
public String[] getDescription() {
if (mCasingName.toLowerCase().contains(".name")) {
- mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, 7);
+ mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, 8);
}
return new String[]{
"Controller Block for the XL Steam Turbine",
@@ -66,7 +56,7 @@ public class GT_MTE_LargeTurbine_Steam extends GregtechMetaTileEntity_LargerTurb
@Override
public Block getCasingBlock() {
- return GregTech_API.sBlockCasings4;
+ return ModBlocks.blockCasings4Misc;
}
@Override
@@ -121,7 +111,7 @@ public class GT_MTE_LargeTurbine_Steam extends GregtechMetaTileEntity_LargerTurb
remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches
totalFlow += flow; // track total input used
if (!achievement) {
- GT_Mod.instance.achievements.issueAchievement(this.getBaseMetaTileEntity().getWorld().getPlayerEntityByName(this.getBaseMetaTileEntity().getOwnerName()), "muchsteam");
+ GT_Mod.achievements.issueAchievement(this.getBaseMetaTileEntity().getWorld().getPlayerEntityByName(this.getBaseMetaTileEntity().getOwnerName()), "muchsteam");
achievement = true;
}
}else if(fluidName.equals("ic2.fluidSuperheatedSteam")){
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java
index ea27472236..54f16e1944 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java
@@ -4,19 +4,31 @@ import java.util.ArrayList;
import gregtech.api.GregTech_API;
import gregtech.api.enums.TAE;
+import gregtech.api.enums.Textures;
import gregtech.api.gui.GT_GUIContainer_MultiMachine;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.items.GT_MetaGenerated_Tool;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler;
+import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Utility;
import gregtech.common.items.GT_MetaGenerated_Tool_01;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.minecraft.BlockPos;
import gtPlusPlus.core.block.ModBlocks;
+import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.minecraft.ItemUtils;
+import gtPlusPlus.core.util.minecraft.PlayerUtils;
+import gtPlusPlus.core.util.sys.KeyboardUtils;
+import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Turbine;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase;
+import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon;
+import gtPlusPlus.xmod.gregtech.common.blocks.textures.turbine.LargeTurbineTextureHandler;
import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -35,16 +47,27 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
private final int mCasingTextureID;
public static String mCasingName;
+
+ 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);
mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, getCasingMeta());
mCasingTextureID = getTAE();
+ GT9_5_Active = getCasingMeta() == 8 ? LargeTurbineTextureHandler.frontFaceActive_4 : LargeTurbineTextureHandler.frontFaceHPActive_4;
+ GT9_5 = getCasingMeta() == 8 ? LargeTurbineTextureHandler.frontFace_4 : LargeTurbineTextureHandler.frontFaceHP_4;
+ frontFaceActive = new GT_RenderedTexture(GT9_5_Active);
+ frontFace = new GT_RenderedTexture(GT9_5);
+
}
public GregtechMetaTileEntity_LargerTurbineBase(String aName) {
super(aName);
mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, getCasingMeta());
mCasingTextureID = getTAE();
+ GT9_5_Active = getCasingMeta() == 8 ? LargeTurbineTextureHandler.frontFaceActive_4 : LargeTurbineTextureHandler.frontFaceHPActive_4;
+ GT9_5 = getCasingMeta() == 8 ? LargeTurbineTextureHandler.frontFace_4 : LargeTurbineTextureHandler.frontFaceHP_4;
+ frontFaceActive = new GT_RenderedTexture(GT9_5_Active);
+ frontFace = new GT_RenderedTexture(GT9_5);
}
public final int getTAE() {
@@ -67,23 +90,40 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
@Override
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
return checkMachine2(aBaseMetaTileEntity, aStack);
-
}
-
public boolean checkMachine2(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) {
- int depth = 1;
//9 high
//7x7
+
this.mDynamoHatches.clear();
- for (int i=0;i>=-9;i--) {
+ this.mTurbineRotorHatches.clear();
+ this.mMaintenanceHatches.clear();
+ this.mMufflerHatches.clear();
+ this.mInputHatches.clear();
+ this.mOutputHatches.clear();
+
+ for (int i=0;i>-9;i--) {
if (!getLayer(i)) {
Logger.INFO("Bad Layer: "+(+i));
return false;
}
- }
- if (mMaintenanceHatches.size() != 1 || mDynamoHatches.size() < 1 || mMufflerHatches.size() < 4) {
- Logger.INFO("Bad Hatches");
+ }
+
+ Logger.INFO("Hatches | Found "+mTurbineRotorHatches.size()+" Rotor Assemblies, "+12+" are required.");
+ Logger.INFO("Hatches | Found "+mMaintenanceHatches.size()+" Maint. hatches, "+1+" are required.");
+ Logger.INFO("Hatches | Found "+mDynamoHatches.size()+" Dynamos, "+1+" or more are required.");
+ Logger.INFO("Hatches | Found "+mMufflerHatches.size()+" Mufflers, "+4+" are required.");
+ Logger.INFO("Hatches | Found "+mInputHatches.size()+" Input Hatches, "+1+" or more are required.");
+ Logger.INFO("Hatches | Found "+mOutputHatches.size()+" Output Hatches, "+1+" ore more are required.");
+
+ if (mTurbineRotorHatches.size() != 12 ||
+ mMaintenanceHatches.size() != 1 ||
+ mDynamoHatches.size() < 1 ||
+ mMufflerHatches.size() != 4 ||
+ mInputHatches.size() < 1 ||
+ mOutputHatches.size() < 1
+ ) {
return false;
}
Logger.INFO("Built Structure");
@@ -92,7 +132,7 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
public boolean getLayer(int aY) {
- if (aY == 0 || aY == 2 || aY == 3 || aY == 5 || aY == 6 || aY == 8) {
+ if (aY == 0 || aY == -2 || aY == -3 || aY == -5 || aY == -6 || aY == -8) {
return checkNormalLayer(aY);
}
else {
@@ -107,21 +147,27 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
for (int z = -3; z <= 3; z++) {
tBlock = this.getBaseMetaTileEntity().getBlockOffset(x, aY, z);
tMeta = this.getBaseMetaTileEntity().getMetaIDOffset(x, aY, z);
- IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityOffset(x, aY, z);
+ IGregTechTileEntity tTileEntity;
if (aY == 0 && x == 0 && z == 0) {
- Logger.INFO("GOOD 1");
- continue;
- }
-
- else if (tBlock == getCasingBlock() && tMeta == getCasingMeta()) {
- Logger.INFO("GOOD 0");
continue;
- } else if (this.addToMachineList(tTileEntity, this.mCasingTextureID)) {
- Logger.INFO("GOOD 2");
+ }
+ else if ((x == 0 && z == -3) || (x == 0 && z == 3) || (x == 3 && z == 0) || (x == -3 && z == 0) ||
+ ((aY == 0) && (x == 0 && z == -2) || (x == 0 && z == 2) || (x == 2 && z == 0) || (x == -2 && z == 0))) {
+ tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityOffset(x, aY, z);
+ if (this.addToMachineList(tTileEntity, this.mCasingTextureID)) {
+ Logger.INFO("Added Hatch at offset "+x+", "+aY+", "+z+" | Type: "+tTileEntity.getInventoryName());
+ continue;
+ }
+ }
+ else if (isValidCasingBlock(tBlock, tMeta)) {
continue;
- } else {
- Logger.INFO("BAD 1");
+ } else {
+ if (tBlock != null) {
+ log("Offset: "+x+", "+aY+", "+z);
+ log("Found "+tBlock.getLocalizedName()+" with Meta "+tMeta);
+ log("Expected "+getCasingBlock().getLocalizedName()+" with Meta "+getCasingMeta());
+ }
return false;
}
}
@@ -139,7 +185,8 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
}
}
- public boolean checkTurbineLayerX(int aY) {
+ public boolean checkTurbineLayerX(int aY) {
+ Logger.INFO("checking X");
Block tBlock;
int tMeta;
for (int x = -3; x <= 3; x++) {
@@ -147,14 +194,30 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
tBlock = this.getBaseMetaTileEntity().getBlockOffset(x, aY, z);
tMeta = this.getBaseMetaTileEntity().getMetaIDOffset(x, aY, z);
- if (x == 0 || z == 0) {
+ if ((x == 0 && z == -3) || (x == 0 && z == 3) || (x == 3 && z == 0) || (x == -3 && z == 0) ||
+ ((aY == 0) && (x == 0 && z == -2) || (x == 0 && z == 2) || (x == 2 && z == 0) || (x == -2 && z == 0))) {
IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityOffset(x, aY, z);
if (this.addToMachineList(tTileEntity, this.mCasingTextureID)) {
+ Logger.INFO("Added Hatch at offset "+x+", "+aY+", "+z+" | Type: "+tTileEntity.getInventoryName());
continue;
- }
- }
+ }
+ }
+
if (x == -2 || x == 2) {
+
+ //Find Hatches on the ends
+ if (z == -3 || z == 3) {
+ IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityOffset(x, aY, z);
+ if (this.addTurbineHatch(tTileEntity, this.mCasingTextureID)) {
+ log("Found x axis Turbine Assembly at Offset: "+x+", "+aY+", "+z);
+ continue;
+ }
+ else {
+ log("Missing x axis Turbine Assembly at Offset: "+x+", "+aY+", "+z);
+ }
+ }
+
if (isValidTurbineBlock(tBlock, tMeta)) {
continue;
}
@@ -176,6 +239,7 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
}
public boolean checkTurbineLayerZ(int aY) {
+ Logger.INFO("checking Z");
Block tBlock;
int tMeta;
for (int x = -3; x <= 3; x++) {
@@ -183,14 +247,29 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
tBlock = this.getBaseMetaTileEntity().getBlockOffset(x, aY, z);
tMeta = this.getBaseMetaTileEntity().getMetaIDOffset(x, aY, z);
- if (x == 0 || z == 0) {
+ if ((x == 0 && z == -3) || (x == 0 && z == 3) || (x == 3 && z == 0) || (x == -3 && z == 0) ||
+ ((aY == 0) && (x == 0 && z == -2) || (x == 0 && z == 2) || (x == 2 && z == 0) || (x == -2 && z == 0))) {
IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityOffset(x, aY, z);
if (this.addToMachineList(tTileEntity, this.mCasingTextureID)) {
+ Logger.INFO("Added Hatch at offset "+x+", "+aY+", "+z+" | Type: "+tTileEntity.getInventoryName());
continue;
- }
+ }
}
if (z == -2 || z == 2) {
+
+ //Find Hatches on the ends
+ if (x == -3 || x == 3) {
+ IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityOffset(x, aY, z);
+ if (this.addTurbineHatch(tTileEntity, this.mCasingTextureID)) {
+ log("Found z axis Turbine Assembly at Offset: "+x+", "+aY+", "+z);
+ continue;
+ }
+ else {
+ log("Missing z axis Turbine Assembly at Offset: "+x+", "+aY+", "+z);
+ }
+ }
+
if (isValidTurbineBlock(tBlock, tMeta)) {
continue;
}
@@ -218,7 +297,7 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
if (Block.isEqualTo(aBlock, getCasingBlock()) && (int) aMeta == (int) getCasingMeta()) {
return true;
}
- Logger.INFO("Found "+(aBlock != null ? aBlock.getLocalizedName() : "Air") + " With Meta "+aMeta+", Expected "+getCasingBlock().getLocalizedName()+" With Meta "+getCasingMeta());
+ log("Found "+(aBlock != null ? aBlock.getLocalizedName() : "Air") + " With Meta "+aMeta+", Expected "+getCasingBlock().getLocalizedName()+" With Meta "+getCasingMeta());
return false;
}
@@ -226,7 +305,7 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
if (aBlock == getCasingBlock() && aMeta == getCasingMetaTurbine()) {
return true;
}
- Logger.INFO("Found "+(aBlock != null ? aBlock.getLocalizedName() : "Air") + "With Meta "+aMeta);
+ log("Found "+(aBlock != null ? aBlock.getLocalizedName() : "Air") + " With Meta "+aMeta+", Expected "+getCasingBlock().getLocalizedName()+" With Meta "+getCasingMetaTurbine());
return false;
}
@@ -243,16 +322,6 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
public abstract byte getCasingTextureIndex();
@Override
- public void saveNBTData(NBTTagCompound aNBT) {
- super.saveNBTData(aNBT);
- }
-
- @Override
- public void loadNBTData(NBTTagCompound aNBT) {
- super.loadNBTData(aNBT);
- }
-
- @Override
public boolean checkRecipe(ItemStack aStack) {
if((counter&7)==0 && (aStack==null || !(aStack.getItem() instanceof GT_MetaGenerated_Tool) || aStack.getItemDamage() < 170 || aStack.getItemDamage() >179)) {
stopMachine();
@@ -266,7 +335,7 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
baseEff = GT_Utility.safeInt((long)((5F + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack)) * 1000F));
optFlow = GT_Utility.safeInt((long)Math.max(Float.MIN_NORMAL,
((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack).getSpeedMultiplier()
- * ((GT_MetaGenerated_Tool) aStack.getItem()).getPrimaryMaterial(aStack).mToolSpeed
+ * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolSpeed
* 50));
if(optFlow<=0 || baseEff<=0){
stopMachine();//in case the turbine got removed
@@ -276,6 +345,9 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
counter++;
}
}
+ else {
+ Logger.INFO("Did not find any valid input fluids.");
+ }
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
@@ -287,8 +359,9 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
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
+ } else {
this.mEUt = newPower;
+ }
if (this.mEUt <= 0) {
//stopMachine();
@@ -404,4 +477,156 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechM
return 16;
}
+
+ @Override
+ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if (!KeyboardUtils.isShiftKeyDown()) {
+ super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ);
+ }
+ else {
+ this.mIsAnimated = Utils.invertBoolean(mIsAnimated);
+ if (this.mIsAnimated) {
+ PlayerUtils.messagePlayer(aPlayer, "Using Animated Turbine Texture.");
+ }
+ else {
+ PlayerUtils.messagePlayer(aPlayer, "Using Static Turbine Texture.");
+ }
+ if (mTurbineRotorHatches.size() > 0) {
+ for (GT_MetaTileEntity_Hatch_Turbine h : mTurbineRotorHatches) {
+ if (h != null) {
+ h.mUsingAnimation = mIsAnimated;
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ super.saveNBTData(aNBT);
+ aNBT.setBoolean("mIsAnimated", mIsAnimated);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ mIsAnimated = aNBT.getBoolean("mIsAnimated");
+ }
+
+ private boolean mIsAnimated = true;
+ public ITexture frontFace;
+ public ITexture frontFaceActive;
+ private CustomIcon GT9_5_Active;
+ private CustomIcon GT9_5;
+
+ public boolean usingAnimations() {
+ return mIsAnimated;
+ }
+
+ @Override
+ public final ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? getFrontFacingTurbineTexture(aActive) : Textures.BlockIcons.CASING_BLOCKS[getTAE()]};
+ }
+
+ protected ITexture getFrontFacingTurbineTexture(boolean isActive) {
+ if (usingAnimations()) {
+ if (isActive) {
+ return frontFaceActive;
+ }
+ }
+ return frontFace;
+ }
+
+ public boolean addTurbineHatch(final IGregTechTileEntity aTileEntity,
+ final int aBaseCasingIndex) {
+ if (aTileEntity == null) {
+ return false;
+ }
+ final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity == null) {
+ return false;
+ }
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine) {
+ log("Found GT_MetaTileEntity_Hatch_Turbine");
+ updateTexture(aTileEntity, aBaseCasingIndex);
+ 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);
+ }
+ else {
+ Logger.INFO("Failed to inject controller into Turbine Assembly Hatch.");
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ super.onPostTick(aBaseMetaTileEntity, aTick);
+ if (aBaseMetaTileEntity.isServerSide()) {
+ if (mUpdate == 0 || this.mStartUpCheck == 0) {
+ this.mTurbineRotorHatches.clear();
+ }
+ }
+ if (aTick % 20 == 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) {
+ enableAllTurbineHatches();
+ }
+
+ }
+ @Override
+ public void startProcess() {
+ super.startProcess();
+ enableAllTurbineHatches();
+ }
+ @Override
+ public void onMachineBlockUpdate() {
+ super.onMachineBlockUpdate();
+ }
+ @Override
+ public boolean onRunningTick(ItemStack aStack) {
+ return super.onRunningTick(aStack);
+ }
+ @Override
+ public void stopMachine() {
+ super.stopMachine();
+ disableAllTurbineHatches();
+ }
+ @Override
+ public void onRemoval() {
+ super.onRemoval();
+ for (GT_MetaTileEntity_Hatch_Turbine h : this.mTurbineRotorHatches) {
+ h.clearController();
+ }
+ disableAllTurbineHatches();
+ this.mTurbineRotorHatches.clear();
+ }
+
+ public boolean enableAllTurbineHatches() {
+ return updateTurbineHatches(this.isMachineRunning()) > 0;
+ }
+ public boolean disableAllTurbineHatches() {
+ return updateTurbineHatches(false) > 0;
+ }
+
+ private Long mLastHatchUpdate;
+ public int updateTurbineHatches(boolean aState) {
+ int aUpdated = 0;
+ if (mLastHatchUpdate == null) {
+ mLastHatchUpdate = System.currentTimeMillis()/1000;
+ }
+ if (this.mTurbineRotorHatches.isEmpty() || ((System.currentTimeMillis()/1000)-mLastHatchUpdate) <= 2) {
+ return 0;
+ }
+ for (GT_MetaTileEntity_Hatch_Turbine h : this.mTurbineRotorHatches) {
+ h.setActive(aState);
+ aUpdated++;
+ }
+
+ mLastHatchUpdate = System.currentTimeMillis()/1000;
+ return aUpdated;
+ }
+
+
}