From 0b65e63e3705fc9ead2ddcb71e9da4ad808a2959 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Fri, 15 Dec 2017 12:14:47 +1000 Subject: Add TecTech support (#166) + Added check for TecTech mod. + Added TecTech support to my Base Multiblock. + Added TecTech support to my Power-Substation. + Added TecTech support to my Generator Array. % Made GT++ load after a few more mods that were recently added. $ Fixed else statement for computronics load message during startup. $ By now supporting Multi-amp Dynamos, this closes #161. --- .../base/GregtechMeta_MultiBlockBase.java | 109 +++++++++++++++++++-- .../GregtechMetaTileEntityGeneratorArray.java | 4 +- ...chMetaTileEntity_PowerSubStationController.java | 30 +++++- 3 files changed, 131 insertions(+), 12 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 1fe2426ced..5d8e2dd933 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -1,5 +1,7 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Iterator; @@ -12,6 +14,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Outpu import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.util.GT_Recipe; +import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_MultiMachine; @@ -223,13 +226,23 @@ GT_MetaTileEntity_MultiBlockBase { } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBattery) { + updateTexture(aBaseCasingIndex); return this.mChargeHatches.add( (GT_MetaTileEntity_Hatch_InputBattery) aMetaTileEntity); } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBattery) { + updateTexture(aBaseCasingIndex); return this.mDischargeHatches.add( (GT_MetaTileEntity_Hatch_OutputBattery) aMetaTileEntity); } + if (LoadedMods.TecTech){ + if (isThisHatchMultiDynamo()) { + updateTexture(aBaseCasingIndex); + return this.mMultiDynamoHatches.add( + (GT_MetaTileEntity_Hatch) aMetaTileEntity); + } + + } return super.addToMachineList(aTileEntity, aBaseCasingIndex); } @@ -243,8 +256,7 @@ GT_MetaTileEntity_MultiBlockBase { return false; } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBattery) { - //((GT_MetaTileEntity_Hatch) aMetaTileEntity); - //.updateTexture(aBaseCasingIndex); + updateTexture(aBaseCasingIndex); return this.mChargeHatches.add( (GT_MetaTileEntity_Hatch_InputBattery) aMetaTileEntity); } @@ -261,8 +273,7 @@ GT_MetaTileEntity_MultiBlockBase { return false; } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBattery) { - //((GT_MetaTileEntity_Hatch) aMetaTileEntity) - //.updateTexture(aBaseCasingIndex); + updateTexture(aBaseCasingIndex); return this.mDischargeHatches.add( (GT_MetaTileEntity_Hatch_OutputBattery) aMetaTileEntity); } @@ -279,7 +290,7 @@ GT_MetaTileEntity_MultiBlockBase { return false; } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - //((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + updateTexture(aBaseCasingIndex); ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); } @@ -295,10 +306,96 @@ GT_MetaTileEntity_MultiBlockBase { return false; } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { - //((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + updateTexture(aBaseCasingIndex); return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); } return false; } + + /** + * Enable Texture Casing Support if found in GT 5.09 + */ + + public boolean updateTexture(int aCasingID){ + try { + Method mProper = Class.forName("gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch").getDeclaredMethod("updateTexture", int.class); + if (mProper != null){ + mProper.setAccessible(true); + mProper.invoke(this, aCasingID); + } + else { + return false; + } + } + catch (NoSuchMethodException | SecurityException | ClassNotFoundException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {} + return false; + } + + + + + + + + + + /** + * TecTech Support + */ + + + /** + * This is the array Used to Store the Tectech Multi-Amp hatches. + */ + + public ArrayList mMultiDynamoHatches = new ArrayList(); + + /** + * TecTech Multi-Amp Dynamo Support + * @param aTileEntity - The Dynamo Hatch + * @param aBaseCasingIndex - Casing Texture + * @return + */ + + public boolean addMultiAmpDynamoToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex){ + //GT_MetaTileEntity_Hatch_DynamoMulti + if (aTileEntity == null) { + return false; + } + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (isThisHatchMultiDynamo()) { + updateTexture(aBaseCasingIndex); + return this.mMultiDynamoHatches.add((GT_MetaTileEntity_Hatch) aMetaTileEntity); + } + return false; + } + + public boolean isThisHatchMultiDynamo(){ + Class mDynamoClass; + try { + mDynamoClass = Class.forName("com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti"); + if (mDynamoClass != null){ + if (mDynamoClass.isInstance(this)){ + return true; + } + } + } + catch (ClassNotFoundException e) {} + return false; + } + + @Override + public boolean addDynamoToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (LoadedMods.TecTech){ + if (isThisHatchMultiDynamo()) { + addMultiAmpDynamoToMachineList(aTileEntity, aBaseCasingIndex); + } + + } + return super.addDynamoToMachineList(aTileEntity, aBaseCasingIndex); + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityGeneratorArray.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityGeneratorArray.java index eb7b1eb712..a6b3944a06 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityGeneratorArray.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityGeneratorArray.java @@ -6,12 +6,12 @@ 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.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.fluid.FluidUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; @@ -22,7 +22,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -public class GregtechMetaTileEntityGeneratorArray extends GT_MetaTileEntity_MultiBlockBase { +public class GregtechMetaTileEntityGeneratorArray extends GregtechMeta_MultiBlockBase { GT_Recipe mLastRecipe; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java index a163215459..54365f63d7 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java @@ -1,5 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; +import java.util.ArrayList; import java.util.concurrent.TimeUnit; import gregtech.api.GregTech_API; @@ -8,12 +9,14 @@ 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.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Config; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; @@ -34,6 +37,9 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe protected long mTotalEnergyConsumed = 0; protected long mTotalEnergyLost = 0; protected long mTotalRunTime = 0; + + //TecTech Support + public ArrayList mAllDynamoHatches = new ArrayList(); public GregtechMetaTileEntity_PowerSubStationController(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); @@ -246,14 +252,30 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe } } } + + /** + * TecTech Support, this allows adding Multi-Amp dynamos. + */ + if (this.mDynamoHatches.size() > 0){ + for (GT_MetaTileEntity_Hatch_Dynamo o : this.mDynamoHatches){ + mAllDynamoHatches.add(o); + } + } + if (LoadedMods.TecTech && this.mMultiDynamoHatches.size() > 0){ + for (GT_MetaTileEntity_Hatch o : this.mMultiDynamoHatches){ + mAllDynamoHatches.add(o); + } + } + + if ((this.mChargeHatches.size() < 1) || (this.mDischargeHatches.size() < 1) || (this.mMaintenanceHatches.size() != 1) || (this.mEnergyHatches.size() < 1) - || (this.mDynamoHatches.size() < 1)) { + || (this.mAllDynamoHatches.size() < 1)) { Utils.LOG_MACHINE_INFO("Returned False 3"); Utils.LOG_MACHINE_INFO("Charge Buses: "+this.mChargeHatches.size()+" | expected: 1 | "+(this.mChargeHatches.size() != 1)); Utils.LOG_MACHINE_INFO("Discharge Buses: "+this.mDischargeHatches.size()+" | expected: 1 | "+(this.mDischargeHatches.size() != 1)); Utils.LOG_MACHINE_INFO("Energy Hatches: "+this.mEnergyHatches.size()+" | expected: >= 1 | "+(this.mEnergyHatches.size() < 1)); - Utils.LOG_MACHINE_INFO("Dynamo Hatches: "+this.mDynamoHatches.size()+" | expected: >= 1 | "+(this.mDynamoHatches.size() < 1)); + Utils.LOG_MACHINE_INFO("Dynamo Hatches: "+this.mAllDynamoHatches.size()+" | expected: >= 1 | "+(this.mAllDynamoHatches.size() < 1)); Utils.LOG_MACHINE_INFO("Maint. Hatches: "+this.mMaintenanceHatches.size()+" | expected: 1 | "+(this.mMaintenanceHatches.size() != 1)); return false; } @@ -265,7 +287,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe tempAvg += re.getInputTier(); hatchCount++; } - for (GT_MetaTileEntity_Hatch_Dynamo re : this.mDynamoHatches){ + for (GT_MetaTileEntity_Hatch re : this.mAllDynamoHatches){ tempAvg += re.getOutputTier(); hatchCount++; } @@ -493,7 +515,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe } hatchCount++; } - for (GT_MetaTileEntity_Hatch_Dynamo tHatch : this.mDynamoHatches) { + for (GT_MetaTileEntity_Hatch tHatch : this.mAllDynamoHatches) { //Utils.LOG_INFO("Storing Power in a Dynamo Hatch"); if ((isValidMetaTileEntity(tHatch)) && (tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(tHatch.getOutputTier()*2, false))) { this.setEUVar(this.getEUVar()-(tHatch.getOutputTier()*2)); -- cgit