From 87d55337181db58328af35601d0d58405b9d591a Mon Sep 17 00:00:00 2001 From: Technus Date: Sat, 16 Dec 2017 20:50:23 +0100 Subject: Solidify base class of multiblocks --- .../compatibility/thaumcraft/EssentiaCompat.java | 2 +- .../thaumcraft/EssentiaCompatEnabled.java | 2 +- .../GT_MetaTileEntity_EM_essentiaDequantizer.java | 2 +- .../GT_MetaTileEntity_EM_essentiaQuantizer.java | 2 +- .../technus/tectech/loader/MachineLoader.java | 1 + .../multi/GT_MetaTileEntity_EM_annihilation.java | 1 + .../multi/GT_MetaTileEntity_EM_bhg.java | 1 + .../multi/GT_MetaTileEntity_EM_collider.java | 1 + .../multi/GT_MetaTileEntity_EM_computer.java | 1 + .../multi/GT_MetaTileEntity_EM_crafting.java | 1 + .../multi/GT_MetaTileEntity_EM_decay.java | 1 + .../multi/GT_MetaTileEntity_EM_dequantizer.java | 1 + .../multi/GT_MetaTileEntity_EM_infuser.java | 5 +- .../multi/GT_MetaTileEntity_EM_junction.java | 1 + .../multi/GT_MetaTileEntity_EM_machine.java | 1 + .../multi/GT_MetaTileEntity_EM_quantizer.java | 1 + .../multi/GT_MetaTileEntity_EM_research.java | 1 + .../multi/GT_MetaTileEntity_EM_scanner.java | 1 + .../multi/GT_MetaTileEntity_EM_stabilizer.java | 1 + .../multi/GT_MetaTileEntity_EM_switch.java | 1 + .../multi/GT_MetaTileEntity_EM_transformer.java | 5 +- .../multi/GT_MetaTileEntity_EM_wormhole.java | 1 + .../multi/GT_MetaTileEntity_MultiblockBase_EM.java | 1677 -------------------- .../multi/GT_MetaTileEntity_TM_microwave.java | 7 +- .../multi/base/GT_Container_MultiMachineEM.java | 128 ++ .../multi/base/GT_GUIContainer_MultiMachineEM.java | 205 +++ .../base/GT_MetaTileEntity_MultiblockBase_EM.java | 1675 +++++++++++++++++++ .../multi/gui/GT_Container_MultiMachineEM.java | 128 -- .../multi/gui/GT_GUIContainer_MultiMachineEM.java | 205 --- 29 files changed, 2038 insertions(+), 2021 deletions(-) delete mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_GUIContainer_MultiMachineEM.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java delete mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/gui/GT_Container_MultiMachineEM.java delete mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/gui/GT_GUIContainer_MultiMachineEM.java (limited to 'src') diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/EssentiaCompat.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/EssentiaCompat.java index f82c9e5225..fba6f1e6e9 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/EssentiaCompat.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/EssentiaCompat.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.compatibility.thaumcraft; import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack; -import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import net.minecraft.tileentity.TileEntity; /** diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/EssentiaCompatEnabled.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/EssentiaCompatEnabled.java index d55485dfe0..a66f51ff2d 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/EssentiaCompatEnabled.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/EssentiaCompatEnabled.java @@ -3,7 +3,7 @@ package com.github.technus.tectech.compatibility.thaumcraft; import com.github.technus.tectech.compatibility.thaumcraft.definitions.iElementalAspect; import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack; import com.github.technus.tectech.elementalMatter.core.templates.cElementalDefinition; -import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import net.minecraft.tileentity.TileEntity; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java index 666053ad1f..2162f81ab5 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java @@ -8,7 +8,7 @@ import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstance import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; -import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java index e5bde00836..350b918ba8 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java @@ -8,7 +8,7 @@ import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstance import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; -import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; diff --git a/src/main/java/com/github/technus/tectech/loader/MachineLoader.java b/src/main/java/com/github/technus/tectech/loader/MachineLoader.java index ac224ad0b6..ef77bb2111 100644 --- a/src/main/java/com/github/technus/tectech/loader/MachineLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/MachineLoader.java @@ -4,6 +4,7 @@ import com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity. import com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_essentiaQuantizer; import com.github.technus.tectech.thing.metaTileEntity.hatch.*; import com.github.technus.tectech.thing.metaTileEntity.multi.*; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Data; import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_EM; import com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_DebugPowerGenerator; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java index 53554d7e97..f64e6c84d5 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java @@ -3,6 +3,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java index d059066b37..a4eb61ae65 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java @@ -3,6 +3,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java index 08bb0f08e3..2903b99759 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java @@ -5,6 +5,7 @@ import com.github.technus.tectech.TecTech; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java index 01d620db7e..32dbbb8ee4 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java @@ -9,6 +9,7 @@ import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputData; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_OutputData; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Rack; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java index 8fb3e0df3a..b2942f8c1c 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java @@ -3,6 +3,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java index 66ba0d8433..a8473b7525 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java @@ -5,6 +5,7 @@ import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMa import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java index 0b3fdb5523..80e5d4aab2 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java @@ -9,6 +9,7 @@ import com.github.technus.tectech.elementalMatter.core.transformations.aOredictD import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputElemental; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java index 573cf8a5be..4115a93910 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java @@ -4,8 +4,9 @@ import cofh.api.energy.IEnergyContainerItem; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; -import com.github.technus.tectech.thing.metaTileEntity.multi.gui.GT_Container_MultiMachineEM; -import com.github.technus.tectech.thing.metaTileEntity.multi.gui.GT_GUIContainer_MultiMachineEM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_Container_MultiMachineEM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_GUIContainer_MultiMachineEM; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import ic2.api.item.ElectricItem; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java index 3d6b11bd79..28dbb61e83 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java @@ -4,6 +4,7 @@ import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputElemental; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_OutputElemental; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_machine.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_machine.java index 533807984b..3c1986d635 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_machine.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_machine.java @@ -3,6 +3,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.common.blocks.GT_Block_Machines; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java index fac96beee7..4f90191c07 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java @@ -11,6 +11,7 @@ import com.github.technus.tectech.elementalMatter.core.transformations.aOredictQ import com.github.technus.tectech.elementalMatter.core.transformations.bTransformationInfo; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import gregtech.api.GregTech_API; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java index ada50c3094..382ab68609 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java @@ -6,6 +6,7 @@ import com.github.technus.tectech.recipe.TT_recipe; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Holder; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java index 65b2fbf855..e92753a897 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java @@ -9,6 +9,7 @@ import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.block.QuantumStuffBlock; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import gregtech.api.enums.ItemList; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java index f59cc75b7c..c75453dc26 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java @@ -3,6 +3,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java index 6207dfe08a..059b7386ca 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java @@ -6,6 +6,7 @@ import com.github.technus.tectech.dataFramework.QuantumDataPacket; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputData; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_OutputData; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java index 83a7415d02..4bb1e6de3b 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java @@ -2,8 +2,9 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; -import com.github.technus.tectech.thing.metaTileEntity.multi.gui.GT_Container_MultiMachineEM; -import com.github.technus.tectech.thing.metaTileEntity.multi.gui.GT_GUIContainer_MultiMachineEM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_Container_MultiMachineEM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_GUIContainer_MultiMachineEM; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java index 518d1946f1..c410bb289c 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java @@ -3,6 +3,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java deleted file mode 100644 index a86bbb1a3a..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java +++ /dev/null @@ -1,1677 +0,0 @@ -package com.github.technus.tectech.thing.metaTileEntity.multi; - -import com.github.technus.tectech.CommonValues; -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.Util; -import com.github.technus.tectech.Vec3pos; -import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.elementalMatter.core.stacks.cElementalDefinitionStack; -import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack; -import com.github.technus.tectech.elementalMatter.core.tElementalException; -import com.github.technus.tectech.thing.metaTileEntity.hatch.*; -import com.github.technus.tectech.thing.metaTileEntity.multi.gui.GT_Container_MultiMachineEM; -import com.github.technus.tectech.thing.metaTileEntity.multi.gui.GT_GUIContainer_MultiMachineEM; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -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.BaseTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.*; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gregtech.common.GT_Pollution; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.fluids.FluidStack; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import static com.github.technus.tectech.CommonValues.*; -import static com.github.technus.tectech.Util.*; -import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; - -/** - * Created by danie_000 on 27.10.2016. - */ -public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEntity_MultiBlockBase { - protected final static Map adderMethodMap = new HashMap<>(); - public static Method adderMethod; - - protected cElementalInstanceStackMap[] outputEM; - - public final static ItemStack[] nothingI = new ItemStack[0]; - public final static FluidStack[] nothingF = new FluidStack[0]; - - protected static Textures.BlockIcons.CustomIcon ScreenOFF; - protected static Textures.BlockIcons.CustomIcon ScreenON; - - public ArrayList eInputHatches = new ArrayList<>(); - public ArrayList eOutputHatches = new ArrayList<>(); - public ArrayList eMufflerHatches = new ArrayList<>(); - public ArrayList eParamHatches = new ArrayList<>(); - public ArrayList eUncertainHatches = new ArrayList<>(); - public ArrayList eEnergyMulti = new ArrayList<>(); - public ArrayList eDynamoMulti = new ArrayList<>(); - public ArrayList eInputData = new ArrayList<>(); - public ArrayList eOutputData = new ArrayList<>(); - - // 0 and 10 are from first parametrizer - // 1 and 11 are from second etc... - - private final int[] iParamsIn = new int[20];//number I from parametrizers - private final int[] iParamsOut = new int[20];//number O to parametrizers - private final boolean[] bParamsAreFloats = new boolean[10]; - - public final byte[] eParamsInStatus = new byte[20];//LED status for I - public final byte[] eParamsOutStatus = new byte[20];//LED status for O - public final static byte STATUS_UNUSED = 0, - STATUS_TOO_LOW = 1, STATUS_LOW = 2, - STATUS_WRONG = 3, STATUS_OK = 4, - STATUS_TOO_HIGH = 5, STATUS_HIGH = 6; - // 0,2,4,6 - ok - // 1,3,5 - nok - - //TO ENABLE this change value in to false and/or other than 0, can also be added in recipe check or whatever - public boolean eParameters = true, ePowerPass = false, eSafeVoid = false, eDismantleBoom = false; - public byte eCertainMode = 0, eCertainStatus = 0, minRepairStatus = 3; - - protected long eMaxAmpereFlow = 0;//don't modify! unless YOU REALLY HAVE TO - private long maxEUinputMin = 0, maxEUinputMax = 0; - - public long eAmpereFlow = 1; // analogue of EU/t but for amperes used (so eu/t is actually eu*A/t) USE ONLY POSITIVE NUMBERS! - - public long eRequiredData = 0; // data required to operate - protected long eAvailableData = 0; // data being available - - private boolean explodedThisTick=false; - - //init param states in constructor, or implement it in checkrecipe/outputfunction - - //METHODS TO OVERRIDE - - //if you want to add checks that run periodically when machine works then make onRunningTick better - //if you want to add checks that run periodically when machine is built then use check params - - public boolean checkRecipe_EM(ItemStack itemStack, boolean noParametrizers) { - return false; - } - // My code handles AMPS, if you want overclocking just modify mEUt and mMaxProgressTime, leave amps as usual! - // Set mEUt, Efficiencies, required computation, time, check input etc. - - public void updateParameters_EM(boolean busy) { - } - // update status of parameters in guis and "machine state" - // Called before check recipe, before outputting, and every second the machine is active - - public void outputAfterRecipe_EM() { - } - // based on "machine state" do output, - // this must move to outputEM to EM output hatches - // and can also modify output items/fluids/EM, remaining EM is NOT overflowed. - // (Well it can be overflowed if machine didn't finished, soft-hammered/disabled/not enough EU) - // Setting available data processing - - protected void hatchInit_EM() { - }//For extra types of hatches initiation, LOOK HOW IT IS CALLED! onPostTick - - protected void extraExplosions_EM() { - }//For that extra hatches explosions, and maybe some MOORE EXPLOSIONS - - //machine structure check - protected boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - return false; - } - - //Get Available data, Override only on data producers should return mAvailableData that is set in check recipe - protected long getAvailableData_EM() { - long result = 0; - final Vec3pos pos = new Vec3pos(getBaseMetaTileEntity()); - for (GT_MetaTileEntity_Hatch_InputData in : eInputData) - if (in.q != null) result += in.q.computationIfNotContained(pos); - return result; - } - - //Extra hook on cyclic updates (not really needed for machines smaller than 1 chunk) - //BUT NEEDED WHEN - machine blocks are not touching each other ot they don't implement IMachineBlockUpdateable (ex. air) - protected boolean cyclicUpdate_EM() { - return mUpdate <= -1000;//set to false to disable cyclic update - //default is once per 50s; mUpdate is decremented every tick - } - - @Override - public int getPollutionPerTick(ItemStack itemStack) { - return 0; - } - - public int getPollutionPerTick_EM(ItemStack itemStack) { - return 0; - } - - //triggered if machine is not allowed to work after completing a recipe - protected void notAllowedToWork_stopMachine_EM(){ - stopMachine(); - } - - //Override if needed but usually call super method at start! - //On machine stop - NOT called when softhammered to offline state! - it SHOULD cause a full stop like power failure does - @Override - public void stopMachine() { - if (outputEM != null) { - float mass = 0; - for (cElementalInstanceStackMap tree : outputEM) - mass += tree.getMass(); - if (mass > 0) { - if (eMufflerHatches.size() < 1) explodeMultiblock(); - else { - mass /= eMufflerHatches.size(); - for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) - if (dump.addOverflowMatter(mass)) explodeMultiblock(); - } - } - outputEM = null; - } - - for (GT_MetaTileEntity_Hatch_OutputData data : eOutputData) - data.q = null; - - mOutputItems = null; - mOutputFluids = null; - mEfficiency = 0; - mProgresstime = 0; - mMaxProgresstime = 0; - mEfficiencyIncrease = 0; - getBaseMetaTileEntity().disableWorking(); - hatchesStatusUpdate_EM(); - } - - @Override - public String[] getDescription() { - return new String[]{ - CommonValues.TEC_MARK_GENERAL, - "Nothing special just override me." - }; - } - - //RATHER LEAVE ALONE Section - protected boolean areChunksAroundLoaded_EM(){ - if(isValidMetaTileEntity(this) && getBaseMetaTileEntity().isServerSide()){ - IGregTechTileEntity base=getBaseMetaTileEntity(); - return base.getWorld().doChunksNearChunkExist(base.getXCoord(),base.getYCoord(),base.getZCoord(),3); - //todo check if it is actually checking if chunks are loaded - }else return false; - } - - public GT_MetaTileEntity_MultiblockBase_EM(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GT_MetaTileEntity_MultiblockBase_EM(String aName) { - super(aName); - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "EMDisplay.png"); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister aBlockIconRegister) { - ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/EM_CONTROLLER"); - ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/EM_CONTROLLER_ACTIVE"); - super.registerIcons(aBlockIconRegister); - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][4], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; - return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][4]}; - } - - @Override - public byte getTileEntityBaseType() { - return 3; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - - aNBT.setLong("eMaxEUmin", maxEUinputMin); - aNBT.setLong("eMaxEUmax", maxEUinputMax); - aNBT.setLong("eRating", eAmpereFlow); - aNBT.setLong("eMaxA", eMaxAmpereFlow); - aNBT.setLong("eDataR", eRequiredData); - aNBT.setLong("eDataA", eAvailableData); - aNBT.setByte("eCertainM", eCertainMode); - aNBT.setByte("eCertainS", eCertainStatus); - aNBT.setByte("eMinRepair", minRepairStatus); - aNBT.setBoolean("eParam", eParameters); - aNBT.setBoolean("ePass", ePowerPass); - aNBT.setBoolean("eVoid", eSafeVoid); - aNBT.setBoolean("eBoom", eDismantleBoom); - aNBT.setBoolean("eOK", mMachine); - - //Ensures compatibility - if (mOutputItems != null) { - aNBT.setInteger("mOutputItemsLength", mOutputItems.length); - for (int i = 0; i < mOutputItems.length; i++) - if (mOutputItems[i] != null) { - NBTTagCompound tNBT = new NBTTagCompound(); - mOutputItems[i].writeToNBT(tNBT); - aNBT.setTag("mOutputItem" + i, tNBT); - } - } - - //Ensures compatibility - if (mOutputFluids != null) { - aNBT.setInteger("mOutputFluidsLength", mOutputFluids.length); - for (int i = 0; i < mOutputFluids.length; i++) - if (mOutputFluids[i] != null) { - NBTTagCompound tNBT = new NBTTagCompound(); - mOutputFluids[i].writeToNBT(tNBT); - aNBT.setTag("mOutputFluids" + i, tNBT); - } - } - - if (outputEM != null) { - aNBT.setInteger("outputStackCount", outputEM.length); - NBTTagCompound output = new NBTTagCompound(); - for (int i = 0; i < outputEM.length; i++) - output.setTag(Integer.toString(i), outputEM[i].toNBT()); - aNBT.setTag("outputEM", output); - } else { - aNBT.setInteger("outputStackCount", 0); - aNBT.removeTag("outputEM"); - } - - NBTTagCompound paramI = new NBTTagCompound(); - for (int i = 0; i < iParamsIn.length; i++) - paramI.setInteger(Integer.toString(i), iParamsIn[i]); - aNBT.setTag("eParamsIn", paramI); - - NBTTagCompound paramO = new NBTTagCompound(); - for (int i = 0; i < iParamsOut.length; i++) - paramO.setInteger(Integer.toString(i), iParamsOut[i]); - aNBT.setTag("eParamsOut", paramO); - - NBTTagCompound paramB = new NBTTagCompound(); - for (int i = 0; i < bParamsAreFloats.length; i++) - paramB.setBoolean(Integer.toString(i), bParamsAreFloats[i]); - aNBT.setTag("eParamsB", paramB); - - NBTTagCompound paramIs = new NBTTagCompound(); - for (int i = 0; i < eParamsInStatus.length; i++) - paramIs.setByte(Integer.toString(i), eParamsInStatus[i]); - aNBT.setTag("eParamsInS", paramIs); - - NBTTagCompound paramOs = new NBTTagCompound(); - for (int i = 0; i < eParamsOutStatus.length; i++) - paramOs.setByte(Integer.toString(i), eParamsOutStatus[i]); - aNBT.setTag("eParamsOutS", paramOs); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - - maxEUinputMin = aNBT.getLong("eMaxEUmin"); - maxEUinputMax = aNBT.getLong("eMaxEUmax"); - eAmpereFlow = aNBT.getLong("eRating"); - eMaxAmpereFlow = aNBT.getLong("eMaxA"); - eRequiredData = aNBT.getLong("eDataR"); - eAvailableData = aNBT.getLong("eDataA"); - eCertainMode = aNBT.getByte("eCertainM"); - eCertainStatus = aNBT.getByte("eCertainS"); - minRepairStatus = aNBT.getByte("eMinRepair"); - eParameters = aNBT.getBoolean("eParam"); - ePowerPass = aNBT.getBoolean("ePass"); - eSafeVoid = aNBT.getBoolean("eVoid"); - eDismantleBoom = aNBT.getBoolean("eBoom"); - mMachine = aNBT.getBoolean("eOK"); - - //Ensures compatibility - int aOutputItemsLength = aNBT.getInteger("mOutputItemsLength"); - if (aOutputItemsLength > 0) { - mOutputItems = new ItemStack[aOutputItemsLength]; - for (int i = 0; i < mOutputItems.length; i++) - mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); - } - - //Ensures compatibility - int aOutputFluidsLength = aNBT.getInteger("mOutputFluidsLength"); - if (aOutputFluidsLength > 0) { - mOutputFluids = new FluidStack[aOutputFluidsLength]; - for (int i = 0; i < mOutputFluids.length; i++) - mOutputFluids[i] = GT_Utility.loadFluid(aNBT, "mOutputFluids" + i); - } - - final int outputLen = aNBT.getInteger("outputStackCount"); - if (outputLen > 0) { - outputEM = new cElementalInstanceStackMap[outputLen]; - for (int i = 0; i < outputEM.length; i++) - try { - outputEM[i] = cElementalInstanceStackMap.fromNBT( - aNBT.getCompoundTag("outputEM").getCompoundTag(Integer.toString(i))); - } catch (tElementalException e) { - if (DEBUG_MODE) e.printStackTrace(); - outputEM[i] = new cElementalInstanceStackMap(); - } - } else outputEM = new cElementalInstanceStackMap[0]; - - NBTTagCompound paramI = aNBT.getCompoundTag("eParamsIn"); - for (int i = 0; i < iParamsIn.length; i++) - iParamsIn[i] = paramI.getInteger(Integer.toString(i)); - - NBTTagCompound paramO = aNBT.getCompoundTag("eParamsOut"); - for (int i = 0; i < iParamsOut.length; i++) - iParamsOut[i] = paramO.getInteger(Integer.toString(i)); - - NBTTagCompound paramB = aNBT.getCompoundTag("eParamsB"); - for (int i = 0; i < bParamsAreFloats.length; i++) - bParamsAreFloats[i] = paramB.getBoolean(Integer.toString(i)); - - NBTTagCompound paramIs = aNBT.getCompoundTag("eParamsInS"); - for (int i = 0; i < eParamsInStatus.length; i++) - eParamsInStatus[i] = paramIs.getByte(Integer.toString(i)); - - NBTTagCompound paramOs = aNBT.getCompoundTag("eParamsOutS"); - for (int i = 0; i < eParamsOutStatus.length; i++) - eParamsOutStatus[i] = paramOs.getByte(Integer.toString(i)); - } - - private boolean cyclicUpdate() { - if (cyclicUpdate_EM()) { - mUpdate = 0; - return true; - } - return false; - } - - //Param methods - public final boolean isParametrizerUsingFloat(int hatchNo){ - return bParamsAreFloats[hatchNo]; - } - - public final double getParameterInSafely(int hatchNo, int paramID){ - return bParamsAreFloats[hatchNo]?Float.intBitsToFloat(iParamsIn[hatchNo+10*paramID]):iParamsIn[hatchNo+10*paramID]; - } - - public final int getParameterInInt(int hatchNo, int paramID){ - return iParamsIn[hatchNo+10*paramID]; - } - - public final float getParameterInFloat(int hatchNo, int paramID){ - return Float.intBitsToFloat(iParamsIn[hatchNo+10*paramID]); - } - - public final void setParameterOutSafely(int hatchNo, int paramID, double value){ - if(bParamsAreFloats[hatchNo]) { - iParamsOut[hatchNo+10*paramID]=Float.floatToIntBits((float) value); - }else{ - iParamsOut[hatchNo+10*paramID]=(int)value; - } - } - - public final boolean setParameterOutInt(int hatchNo, int paramID, int value){ - if(bParamsAreFloats[hatchNo]) return false; - iParamsOut[hatchNo+10*paramID]=value; - return true; - } - - public final boolean setParameterOutFloat(int hatchNo, int paramID, float value){ - if(bParamsAreFloats[hatchNo]) { - iParamsOut[hatchNo + 10 * paramID] = Float.floatToIntBits(value); - return true; - } - return false; - } - - public final byte getStatusOfParameterIn(int hatchNo, int paramID){ - return eParamsInStatus[hatchNo+10*paramID]; - } - - public final void setStatusOfParameterIn(int hatchNo, int paramID, byte status){ - eParamsInStatus[hatchNo+10*paramID]=status; - } - - public final byte getStatusOfParameterOut(int hatchNo, int paramID){ - return eParamsOutStatus[hatchNo+10*paramID]; - } - - public final void setStatusOfParameterOut(int hatchNo, int paramID, byte status){ - eParamsOutStatus[hatchNo+10*paramID]=status; - } - - @Override - public final boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - return checkMachine_EM(iGregTechTileEntity, itemStack); - } - - //can be used to check structures of multi-blocks larger than one chunk, but... - //ALL THE HATCHES AND THE CONTROLLER SHOULD BE IN ONE CHUNK OR IN LOADED CHUNKS - @Deprecated - public final boolean structureCheck_EM( - String[][] structure,//0-9 casing, +- air no air, a-z ignore - Block[] blockType,//use numbers 0-9 for casing types - byte[] blockMeta,//use numbers 0-9 for casing types - int horizontalOffset, int verticalOffset, int depthOffset) { - return StructureChecker(structure, blockType, blockMeta, - horizontalOffset, verticalOffset, depthOffset, getBaseMetaTileEntity(), !mMachine); - } - - public final boolean structureCheck_EM( - String[][] structure,//0-9 casing, +- air no air, a-z ignore - Block[] blockType,//use numbers 0-9 for casing types - byte[] blockMeta,//use numbers 0-9 for casing types - String[] addingMethods, - short[] casingTextures, - Block[] blockTypeFallback,//use numbers 0-9 for casing types - byte[] blockMetaFallback,//use numbers 0-9 for casing types - int horizontalOffset, int verticalOffset, int depthOffset) { - return StructureCheckerAdvanced(structure, blockType, blockMeta, - adderMethod, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, - horizontalOffset, verticalOffset, depthOffset, getBaseMetaTileEntity(), !mMachine); - } - - //CAREFUL!!! it calls most of the callbacks - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - explodedThisTick=false; - if (mEfficiency < 0) mEfficiency = 0; - - if (--mUpdate == 0 || --mStartUpCheck == 0 || cyclicUpdate() || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) { - mInputHatches.clear(); - mInputBusses.clear(); - mOutputHatches.clear(); - mOutputBusses.clear(); - mDynamoHatches.clear(); - mEnergyHatches.clear(); - mMufflerHatches.clear(); - mMaintenanceHatches.clear(); - - for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eOutputHatches) - if (isValidMetaTileEntity(hatch_elemental)) hatch_elemental.id = -1; - for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eInputHatches) - if (isValidMetaTileEntity(hatch_elemental)) hatch_elemental.id = -1; - - for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eOutputData) - if (isValidMetaTileEntity(hatch_data)) hatch_data.id = -1; - for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eInputData) - if (isValidMetaTileEntity(hatch_data)) hatch_data.id = -1; - - for (GT_MetaTileEntity_Hatch_Uncertainty hatch : eUncertainHatches) - if (isValidMetaTileEntity(hatch)) hatch.getBaseMetaTileEntity().setActive(false); - for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) - if (isValidMetaTileEntity(hatch)) hatch.getBaseMetaTileEntity().setActive(false); - - eUncertainHatches.clear(); - eEnergyMulti.clear(); - eInputHatches.clear(); - eOutputHatches.clear(); - eParamHatches.clear(); - eMufflerHatches.clear(); - eDynamoMulti.clear(); - eOutputData.clear(); - eInputData.clear(); - - if ((getBaseMetaTileEntity() instanceof BaseTileEntity)) - ((BaseTileEntity) getBaseMetaTileEntity()).ignoreUnloadedChunks = mMachine; - mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); - - if (!mMachine) { - if ((ePowerPass && getEUVar() > V[3]) || (eDismantleBoom && mMaxProgresstime > 0 && areChunksAroundLoaded_EM())) - explodeMultiblock(); - if (outputEM != null) - for (cElementalInstanceStackMap tree : outputEM) - if (tree.hasStacks()) explodeMultiblock(); - } - - if (eUncertainHatches.size() > 1) mMachine = false; - - if (mMachine) { - short id = 1; - for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eOutputHatches) - if (isValidMetaTileEntity(hatch_elemental)) hatch_elemental.id = id++; - id = 1; - for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eInputHatches) - if (isValidMetaTileEntity(hatch_elemental)) hatch_elemental.id = id++; - - id = 1; - for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eOutputData) - if (isValidMetaTileEntity(hatch_data)) hatch_data.id = id++; - id = 1; - for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eInputData) - if (isValidMetaTileEntity(hatch_data)) hatch_data.id = id++; - - if (mEnergyHatches.size() > 0 || eEnergyMulti.size() > 0) { - maxEUinputMin = V[15]; - maxEUinputMax = V[0]; - for (GT_MetaTileEntity_Hatch_Energy hatch : mEnergyHatches) - if (isValidMetaTileEntity(hatch)) { - if (hatch.maxEUInput() < maxEUinputMin) maxEUinputMin = hatch.maxEUInput(); - if (hatch.maxEUInput() > maxEUinputMax) maxEUinputMax = hatch.maxEUInput(); - } - for (GT_MetaTileEntity_Hatch_EnergyMulti hatch : eEnergyMulti) - if (isValidMetaTileEntity(hatch)) { - if (hatch.maxEUInput() < maxEUinputMin) maxEUinputMin = hatch.maxEUInput(); - if (hatch.maxEUInput() > maxEUinputMax) maxEUinputMax = hatch.maxEUInput(); - } - eMaxAmpereFlow = 0; - //counts only full amps - for (GT_MetaTileEntity_Hatch_Energy hatch : mEnergyHatches) - if (isValidMetaTileEntity(hatch)) eMaxAmpereFlow += hatch.maxEUInput() / maxEUinputMin; - for (GT_MetaTileEntity_Hatch_EnergyMulti hatch : eEnergyMulti) - if (isValidMetaTileEntity(hatch)) - eMaxAmpereFlow += (hatch.maxEUInput() / maxEUinputMin) * hatch.Amperes; - if (this.getEUVar() > maxEUStore()) this.setEUVar(this.maxEUStore()); - } else { - maxEUinputMin = 0; - maxEUinputMax = 0; - eMaxAmpereFlow = 0; - this.setEUVar(0); - } - - for (GT_MetaTileEntity_Hatch_Uncertainty hatch : eUncertainHatches) - if (isValidMetaTileEntity(hatch)) hatch.getBaseMetaTileEntity().setActive(true); - for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches){ - if (isValidMetaTileEntity(hatch)) { - hatch.getBaseMetaTileEntity().setActive(true); - if(hatch.param>=0) bParamsAreFloats[hatch.param]=hatch.isUsingFloats(); - } - } - } else { - maxEUinputMin = 0; - maxEUinputMax = 0; - eMaxAmpereFlow = 0; - this.setEUVar(0); - } - hatchInit_EM(); - } - - if (mStartUpCheck < 0) {//E - if (mMachine) {//S - final byte Tick = (byte) (aTick % 20); - if (MULTI_PURGE_1_AT == Tick || MULTI_PURGE_2_AT == Tick) - purgeAllOverflowEM_EM(); - else if (MULTI_CHECK_AT == Tick) - for (GT_MetaTileEntity_Hatch_Maintenance tHatch : mMaintenanceHatches) { - if (isValidMetaTileEntity(tHatch)) { - if (disableMaintenance) { - mWrench = true; - mScrewdriver = true; - mSoftHammer = true; - mHardHammer = true; - mSolderingTool = true; - mCrowbar = true; - } else { - if (tHatch.mAuto && !(mWrench && mScrewdriver && mSoftHammer && mHardHammer && mSolderingTool && mCrowbar)) - tHatch.autoMaintainance(); - if (tHatch.mWrench) mWrench = true; - if (tHatch.mScrewdriver) mScrewdriver = true; - if (tHatch.mSoftHammer) mSoftHammer = true; - if (tHatch.mHardHammer) mHardHammer = true; - if (tHatch.mSolderingTool) mSolderingTool = true; - if (tHatch.mCrowbar) mCrowbar = true; - - tHatch.mWrench = false; - tHatch.mScrewdriver = false; - tHatch.mSoftHammer = false; - tHatch.mHardHammer = false; - tHatch.mSolderingTool = false; - tHatch.mCrowbar = false; - } - } - } - else if (MOVE_AT == Tick && eSafeVoid) { - for (GT_MetaTileEntity_Hatch_MufflerElemental voider : eMufflerHatches) { - if (voider.overflowMax < voider.getOverflowMatter()) continue; - float remaining = voider.overflowMax - voider.getOverflowMatter(); - for (GT_MetaTileEntity_Hatch_InputElemental in : eInputHatches) { - for (cElementalInstanceStack instance : in.getContainerHandler().values()) { - long qty = (long) Math.floor(remaining / instance.definition.getMass()); - if (qty > 0) { - qty = Math.min(qty, instance.amount); - if (voider.addOverflowMatter(instance.definition.getMass() * qty)) - voider.setOverflowMatter(voider.overflowMax); - in.getContainerHandler().removeAmount(false, new cElementalDefinitionStack(instance.definition, qty)); - } - } - } - for (GT_MetaTileEntity_Hatch_OutputElemental out : eOutputHatches) { - for (cElementalInstanceStack instance : out.getContainerHandler().values()) { - long qty = (long)Math.floor(remaining / instance.definition.getMass()); - if (qty > 0) { - qty = Math.min(qty, instance.amount); - if (voider.addOverflowMatter(instance.definition.getMass() * qty)) - voider.setOverflowMatter(voider.overflowMax); - out.getContainerHandler().removeAmount(false, new cElementalDefinitionStack(instance.definition, qty)); - } - } - } - } - } - - if (getRepairStatus() >= minRepairStatus) {//S - if (MULTI_CHECK_AT == Tick) - hatchesStatusUpdate_EM(); - - //region power pass and controller charging - {//DO - long euVar; - for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { - if (this.getEUVar() > this.getMinimumStoredEU()) break; - if (isValidMetaTileEntity(tHatch)) { - euVar = tHatch.maxEUInput(); - if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euVar, false)) - this.setEUVar(this.getEUVar() + euVar); - } - } - for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) { - if (this.getEUVar() > this.getMinimumStoredEU()) break; - if (isValidMetaTileEntity(tHatch)) { - euVar = tHatch.maxEUInput() * tHatch.Amperes; - if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euVar, false)) - this.setEUVar(this.getEUVar() + euVar); - } - } - if (ePowerPass) { - for (GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) { - if (isValidMetaTileEntity(tHatch)) { - euVar = tHatch.maxEUOutput(); - if (tHatch.getBaseMetaTileEntity().getStoredEU() <= (tHatch.maxEUStore() - euVar) && - aBaseMetaTileEntity.decreaseStoredEnergyUnits(euVar + Math.min(euVar >> 7,1), false)) - tHatch.setEUVar(tHatch.getBaseMetaTileEntity().getStoredEU() + euVar); - } - } - for (GT_MetaTileEntity_Hatch_DynamoMulti tHatch : eDynamoMulti) { - if (isValidMetaTileEntity(tHatch)) { - euVar = tHatch.maxEUOutput() * tHatch.Amperes; - if (tHatch.getBaseMetaTileEntity().getStoredEU() <= tHatch.maxEUStore() - euVar && - aBaseMetaTileEntity.decreaseStoredEnergyUnits(euVar + Math.min(euVar >> 7,tHatch.Amperes), false)) - tHatch.setEUVar(tHatch.getBaseMetaTileEntity().getStoredEU() + euVar); - } - } - } - } - //endregion - - if (mMaxProgresstime > 0 && doRandomMaintenanceDamage()) {//Start - if (onRunningTick(mInventory[1])) {//Compute EU - if (!polluteEnvironment(getPollutionPerTick(mInventory[1]))) stopMachine(); - if (!polluteEnvironment_EM(getPollutionPerTick_EM(mInventory[1]))) stopMachine(); - - if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime && RECIPE_AT == Tick) {//progress increase and done - hatchesStatusUpdate_EM(); - - outputAfterRecipe_EM(); - cleanOutputEM_EM(); - - if (mOutputItems != null) for (ItemStack tStack : mOutputItems) - if (tStack != null) addOutput(tStack); - mOutputItems = null; - - if (mOutputFluids != null) { - if (mOutputFluids.length == 1) { - for (FluidStack tStack : mOutputFluids) - if (tStack != null) addOutput(tStack); - } else if (mOutputFluids.length > 1) addFluidOutputs(mOutputFluids); - } - mOutputFluids = null; - - updateSlots(); - mProgresstime = 0; - mMaxProgresstime = 0; - mEfficiencyIncrease = 0; - if (aBaseMetaTileEntity.isAllowedToWork()) { - if (checkRecipe(mInventory[1])) { - mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); - }else { - mMaxProgresstime=0; - } - updateSlots(); - } else notAllowedToWork_stopMachine_EM(); - } - }// else {//failed to consume power/resources - inside on running tick - // stopMachine(); - //} - } else if (RECIPE_AT == Tick || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) { - if (aBaseMetaTileEntity.isAllowedToWork()) { - if (checkRecipe(mInventory[1])) { - mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); - }else { - mMaxProgresstime=0; - } - updateSlots(); - } //else notAllowedToWork_stopMachine_EM(); //it is already stopped here - } - } else {//not repaired - stopMachine(); - } - } else {//not complete - stopMachine(); - } - } - - aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & -512) | (mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8) | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64) | ((eCertainStatus == 0) ? 0 : 128) | (eParameters ? 0 : 256)); - aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); - boolean active = aBaseMetaTileEntity.isActive() && mPollution > 0; - for (GT_MetaTileEntity_Hatch_Muffler aMuffler : mMufflerHatches) - aMuffler.getBaseMetaTileEntity().setActive(active); - } - } - - public boolean polluteEnvironment_EM(int aPollutionLevel) { - return true; //TODO - } - - @Deprecated - public final int getAmountOfOutputs() { - throw new NoSuchMethodError("Deprecated Do not use"); - } - - @Override - protected void addFluidOutputs(FluidStack[] mOutputFluids) { - int min=mOutputFluids.length>mOutputHatches.size()?mOutputHatches.size():mOutputFluids.length; - for (int i = 0; i < min; ++i) { - if (this.mOutputHatches.get(i) != null && mOutputFluids[i] != null && isValidMetaTileEntity(this.mOutputHatches.get(i))) { - this.mOutputHatches.get(i).fill(mOutputFluids[i], true); - } - } - } - - @Override - public int getMaxEfficiency(ItemStack itemStack) { - return 10000; - } - - @Override - public int getIdealStatus() { - return super.getIdealStatus() + 2; - } - - @Override - public int getRepairStatus() { - return super.getRepairStatus() + ((eCertainStatus == 0) ? 1 : 0) + (this.eParameters ? 1 : 0); - } - - @Override - public boolean onRunningTick(ItemStack aStack) { - if (eRequiredData > eAvailableData) { - if(energyFlow(aStack,false)) - stopMachine(); - return false; - } - return energyFlow(aStack,true); - } - - //new method - private boolean energyFlow(ItemStack aStack,boolean allowProduction) { - long temp = mEUt * eAmpereFlow;//quick scope sign - if (allowProduction && temp > 0) { - this.addEnergyOutput_EM((long) mEUt * (long) mEfficiency / getMaxEfficiency(aStack), eAmpereFlow); - } else if (temp < 0) { - if (!this.drainEnergyInput_EM(mEUt,(long) mEUt * getMaxEfficiency(aStack) / Math.max(1000L, this.mEfficiency), eAmpereFlow)) { - stopMachine(); - return false; - } - } - return true; - } - - //region energy - public final boolean energyFlowWithoutEffieciencyComputation(int eu,long ampere) { - long temp = eu * ampere;//quick scope sign - if (temp > 0) { - this.addEnergyOutput_EM(eu, ampere); - } else if (temp < 0) { - if (!this.drainEnergyInput_EM(eu,eu, ampere)) { - stopMachine(); - return false; - } - } - return true; - } - - @Override - public final long maxEUStore() { - return (maxEUinputMin * eMaxAmpereFlow) << 3; - } - - @Override - public final long getMinimumStoredEU() { - return maxEUStore() >> 1; - } - - @Override - public final long maxAmperesIn() { - return 0L; - } - - @Override - public final long maxAmperesOut() { - return 0L; - } - - @Deprecated - @Override - public final boolean addEnergyOutput(long EU) { - if (EU <= 0L) return true; - for (GT_MetaTileEntity_Hatch tHatch : eDynamoMulti) - if (isValidMetaTileEntity(tHatch)){ - if(tHatch.maxEUOutput() 0) { - if (euVar > diff) { - tHatch.setEUVar(tHatch.maxEUStore()); - euVar -= diff; - } else if (euVar <= diff) { - tHatch.setEUVar(tHatch.getBaseMetaTileEntity().getStoredEU() + euVar); - return true; - } - } - } - } - for (GT_MetaTileEntity_Hatch_DynamoMulti tHatch : eDynamoMulti) { - if (isValidMetaTileEntity(tHatch)) { - if (tHatch.maxEUOutput() < EU) explodeMultiblock(); - diff = tHatch.maxEUStore() - tHatch.getBaseMetaTileEntity().getStoredEU(); - if (diff > 0) { - if (euVar > diff) { - tHatch.setEUVar(tHatch.maxEUStore()); - euVar -= diff; - } else if (euVar <= diff) { - tHatch.setEUVar(tHatch.getBaseMetaTileEntity().getStoredEU() + euVar); - return true; - } - } - } - } - return false; - } - - @Deprecated - @Override - public final boolean drainEnergyInput(long EU) { - if (EU <= 0L) return true; - for (GT_MetaTileEntity_Hatch tHatch : eEnergyMulti) - if (isValidMetaTileEntity(tHatch) && tHatch.maxEUInput()>EU && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(EU, false)) - return true; - for (GT_MetaTileEntity_Hatch tHatch : mEnergyHatches) - if (isValidMetaTileEntity(tHatch) && tHatch.maxEUInput()>EU && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(EU, false)) - return true; - return false; - } - - private boolean drainEnergyInput_EM(long EUt, long EUtEff, long Amperes) { - if(EUt<0) EUt=-EUt; - if(EUtEff<0) EUtEff=-EUtEff; - if(Amperes<0) Amperes=-Amperes; - long EUuse = EUtEff * Amperes; - if (EUuse > getEUVar() || //not enough power - EUt > maxEUinputMax || //TIER IS BASED ON BEST HATCH! not total EUtEff input - ((EUt*Amperes) - 1) / maxEUinputMin + 1 > eMaxAmpereFlow) {// EUuse==0? --> (EUuse - 1) / maxEUinputMin + 1 = 1! //if not too much A - if (DEBUG_MODE) { - TecTech.Logger.debug("L1 " + EUuse + " " + getEUVar() + " " + (EUuse > getEUVar())); - TecTech.Logger.debug("L2 " + EUtEff + " " + maxEUinputMax + " " + (EUtEff > maxEUinputMax)); - TecTech.Logger.debug("L3 " + EUuse + " " + eMaxAmpereFlow); - TecTech.Logger.debug("L4 " + ((EUuse - 1) / maxEUinputMin + 1) + " " + eMaxAmpereFlow + " " + ((EUuse - 1) / maxEUinputMin + 1 > eMaxAmpereFlow)); - } - return false; - } - //sub eu - setEUVar(getEUVar() - EUuse); - return true; - } - - //new method - public final boolean overclockAndPutValuesIn_EM(long EU, int time) {//TODO revise - if (EU == 0L) { - mEUt = 0; - mMaxProgresstime = time; - return true; - } - long tempEUt = EU < V[1] ? V[1] : EU; - long tempTier = maxEUinputMax >> 2; - while (tempEUt < tempTier) { - tempEUt <<= 2; - time >>= 1; - EU = time == 0 ? EU >> 1 : EU << 2;//U know, if the time is less than 1 tick make the machine use less power - } - if (EU > Integer.MAX_VALUE || EU < Integer.MIN_VALUE) { - mEUt = Integer.MAX_VALUE - 1; - mMaxProgresstime = Integer.MAX_VALUE - 1; - return false; - } - mEUt = (int) EU; - mMaxProgresstime = time == 0 ? 1 : time; - return true; - }//Use in EM check recipe return statement if you want overclocking - - @Override // same as gt sum of all hatches - public final long getMaxInputVoltage() { - long rVoltage = 0; - for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) - if (isValidMetaTileEntity(tHatch)) rVoltage += tHatch.maxEUInput(); - for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) - if (isValidMetaTileEntity(tHatch)) rVoltage += tHatch.maxEUInput(); - return rVoltage; - } - - //new Method - public final long getMaxInputEnergy(){ - long energy = 0; - for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) - if (isValidMetaTileEntity(tHatch)) energy += tHatch.maxEUInput(); - for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) - if (isValidMetaTileEntity(tHatch)) energy += tHatch.maxEUInput() * tHatch.Amperes; - return energy; - } - - //new Method - public final int getMaxEnergyInputTier_EM() { - return Util.getTier(maxEUinputMax); - } - - //new Method - public final int getMinEnergyInputTier_EM() { - return Util.getTier(maxEUinputMin); - } - - public final long getMaxAmpereFlowAtMinTierOfEnergyHatches(){ - return eAmpereFlow; - } - - //endregion - - //new Method - public final cElementalInstanceStackMap getInputsClone_EM(){ - cElementalInstanceStackMap in=new cElementalInstanceStackMap(); - for(GT_MetaTileEntity_Hatch_ElementalContainer hatch:eInputHatches){ - in.putUnifyAll(hatch.getContainerHandler()); - } - return in.hasStacks()?in:null; - } - - //new Method - public final cElementalInstanceStackMap getOutputsClone_EM(){ - cElementalInstanceStackMap out=new cElementalInstanceStackMap(); - for(GT_MetaTileEntity_Hatch_ElementalContainer hatch:eOutputHatches){ - out.putUnifyAll(hatch.getContainerHandler()); - } - return out.hasStacks()?out:null; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return null; - } - - @Override - public void updateSlots() { - super.updateSlots(); - purgeAllOverflowEM_EM(); - } - - //region em cleaning - private void purgeAllOverflowEM_EM() { - float mass = 0; - for (GT_MetaTileEntity_Hatch_InputElemental tHatch : eInputHatches) { - if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); - mass += tHatch.overflowMatter; - tHatch.overflowMatter = 0; - } - for (GT_MetaTileEntity_Hatch_OutputElemental tHatch : eOutputHatches) { - if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); - mass += tHatch.overflowMatter; - tHatch.overflowMatter = 0; - } - if (mass > 0) { - if (eMufflerHatches.size() < 1) explodeMultiblock(); - mass /= eMufflerHatches.size(); - for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) - if (dump.addOverflowMatter(mass)) explodeMultiblock(); - } - } - - public void cleanHatchContentEM_EM(GT_MetaTileEntity_Hatch_ElementalContainer target) { - if (target == null) return; - float mass = target.getContainerHandler().getMass(); - if (mass > 0) { - if (eMufflerHatches.size() < 1) explodeMultiblock(); - mass /= eMufflerHatches.size(); - for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) - if (dump.addOverflowMatter(mass)) explodeMultiblock(); - } - } - - public void cleanStackEM_EM(cElementalInstanceStack target) { - if (target == null) return; - cleanMassEM_EM(target.getMass()); - } - - public void cleanMassEM_EM(float mass) { - if (mass > 0) { - if (eMufflerHatches.size() < 1) explodeMultiblock(); - mass /= eMufflerHatches.size(); - for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) - if (dump.addOverflowMatter(mass)) explodeMultiblock(); - } - } - - private void cleanOutputEM_EM() { - if (outputEM == null) return; - float mass = 0; - for (cElementalInstanceStackMap map : outputEM) - mass = map.removeOverflow(0, 0); - - if (mass > 0) { - if (eMufflerHatches.size() < 1) explodeMultiblock(); - mass /= eMufflerHatches.size(); - for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) - if (dump.addOverflowMatter(mass)) explodeMultiblock(); - } - outputEM = null; - } - //endregion - - @Override - public final boolean checkRecipe(ItemStack itemStack) {//do recipe checks, based on "machine content and state" - hatchesStatusUpdate_EM(); - return checkRecipe_EM(itemStack, eParamHatches.size()==0); - } - - private void hatchesStatusUpdate_EM() { - for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) { - if (!isValidMetaTileEntity(hatch) || hatch.param < 0) continue; - final int paramID = hatch.param; - iParamsIn[paramID] = hatch.value0i; - iParamsIn[paramID + 10] = hatch.value1i; - hatch.input0i = iParamsOut[paramID]; - hatch.input1i = iParamsOut[paramID + 10]; - bParamsAreFloats[hatch.param]=hatch.isUsingFloats(); - } - updateParameters_EM(mMaxProgresstime>0); - - eAvailableData = getAvailableData_EM(); - - for (GT_MetaTileEntity_Hatch_Uncertainty uncertainty : eUncertainHatches) - eCertainStatus = uncertainty.update(eCertainMode); - } - - @Override - public boolean isCorrectMachinePart(ItemStack itemStack) { - return true; - } - - @Override - public int getDamageToComponent(ItemStack itemStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack itemStack) { - return false; - } - - @Override - public final void explodeMultiblock() { - if(explodedThisTick)return; - explodedThisTick=true; - if (!TecTech.ModConfig.BOOM_ENABLE) { - TecTech.proxy.broadcast("Multi Explode BOOM! " + getBaseMetaTileEntity().getXCoord() + " " + getBaseMetaTileEntity().getYCoord() + " " + getBaseMetaTileEntity().getZCoord()); - StackTraceElement[] ste = Thread.currentThread().getStackTrace(); - TecTech.proxy.broadcast("Multi Explode BOOM! " + ste[2].toString()); - return; - } - extraExplosions_EM(); - GT_Pollution.addPollution(getBaseMetaTileEntity(), 600000); - mInventory[1] = null; - for (MetaTileEntity tTileEntity : mInputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); - for (MetaTileEntity tTileEntity : mOutputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); - for (MetaTileEntity tTileEntity : mInputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); - for (MetaTileEntity tTileEntity : mOutputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); - for (MetaTileEntity tTileEntity : mDynamoHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); - for (MetaTileEntity tTileEntity : mMufflerHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); - for (MetaTileEntity tTileEntity : mEnergyHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); - for (MetaTileEntity tTileEntity : mMaintenanceHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); - for (MetaTileEntity tTileEntity : eParamHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); - for (MetaTileEntity tTileEntity : eInputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); - for (MetaTileEntity tTileEntity : eOutputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); - for (MetaTileEntity tTileEntity : eMufflerHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); - for (MetaTileEntity tTileEntity : eEnergyMulti) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); - for (MetaTileEntity tTileEntity : eUncertainHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); - for (MetaTileEntity tTileEntity : eDynamoMulti) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); - for (MetaTileEntity tTileEntity : eInputData) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); - for (MetaTileEntity tTileEntity : eOutputData) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); - getBaseMetaTileEntity().doExplosion(V[15]); - } - - @Override - public void doExplosion(long aExplosionPower) { - explodeMultiblock(); - super.doExplosion(aExplosionPower); - }//Redirecting to explodemultiblock - - @Override - public void onRemoval() { - try { - if (eOutputHatches != null) { - for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eOutputHatches) - hatch_elemental.id = -1; - for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eInputHatches) - hatch_elemental.id = -1; - for (GT_MetaTileEntity_Hatch_OutputData hatch_data : eOutputData) { - hatch_data.id = -1; - hatch_data.q = null; - } - for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eInputData) - hatch_data.id = -1; - for (GT_MetaTileEntity_Hatch_Uncertainty hatch : eUncertainHatches) - hatch.getBaseMetaTileEntity().setActive(false); - for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) - hatch.getBaseMetaTileEntity().setActive(false); - } - if ((ePowerPass && getEUVar()>V[3]) || (eDismantleBoom && mMaxProgresstime > 0 && areChunksAroundLoaded_EM())) explodeMultiblock(); - if (outputEM != null) - for (cElementalInstanceStackMap output : outputEM) - if (output.hasStacks()) explodeMultiblock(); - } catch (Exception e) { - if (DEBUG_MODE) e.printStackTrace(); - } - } - - //region adder methods - @Override - public final boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) - return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) - return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) - return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) - return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) - return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) - return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) - return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) - return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputElemental) - return eInputHatches.add((GT_MetaTileEntity_Hatch_InputElemental) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputElemental) - return eOutputHatches.add((GT_MetaTileEntity_Hatch_OutputElemental) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) - return eParamHatches.add((GT_MetaTileEntity_Hatch_Param) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Uncertainty) - return eUncertainHatches.add((GT_MetaTileEntity_Hatch_Uncertainty) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MufflerElemental) - return eMufflerHatches.add((GT_MetaTileEntity_Hatch_MufflerElemental) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) - return eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) - return eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputData) - return eInputData.add((GT_MetaTileEntity_Hatch_InputData) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputData) - return eOutputData.add((GT_MetaTileEntity_Hatch_OutputData) aMetaTileEntity); - return false; - } - - public final boolean addClassicToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) - return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) - return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) - return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) - return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) - return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) - return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) - return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) - return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) - return eParamHatches.add((GT_MetaTileEntity_Hatch_Param) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Uncertainty) - return eUncertainHatches.add((GT_MetaTileEntity_Hatch_Uncertainty) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) - return eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) - return eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputData) - return eInputData.add((GT_MetaTileEntity_Hatch_InputData) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputData) - return eOutputData.add((GT_MetaTileEntity_Hatch_OutputData) aMetaTileEntity); - return false; - } - - public final boolean addElementalToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputElemental) - return eInputHatches.add((GT_MetaTileEntity_Hatch_InputElemental) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputElemental) - return eOutputHatches.add((GT_MetaTileEntity_Hatch_OutputElemental) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MufflerElemental) - return eMufflerHatches.add((GT_MetaTileEntity_Hatch_MufflerElemental) aMetaTileEntity); - return false; - } - - public final boolean addClassicMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); - } - return false; - } - - public final boolean addElementalMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MufflerElemental) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return eMufflerHatches.add((GT_MetaTileEntity_Hatch_MufflerElemental) aMetaTileEntity); - } - return false; - } - - @Override - public final boolean addMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MufflerElemental) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return eMufflerHatches.add((GT_MetaTileEntity_Hatch_MufflerElemental) aMetaTileEntity); - } - return false; - } - - @Override - public final boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap(); - return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = getRecipeMap(); - return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputElemental) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - //((GT_MetaTileEntity_Hatch_Elemental) aMetaTileEntity).mRecipeMap = getRecipeMap(); - return eInputHatches.add((GT_MetaTileEntity_Hatch_InputElemental) aMetaTileEntity); - } - return false; - } - - @Override - public final boolean addOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputElemental) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return eOutputHatches.add((GT_MetaTileEntity_Hatch_OutputElemental) aMetaTileEntity); - } - return false; - } - - @Deprecated - @Override - public final boolean addEnergyInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); - } - return false; - } - - @Deprecated - @Override - public final boolean addDynamoToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity); - } - return false; - } - - //New Method - public final boolean addEnergyIOToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity); - } - return false; - } - - //NEW METHOD - public final boolean addElementalInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputElemental) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - //((GT_MetaTileEntity_Hatch_Elemental) aMetaTileEntity).mRecipeMap = getRecipeMap(); - return eInputHatches.add((GT_MetaTileEntity_Hatch_InputElemental) aMetaTileEntity); - } - return false; - } - - //NEW METHOD - public final boolean addElementalOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputElemental) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return eOutputHatches.add((GT_MetaTileEntity_Hatch_OutputElemental) aMetaTileEntity); - } - return false; - } - - //NEW METHOD - public final boolean addClassicInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap(); - return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = getRecipeMap(); - return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); - } - return false; - } - - //NEW METHOD - public final boolean addClassicOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); - } - return false; - } - - //NEW METHOD - public final boolean addParametrizerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return eParamHatches.add((GT_MetaTileEntity_Hatch_Param) aMetaTileEntity); - } - return false; - } - - //NEW METHOD - public final boolean addUncertainToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Uncertainty) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return eUncertainHatches.add((GT_MetaTileEntity_Hatch_Uncertainty) aMetaTileEntity); - } - return false; - } - - @Override - public final boolean addMaintenanceToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return eParamHatches.add((GT_MetaTileEntity_Hatch_Param) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Uncertainty) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return eUncertainHatches.add((GT_MetaTileEntity_Hatch_Uncertainty) aMetaTileEntity); - } - return false; - } - - //NEW METHOD - public final boolean addClassicMaintenanceToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); - } - return false; - } - - //NEW METHOD - public final boolean addDataConnectorToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputData) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return eInputData.add((GT_MetaTileEntity_Hatch_InputData) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputData) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return eOutputData.add((GT_MetaTileEntity_Hatch_OutputData) aMetaTileEntity); - } - return false; - } - //endregion - - public static void run() { - try { - adderMethodMap.put("addToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addClassicToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addElementalToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addElementalToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addMufflerToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addMufflerToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addClassicMufflerToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicMufflerToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addElementalMufflerToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addElementalMufflerToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addInputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addInputToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addOutputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addOutputToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addEnergyInputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addEnergyInputToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addDynamoToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addDynamoToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addEnergyIOToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addEnergyIOToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addElementalInputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addElementalInputToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addElementalOutputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addElementalOutputToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addClassicInputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicInputToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addClassicOutputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicOutputToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addParametrizerToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addParametrizerToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addUncertainToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addUncertainToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addMaintenanceToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addMaintenanceToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addClassicMaintenanceToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicMaintenanceToMachineList", IGregTechTileEntity.class, int.class)); - adderMethodMap.put("addDataConnectorToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addDataConnectorToMachineList", IGregTechTileEntity.class, int.class)); - adderMethod = GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addThing", String.class, IGregTechTileEntity.class, int.class); - } catch (NoSuchMethodException e) { - if (DEBUG_MODE) e.printStackTrace(); - } - } - - //CALLBACK - public boolean addThing(String methodName, IGregTechTileEntity igt, int casing) { - try { - return (boolean) adderMethodMap.get(methodName).invoke(this, igt, casing); - } catch (InvocationTargetException | IllegalAccessException e) { - if (DEBUG_MODE) e.printStackTrace(); - } - return false; - } - - @Override - public String[] getInfoData() {//TODO Do it - long storedEnergy = 0; - long maxEnergy = 0; - for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { - if (isValidMetaTileEntity(tHatch)) { - storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); - maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); - } - } - for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) { - if (isValidMetaTileEntity(tHatch)) { - storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); - maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); - } - } - - return new String[]{ - "Progress:", - EnumChatFormatting.GREEN + Integer.toString(mProgresstime / 20) + EnumChatFormatting.RESET + " s / " + - EnumChatFormatting.YELLOW + Integer.toString(mMaxProgresstime / 20) + EnumChatFormatting.RESET + " s", - "Energy Hatches:", - EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET + " EU / " + - EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET + " EU", - (mEUt <= 0 ? "Probably uses: " : "Probably makes: ") + - EnumChatFormatting.RED + Integer.toString(Math.abs(mEUt)) + EnumChatFormatting.RESET + " EU/t at " + - EnumChatFormatting.RED + eAmpereFlow + EnumChatFormatting.RESET + " A", - "Tier Rating: " + EnumChatFormatting.YELLOW + VN[getMaxEnergyInputTier_EM()] + EnumChatFormatting.RESET + " / " + EnumChatFormatting.GREEN + VN[getMinEnergyInputTier_EM()] + EnumChatFormatting.RESET + - " Amp Rating: " + EnumChatFormatting.GREEN + eMaxAmpereFlow + EnumChatFormatting.RESET + " A", - "Problems: " + EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + - " Efficiency: " + EnumChatFormatting.YELLOW + Float.toString(mEfficiency / 100.0F) + EnumChatFormatting.RESET + " %", - "PowerPass: " + EnumChatFormatting.BLUE + ePowerPass + EnumChatFormatting.RESET + - " SafeVoid: " + EnumChatFormatting.BLUE + eSafeVoid, - "Computation: " + EnumChatFormatting.GREEN + eAvailableData + EnumChatFormatting.RESET + " / " + EnumChatFormatting.YELLOW + eRequiredData + EnumChatFormatting.RESET - }; - } - - @Override - public boolean isGivingInformation() { - return true; - } -} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java index 45267e3490..5173a2bec5 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java @@ -3,8 +3,9 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.auxiliary.Reference; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; -import com.github.technus.tectech.thing.metaTileEntity.multi.gui.GT_Container_MultiMachineEM; -import com.github.technus.tectech.thing.metaTileEntity.multi.gui.GT_GUIContainer_MultiMachineEM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_Container_MultiMachineEM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_GUIContainer_MultiMachineEM; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -33,7 +34,7 @@ import static gregtech.api.GregTech_API.sBlockCasings4; /** * Created by danie_000 on 17.12.2016. */ -public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { +public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { public final static int POWER_SETTING_DEFAULT=1000, TIMER_SETTING_DEFAULT=360; private int powerSetting = POWER_SETTING_DEFAULT; private int timerSetting = TIMER_SETTING_DEFAULT; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java new file mode 100644 index 0000000000..5342c9bc51 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java @@ -0,0 +1,128 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.base; + +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.gui.GT_Slot_Holo; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class GT_Container_MultiMachineEM extends GT_ContainerMetaTile_Machine { + public byte[] eParamsInStatus = new byte[20];//unused 0,G ok 1, B too low 2, R too high 3, Y blink dangerous 4,5 + public byte[] eParamsOutStatus = new byte[20]; + public byte eCertainMode = 5, eCertainStatus = 127; + public boolean ePowerPass = false, eSafeVoid = false, allowedToWork = false; + public final boolean ePowerPassButton, eSafeVoidButton, allowedToWorkButton; + + public GT_Container_MultiMachineEM(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean enablePowerPass, boolean enableSafeVoid, boolean enablePowerButton) { + super(aInventoryPlayer, aTileEntity); + ePowerPassButton=enablePowerPass; + eSafeVoidButton=enableSafeVoid; + allowedToWorkButton=enablePowerButton; + } + + public GT_Container_MultiMachineEM(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + ePowerPassButton=eSafeVoidButton=allowedToWorkButton=true; + } + + public GT_Container_MultiMachineEM(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + ePowerPassButton=eSafeVoidButton=allowedToWorkButton=true; + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new Slot(mTileEntity, 1, 152, -21)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, -2, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 15, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 32, false, false, 1)); + } + + @Override + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (aSlotIndex < 0) + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); + if ((tSlot != null) && (this.mTileEntity.getMetaTileEntity() != null)) { + GT_MetaTileEntity_MultiblockBase_EM base = (GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity(); + switch (aSlotIndex) { + case 1: + if(ePowerPassButton) { + base.ePowerPass ^= true; + if (!allowedToWorkButton) {//TRANSFORMER HACK + if (base.ePowerPass) base.getBaseMetaTileEntity().enableWorking(); + else base.getBaseMetaTileEntity().disableWorking(); + } + } + break; + case 2: + if(eSafeVoidButton) base.eSafeVoid ^= true; + break; + case 3: + if(allowedToWorkButton) { + if (base.getBaseMetaTileEntity().isAllowedToWork()) { + base.getBaseMetaTileEntity().disableWorking(); + } else { + base.getBaseMetaTileEntity().enableWorking(); + } + } + break; + } + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null) || (this.eParamsInStatus == null)) + return; + this.eParamsInStatus = ((GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity()).eParamsInStatus; + this.eParamsOutStatus = ((GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity()).eParamsOutStatus; + this.eCertainMode = ((GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity()).eCertainMode; + this.eCertainStatus = ((GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity()).eCertainStatus; + this.ePowerPass = ((GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity()).ePowerPass; + this.eSafeVoid = ((GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity()).eSafeVoid; + this.allowedToWork = this.mTileEntity.isAllowedToWork(); + + for (Object crafter : this.crafters) { + ICrafting var1 = (ICrafting) crafter; + int i = 100; + for (int j = 0; j < eParamsInStatus.length; j++) + var1.sendProgressBarUpdate(this, i++, eParamsInStatus[j] | (eParamsOutStatus[j] << 8)); + var1.sendProgressBarUpdate(this, 120, eCertainMode | (eCertainStatus << 8)); + var1.sendProgressBarUpdate(this, 121, (ePowerPass ? 1 : 0) + (eSafeVoid ? 2 : 0) + (allowedToWork ? 4 : 0)); + } + } + + @Override + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + if (this.eParamsInStatus == null) return; + if (par1 >= 100 && par1 < 120) { + this.eParamsInStatus[par1 - 100] = (byte) (par2 & 0xff); + this.eParamsOutStatus[par1 - 100] = (byte) (par2 >>> 8); + } else if (par1 == 120) { + this.eCertainMode = (byte) (par2 & 0xff); + this.eCertainStatus = (byte) (par2 >>> 8); + } else if (par1 == 121) { + this.ePowerPass = (par2 & 1) == 1; + this.eSafeVoid = (par2 & 2) == 2; + this.allowedToWork = (par2 & 4) == 4; + } + } + + @Override + public int getSlotCount() { + return 1; + } + + @Override + public int getShiftClickSlotCount() { + return 1; + } +} \ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_GUIContainer_MultiMachineEM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_GUIContainer_MultiMachineEM.java new file mode 100644 index 0000000000..94a70f6e50 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_GUIContainer_MultiMachineEM.java @@ -0,0 +1,205 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.base; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; +import org.lwjgl.opengl.GL11; + +import static com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM.*; +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +/** + * Created by Tec on 21.02.2017. + */ + +public class GT_GUIContainer_MultiMachineEM extends GT_GUIContainerMetaTile_Machine { + String mName = ""; + private static byte counter = 0; + public final boolean ePowerPassButton, eSafeVoidButton, allowedToWorkButton; + + public GT_GUIContainer_MultiMachineEM(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aTextureFile, boolean enablePowerPass, boolean enableSafeVoid, boolean enablePowerButton) { + super(new GT_Container_MultiMachineEM(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "multimachines/" + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); + mName = aName; + ePowerPassButton=enablePowerPass; + eSafeVoidButton=enableSafeVoid; + allowedToWorkButton=enablePowerButton; + } + + public GT_GUIContainer_MultiMachineEM(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aTextureFile) { + super(new GT_Container_MultiMachineEM(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "multimachines/" + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); + mName = aName; + ePowerPassButton=eSafeVoidButton=allowedToWorkButton=true; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + fontRendererObj.drawString(mName, 10, -18, 16448255); + + if (mContainer != null) { + if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 1) != 0) + fontRendererObj.drawString("Pipe is loose.", 10, -10, 16448255); + if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 2) != 0) + fontRendererObj.drawString("Screws are loose.", 10, -2, 16448255); + if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 4) != 0) + fontRendererObj.drawString("Something is stuck.", 10, 6, 16448255); + if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 8) != 0) + fontRendererObj.drawString("Plating is dented.", 10, 14, 16448255); + if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 16) != 0) + fontRendererObj.drawString("Circuitry burned out.", 10, 22, 16448255); + if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 32) != 0) + fontRendererObj.drawString("That doesn't belong there.", 10, 30, 16448255); + if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 64) != 0) + fontRendererObj.drawString("Incomplete Structure.", 10, 38, 16448255); + if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 128) != 0) + fontRendererObj.drawString("Too Uncertain.", 10, 46, 16448255); + if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 256) != 0) + fontRendererObj.drawString("Invalid Parameters.", 10, 54, 16448255); + + if (((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode == 0) { + if (((GT_Container_MultiMachineEM) mContainer).mActive == 0) { + fontRendererObj.drawString("Soft Hammer or press Button", 10, -10, 16448255); + fontRendererObj.drawString("to (re-)start the Machine", 10, -2, 16448255); + fontRendererObj.drawString("if it doesn't start.", 10, 6, 16448255); + } else { + fontRendererObj.drawString("Running perfectly.", 10, -10, 16448255); + } + } + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + y -= 26; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize + 26); + if (this.mContainer != null && ((GT_Container_MultiMachineEM) this.mContainer).eParamsInStatus != null) { + counter = (byte) ((1 + counter) % 6); + GL11.glColor4f(1f, 1f, 1f, 1f); + + if(!ePowerPassButton) + drawTexturedModalRect(x + 151, y + 23, 215, 23, 18, 18); + else if (((GT_Container_MultiMachineEM) mContainer).ePowerPass) + drawTexturedModalRect(x + 151, y + 23, 183, 23, 18, 18); + + if(!eSafeVoidButton) + drawTexturedModalRect(x + 151, y + 41, 215, 41, 18, 18); + else if (((GT_Container_MultiMachineEM) mContainer).eSafeVoid) + drawTexturedModalRect(x + 151, y + 41, 183, 41, 18, 18); + + if(!allowedToWorkButton) + drawTexturedModalRect(x + 151, y + 57, 215, 57, 18, 18); + else if (((GT_Container_MultiMachineEM) mContainer).allowedToWork) + drawTexturedModalRect(x + 151, y + 57, 183, 57, 18, 18); + + x += 11; + y += 96; + for (int i = 0; i < 20; ) { + byte j = (byte) (i >>> 1); + LEDdrawP(x, y, i, 0, ((GT_Container_MultiMachineEM) this.mContainer).eParamsInStatus[j]); + LEDdrawP(x, y, i++, 1, ((GT_Container_MultiMachineEM) this.mContainer).eParamsOutStatus[j]); + LEDdrawP(x, y, i, 0, ((GT_Container_MultiMachineEM) this.mContainer).eParamsInStatus[j + 10]); + LEDdrawP(x, y, i++, 1, ((GT_Container_MultiMachineEM) this.mContainer).eParamsOutStatus[j + 10]); + } + + final short rU = 183, Vs = 77; + x += 140; + y -= 19; + final byte state = ((GT_Container_MultiMachineEM) this.mContainer).eCertainStatus; + switch (((GT_Container_MultiMachineEM) this.mContainer).eCertainMode) { + case 1://ooo oxo ooo + drawTexturedModalRect(x + 6, y + 6, + rU + (state == 0 ? 38 : 6), + Vs + 6, 6, 6); + break; + case 2://ooo xox ooo + drawTexturedModalRect(x, y + 6, + rU + ((state & 1) == 0 ? 32 : 0), + Vs + 6, 6, 6); + drawTexturedModalRect(x + 12, y + 6, + rU + ((state & 2) == 0 ? 44 : 12), + Vs + 6, 6, 6); + break; + case 3://oxo xox oxo + drawTexturedModalRect(x + 6, y, + rU + ((state & 1) == 0 ? 38 : 6), + Vs, 6, 6); + drawTexturedModalRect(x, y + 6, + rU + ((state & 2) == 0 ? 32 : 0), + Vs + 6, 6, 6); + drawTexturedModalRect(x + 12, y + 6, + rU + ((state & 4) == 0 ? 44 : 12), + Vs + 6, 6, 6); + drawTexturedModalRect(x + 6, y + 12, + rU + ((state & 8) == 0 ? 38 : 6), + Vs + 12, 6, 6); + break; + case 4://xox ooo xox + drawTexturedModalRect(x, y, + rU + ((state & 1) == 0 ? 32 : 0), + Vs, 6, 6); + drawTexturedModalRect(x + 12, y, + rU + ((state & 2) == 0 ? 44 : 12), + Vs, 6, 6); + drawTexturedModalRect(x, y + 12, + rU + ((state & 4) == 0 ? 32 : 0), + Vs + 12, 6, 6); + drawTexturedModalRect(x + 12, y + 12, + rU + ((state & 8) == 0 ? 44 : 12), + Vs + 12, 6, 6); + break; + case 5://xox oxo xox + drawTexturedModalRect(x, y, + rU + ((state & 1) == 0 ? 32 : 0), + Vs, 6, 6); + drawTexturedModalRect(x + 12, y, + rU + ((state & 2) == 0 ? 44 : 12), + Vs, 6, 6); + drawTexturedModalRect(x + 6, y + 6, + rU + ((state & 4) == 0 ? 38 : 6), + Vs + 6, 6, 6); + drawTexturedModalRect(x, y + 12, + rU + ((state & 8) == 0 ? 32 : 0), + Vs + 12, 6, 6); + drawTexturedModalRect(x + 12, y + 12, + rU + ((state & 16) == 0 ? 44 : 12), + Vs + 12, 6, 6); + break; + } + } + } + + private void LEDdrawP(int x, int y, int i, int j, byte status) { + final int v = 192, su = 8, sv = 6, u = 11; + switch (status) { + case STATUS_WRONG: + if (counter < 2) { + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * j, su, sv); + break; + } else if (counter < 4) { + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (8 + j), su, sv); + break; + } + case STATUS_OK://ok + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (4 + j), su, sv); + break; + case STATUS_TOO_LOW://too low blink + if (counter < 3) { + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * j, su, sv); + break; + } + case STATUS_LOW:// too low + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (2 + j), su, sv); + break; + case STATUS_TOO_HIGH://too high blink + if (counter < 3) { + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (8 + j), su, sv); + break; + } + case STATUS_HIGH:// too high + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (6 + j), su, sv); + break; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java new file mode 100644 index 0000000000..ef426ab71b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java @@ -0,0 +1,1675 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.base; + +import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.Util; +import com.github.technus.tectech.Vec3pos; +import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.elementalMatter.core.stacks.cElementalDefinitionStack; +import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack; +import com.github.technus.tectech.elementalMatter.core.tElementalException; +import com.github.technus.tectech.thing.metaTileEntity.hatch.*; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +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.BaseTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Pollution; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.FluidStack; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import static com.github.technus.tectech.CommonValues.*; +import static com.github.technus.tectech.Util.*; +import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; + +/** + * Created by danie_000 on 27.10.2016. + */ +public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEntity_MultiBlockBase { + protected final static Map adderMethodMap = new HashMap<>(); + private static Method adderMethod; + + protected cElementalInstanceStackMap[] outputEM; + + public final static ItemStack[] nothingI = new ItemStack[0]; + public final static FluidStack[] nothingF = new FluidStack[0]; + + protected static Textures.BlockIcons.CustomIcon ScreenOFF; + protected static Textures.BlockIcons.CustomIcon ScreenON; + + protected ArrayList eInputHatches = new ArrayList<>(); + protected ArrayList eOutputHatches = new ArrayList<>(); + protected ArrayList eMufflerHatches = new ArrayList<>(); + protected ArrayList eParamHatches = new ArrayList<>(); + protected ArrayList eUncertainHatches = new ArrayList<>(); + protected ArrayList eEnergyMulti = new ArrayList<>(); + protected ArrayList eDynamoMulti = new ArrayList<>(); + protected ArrayList eInputData = new ArrayList<>(); + protected ArrayList eOutputData = new ArrayList<>(); + + // 0 and 10 are from first parametrizer + // 1 and 11 are from second etc... + + private final int[] iParamsIn = new int[20];//number I from parametrizers + private final int[] iParamsOut = new int[20];//number O to parametrizers + private final boolean[] bParamsAreFloats = new boolean[10]; + + final byte[] eParamsInStatus = new byte[20];//LED status for I + final byte[] eParamsOutStatus = new byte[20];//LED status for O + public final static byte STATUS_UNUSED = 0, + STATUS_TOO_LOW = 1, STATUS_LOW = 2, + STATUS_WRONG = 3, STATUS_OK = 4, + STATUS_TOO_HIGH = 5, STATUS_HIGH = 6; + // 0,2,4,6 - ok + // 1,3,5 - nok + + //TO ENABLE this change value in to false and/or other than 0, can also be added in recipe check or whatever + protected boolean eParameters = true, ePowerPass = false, eSafeVoid = false, eDismantleBoom = false; + protected byte eCertainMode = 0, eCertainStatus = 0, minRepairStatus = 3; + + protected long eMaxAmpereFlow = 0;//don't modify! unless YOU REALLY HAVE TO + private long maxEUinputMin = 0, maxEUinputMax = 0; + + public long eAmpereFlow = 1; // analogue of EU/t but for amperes used (so eu/t is actually eu*A/t) USE ONLY POSITIVE NUMBERS! + + protected long eRequiredData = 0; // data required to operate + protected long eAvailableData = 0; // data being available + + private boolean explodedThisTick=false; + + //init param states in constructor, or implement it in checkrecipe/outputfunction + + //METHODS TO OVERRIDE + + //if you want to add checks that run periodically when machine works then make onRunningTick better + //if you want to add checks that run periodically when machine is built then use check params + + public boolean checkRecipe_EM(ItemStack itemStack, boolean noParametrizers) { + return false; + } + // My code handles AMPS, if you want overclocking just modify mEUt and mMaxProgressTime, leave amps as usual! + // Set mEUt, Efficiencies, required computation, time, check input etc. + + public void updateParameters_EM(boolean busy) { + } + // update status of parameters in guis and "machine state" + // Called before check recipe, before outputting, and every second the machine is active + + public void outputAfterRecipe_EM() { + } + // based on "machine state" do output, + // this must move to outputEM to EM output hatches + // and can also modify output items/fluids/EM, remaining EM is NOT overflowed. + // (Well it can be overflowed if machine didn't finished, soft-hammered/disabled/not enough EU) + // Setting available data processing + + protected void hatchInit_EM() { + }//For extra types of hatches initiation, LOOK HOW IT IS CALLED! onPostTick + + protected void extraExplosions_EM() { + }//For that extra hatches explosions, and maybe some MOORE EXPLOSIONS + + //machine structure check + protected boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + return false; + } + + //Get Available data, Override only on data producers should return mAvailableData that is set in check recipe + protected long getAvailableData_EM() { + long result = 0; + final Vec3pos pos = new Vec3pos(getBaseMetaTileEntity()); + for (GT_MetaTileEntity_Hatch_InputData in : eInputData) + if (in.q != null) result += in.q.computationIfNotContained(pos); + return result; + } + + //Extra hook on cyclic updates (not really needed for machines smaller than 1 chunk) + //BUT NEEDED WHEN - machine blocks are not touching each other ot they don't implement IMachineBlockUpdateable (ex. air) + protected boolean cyclicUpdate_EM() { + return mUpdate <= -1000;//set to false to disable cyclic update + //default is once per 50s; mUpdate is decremented every tick + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + public int getPollutionPerTick_EM(ItemStack itemStack) { + return 0; + } + + //triggered if machine is not allowed to work after completing a recipe + protected void notAllowedToWork_stopMachine_EM(){ + stopMachine(); + } + + //Override if needed but usually call super method at start! + //On machine stop - NOT called when softhammered to offline state! - it SHOULD cause a full stop like power failure does + @Override + public void stopMachine() { + if (outputEM != null) { + float mass = 0; + for (cElementalInstanceStackMap tree : outputEM) + mass += tree.getMass(); + if (mass > 0) { + if (eMufflerHatches.size() < 1) explodeMultiblock(); + else { + mass /= eMufflerHatches.size(); + for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) + if (dump.addOverflowMatter(mass)) explodeMultiblock(); + } + } + outputEM = null; + } + + for (GT_MetaTileEntity_Hatch_OutputData data : eOutputData) + data.q = null; + + mOutputItems = null; + mOutputFluids = null; + mEfficiency = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + getBaseMetaTileEntity().disableWorking(); + hatchesStatusUpdate_EM(); + } + + @Override + public String[] getDescription() { + return new String[]{ + CommonValues.TEC_MARK_GENERAL, + "Nothing special just override me." + }; + } + + //RATHER LEAVE ALONE Section + protected boolean areChunksAroundLoaded_EM(){ + if(isValidMetaTileEntity(this) && getBaseMetaTileEntity().isServerSide()){ + IGregTechTileEntity base=getBaseMetaTileEntity(); + return base.getWorld().doChunksNearChunkExist(base.getXCoord(),base.getYCoord(),base.getZCoord(),3); + //todo check if it is actually checking if chunks are loaded + }else return false; + } + + public GT_MetaTileEntity_MultiblockBase_EM(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_MultiblockBase_EM(String aName) { + super(aName); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "EMDisplay.png"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/EM_CONTROLLER"); + ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/EM_CONTROLLER_ACTIVE"); + super.registerIcons(aBlockIconRegister); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][4], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; + return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][4]}; + } + + @Override + public byte getTileEntityBaseType() { + return 3; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + + aNBT.setLong("eMaxEUmin", maxEUinputMin); + aNBT.setLong("eMaxEUmax", maxEUinputMax); + aNBT.setLong("eRating", eAmpereFlow); + aNBT.setLong("eMaxA", eMaxAmpereFlow); + aNBT.setLong("eDataR", eRequiredData); + aNBT.setLong("eDataA", eAvailableData); + aNBT.setByte("eCertainM", eCertainMode); + aNBT.setByte("eCertainS", eCertainStatus); + aNBT.setByte("eMinRepair", minRepairStatus); + aNBT.setBoolean("eParam", eParameters); + aNBT.setBoolean("ePass", ePowerPass); + aNBT.setBoolean("eVoid", eSafeVoid); + aNBT.setBoolean("eBoom", eDismantleBoom); + aNBT.setBoolean("eOK", mMachine); + + //Ensures compatibility + if (mOutputItems != null) { + aNBT.setInteger("mOutputItemsLength", mOutputItems.length); + for (int i = 0; i < mOutputItems.length; i++) + if (mOutputItems[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + mOutputItems[i].writeToNBT(tNBT); + aNBT.setTag("mOutputItem" + i, tNBT); + } + } + + //Ensures compatibility + if (mOutputFluids != null) { + aNBT.setInteger("mOutputFluidsLength", mOutputFluids.length); + for (int i = 0; i < mOutputFluids.length; i++) + if (mOutputFluids[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + mOutputFluids[i].writeToNBT(tNBT); + aNBT.setTag("mOutputFluids" + i, tNBT); + } + } + + if (outputEM != null) { + aNBT.setInteger("outputStackCount", outputEM.length); + NBTTagCompound output = new NBTTagCompound(); + for (int i = 0; i < outputEM.length; i++) + output.setTag(Integer.toString(i), outputEM[i].toNBT()); + aNBT.setTag("outputEM", output); + } else { + aNBT.setInteger("outputStackCount", 0); + aNBT.removeTag("outputEM"); + } + + NBTTagCompound paramI = new NBTTagCompound(); + for (int i = 0; i < iParamsIn.length; i++) + paramI.setInteger(Integer.toString(i), iParamsIn[i]); + aNBT.setTag("eParamsIn", paramI); + + NBTTagCompound paramO = new NBTTagCompound(); + for (int i = 0; i < iParamsOut.length; i++) + paramO.setInteger(Integer.toString(i), iParamsOut[i]); + aNBT.setTag("eParamsOut", paramO); + + NBTTagCompound paramB = new NBTTagCompound(); + for (int i = 0; i < bParamsAreFloats.length; i++) + paramB.setBoolean(Integer.toString(i), bParamsAreFloats[i]); + aNBT.setTag("eParamsB", paramB); + + NBTTagCompound paramIs = new NBTTagCompound(); + for (int i = 0; i < eParamsInStatus.length; i++) + paramIs.setByte(Integer.toString(i), eParamsInStatus[i]); + aNBT.setTag("eParamsInS", paramIs); + + NBTTagCompound paramOs = new NBTTagCompound(); + for (int i = 0; i < eParamsOutStatus.length; i++) + paramOs.setByte(Integer.toString(i), eParamsOutStatus[i]); + aNBT.setTag("eParamsOutS", paramOs); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + + maxEUinputMin = aNBT.getLong("eMaxEUmin"); + maxEUinputMax = aNBT.getLong("eMaxEUmax"); + eAmpereFlow = aNBT.getLong("eRating"); + eMaxAmpereFlow = aNBT.getLong("eMaxA"); + eRequiredData = aNBT.getLong("eDataR"); + eAvailableData = aNBT.getLong("eDataA"); + eCertainMode = aNBT.getByte("eCertainM"); + eCertainStatus = aNBT.getByte("eCertainS"); + minRepairStatus = aNBT.getByte("eMinRepair"); + eParameters = aNBT.getBoolean("eParam"); + ePowerPass = aNBT.getBoolean("ePass"); + eSafeVoid = aNBT.getBoolean("eVoid"); + eDismantleBoom = aNBT.getBoolean("eBoom"); + mMachine = aNBT.getBoolean("eOK"); + + //Ensures compatibility + int aOutputItemsLength = aNBT.getInteger("mOutputItemsLength"); + if (aOutputItemsLength > 0) { + mOutputItems = new ItemStack[aOutputItemsLength]; + for (int i = 0; i < mOutputItems.length; i++) + mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); + } + + //Ensures compatibility + int aOutputFluidsLength = aNBT.getInteger("mOutputFluidsLength"); + if (aOutputFluidsLength > 0) { + mOutputFluids = new FluidStack[aOutputFluidsLength]; + for (int i = 0; i < mOutputFluids.length; i++) + mOutputFluids[i] = GT_Utility.loadFluid(aNBT, "mOutputFluids" + i); + } + + final int outputLen = aNBT.getInteger("outputStackCount"); + if (outputLen > 0) { + outputEM = new cElementalInstanceStackMap[outputLen]; + for (int i = 0; i < outputEM.length; i++) + try { + outputEM[i] = cElementalInstanceStackMap.fromNBT( + aNBT.getCompoundTag("outputEM").getCompoundTag(Integer.toString(i))); + } catch (tElementalException e) { + if (DEBUG_MODE) e.printStackTrace(); + outputEM[i] = new cElementalInstanceStackMap(); + } + } else outputEM = new cElementalInstanceStackMap[0]; + + NBTTagCompound paramI = aNBT.getCompoundTag("eParamsIn"); + for (int i = 0; i < iParamsIn.length; i++) + iParamsIn[i] = paramI.getInteger(Integer.toString(i)); + + NBTTagCompound paramO = aNBT.getCompoundTag("eParamsOut"); + for (int i = 0; i < iParamsOut.length; i++) + iParamsOut[i] = paramO.getInteger(Integer.toString(i)); + + NBTTagCompound paramB = aNBT.getCompoundTag("eParamsB"); + for (int i = 0; i < bParamsAreFloats.length; i++) + bParamsAreFloats[i] = paramB.getBoolean(Integer.toString(i)); + + NBTTagCompound paramIs = aNBT.getCompoundTag("eParamsInS"); + for (int i = 0; i < eParamsInStatus.length; i++) + eParamsInStatus[i] = paramIs.getByte(Integer.toString(i)); + + NBTTagCompound paramOs = aNBT.getCompoundTag("eParamsOutS"); + for (int i = 0; i < eParamsOutStatus.length; i++) + eParamsOutStatus[i] = paramOs.getByte(Integer.toString(i)); + } + + private boolean cyclicUpdate() { + if (cyclicUpdate_EM()) { + mUpdate = 0; + return true; + } + return false; + } + + //Param methods + public final boolean isParametrizerUsingFloat(int hatchNo){ + return bParamsAreFloats[hatchNo]; + } + + public final double getParameterInSafely(int hatchNo, int paramID){ + return bParamsAreFloats[hatchNo]?Float.intBitsToFloat(iParamsIn[hatchNo+10*paramID]):iParamsIn[hatchNo+10*paramID]; + } + + public final int getParameterInInt(int hatchNo, int paramID){ + return iParamsIn[hatchNo+10*paramID]; + } + + public final float getParameterInFloat(int hatchNo, int paramID){ + return Float.intBitsToFloat(iParamsIn[hatchNo+10*paramID]); + } + + public final void setParameterOutSafely(int hatchNo, int paramID, double value){ + if(bParamsAreFloats[hatchNo]) { + iParamsOut[hatchNo+10*paramID]=Float.floatToIntBits((float) value); + }else{ + iParamsOut[hatchNo+10*paramID]=(int)value; + } + } + + public final boolean setParameterOutInt(int hatchNo, int paramID, int value){ + if(bParamsAreFloats[hatchNo]) return false; + iParamsOut[hatchNo+10*paramID]=value; + return true; + } + + public final boolean setParameterOutFloat(int hatchNo, int paramID, float value){ + if(bParamsAreFloats[hatchNo]) { + iParamsOut[hatchNo + 10 * paramID] = Float.floatToIntBits(value); + return true; + } + return false; + } + + public final byte getStatusOfParameterIn(int hatchNo, int paramID){ + return eParamsInStatus[hatchNo+10*paramID]; + } + + public final void setStatusOfParameterIn(int hatchNo, int paramID, byte status){ + eParamsInStatus[hatchNo+10*paramID]=status; + } + + public final byte getStatusOfParameterOut(int hatchNo, int paramID){ + return eParamsOutStatus[hatchNo+10*paramID]; + } + + public final void setStatusOfParameterOut(int hatchNo, int paramID, byte status){ + eParamsOutStatus[hatchNo+10*paramID]=status; + } + + @Override + public final boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + return checkMachine_EM(iGregTechTileEntity, itemStack); + } + + //can be used to check structures of multi-blocks larger than one chunk, but... + //ALL THE HATCHES AND THE CONTROLLER SHOULD BE IN ONE CHUNK OR IN LOADED CHUNKS + @Deprecated + public final boolean structureCheck_EM( + String[][] structure,//0-9 casing, +- air no air, a-z ignore + Block[] blockType,//use numbers 0-9 for casing types + byte[] blockMeta,//use numbers 0-9 for casing types + int horizontalOffset, int verticalOffset, int depthOffset) { + return StructureChecker(structure, blockType, blockMeta, + horizontalOffset, verticalOffset, depthOffset, getBaseMetaTileEntity(), !mMachine); + } + + public final boolean structureCheck_EM( + String[][] structure,//0-9 casing, +- air no air, a-z ignore + Block[] blockType,//use numbers 0-9 for casing types + byte[] blockMeta,//use numbers 0-9 for casing types + String[] addingMethods, + short[] casingTextures, + Block[] blockTypeFallback,//use numbers 0-9 for casing types + byte[] blockMetaFallback,//use numbers 0-9 for casing types + int horizontalOffset, int verticalOffset, int depthOffset) { + return StructureCheckerAdvanced(structure, blockType, blockMeta, + adderMethod, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, + horizontalOffset, verticalOffset, depthOffset, getBaseMetaTileEntity(), !mMachine); + } + + //CAREFUL!!! it calls most of the callbacks + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + explodedThisTick=false; + if (mEfficiency < 0) mEfficiency = 0; + + if (--mUpdate == 0 || --mStartUpCheck == 0 || cyclicUpdate() || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) { + mInputHatches.clear(); + mInputBusses.clear(); + mOutputHatches.clear(); + mOutputBusses.clear(); + mDynamoHatches.clear(); + mEnergyHatches.clear(); + mMufflerHatches.clear(); + mMaintenanceHatches.clear(); + + for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eOutputHatches) + if (isValidMetaTileEntity(hatch_elemental)) hatch_elemental.id = -1; + for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eInputHatches) + if (isValidMetaTileEntity(hatch_elemental)) hatch_elemental.id = -1; + + for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eOutputData) + if (isValidMetaTileEntity(hatch_data)) hatch_data.id = -1; + for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eInputData) + if (isValidMetaTileEntity(hatch_data)) hatch_data.id = -1; + + for (GT_MetaTileEntity_Hatch_Uncertainty hatch : eUncertainHatches) + if (isValidMetaTileEntity(hatch)) hatch.getBaseMetaTileEntity().setActive(false); + for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) + if (isValidMetaTileEntity(hatch)) hatch.getBaseMetaTileEntity().setActive(false); + + eUncertainHatches.clear(); + eEnergyMulti.clear(); + eInputHatches.clear(); + eOutputHatches.clear(); + eParamHatches.clear(); + eMufflerHatches.clear(); + eDynamoMulti.clear(); + eOutputData.clear(); + eInputData.clear(); + + if ((getBaseMetaTileEntity() instanceof BaseTileEntity)) + ((BaseTileEntity) getBaseMetaTileEntity()).ignoreUnloadedChunks = mMachine; + mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); + + if (!mMachine) { + if ((ePowerPass && getEUVar() > V[3]) || (eDismantleBoom && mMaxProgresstime > 0 && areChunksAroundLoaded_EM())) + explodeMultiblock(); + if (outputEM != null) + for (cElementalInstanceStackMap tree : outputEM) + if (tree.hasStacks()) explodeMultiblock(); + } + + if (eUncertainHatches.size() > 1) mMachine = false; + + if (mMachine) { + short id = 1; + for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eOutputHatches) + if (isValidMetaTileEntity(hatch_elemental)) hatch_elemental.id = id++; + id = 1; + for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eInputHatches) + if (isValidMetaTileEntity(hatch_elemental)) hatch_elemental.id = id++; + + id = 1; + for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eOutputData) + if (isValidMetaTileEntity(hatch_data)) hatch_data.id = id++; + id = 1; + for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eInputData) + if (isValidMetaTileEntity(hatch_data)) hatch_data.id = id++; + + if (mEnergyHatches.size() > 0 || eEnergyMulti.size() > 0) { + maxEUinputMin = V[15]; + maxEUinputMax = V[0]; + for (GT_MetaTileEntity_Hatch_Energy hatch : mEnergyHatches) + if (isValidMetaTileEntity(hatch)) { + if (hatch.maxEUInput() < maxEUinputMin) maxEUinputMin = hatch.maxEUInput(); + if (hatch.maxEUInput() > maxEUinputMax) maxEUinputMax = hatch.maxEUInput(); + } + for (GT_MetaTileEntity_Hatch_EnergyMulti hatch : eEnergyMulti) + if (isValidMetaTileEntity(hatch)) { + if (hatch.maxEUInput() < maxEUinputMin) maxEUinputMin = hatch.maxEUInput(); + if (hatch.maxEUInput() > maxEUinputMax) maxEUinputMax = hatch.maxEUInput(); + } + eMaxAmpereFlow = 0; + //counts only full amps + for (GT_MetaTileEntity_Hatch_Energy hatch : mEnergyHatches) + if (isValidMetaTileEntity(hatch)) eMaxAmpereFlow += hatch.maxEUInput() / maxEUinputMin; + for (GT_MetaTileEntity_Hatch_EnergyMulti hatch : eEnergyMulti) + if (isValidMetaTileEntity(hatch)) + eMaxAmpereFlow += (hatch.maxEUInput() / maxEUinputMin) * hatch.Amperes; + if (this.getEUVar() > maxEUStore()) this.setEUVar(this.maxEUStore()); + } else { + maxEUinputMin = 0; + maxEUinputMax = 0; + eMaxAmpereFlow = 0; + this.setEUVar(0); + } + + for (GT_MetaTileEntity_Hatch_Uncertainty hatch : eUncertainHatches) + if (isValidMetaTileEntity(hatch)) hatch.getBaseMetaTileEntity().setActive(true); + for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches){ + if (isValidMetaTileEntity(hatch)) { + hatch.getBaseMetaTileEntity().setActive(true); + if(hatch.param>=0) bParamsAreFloats[hatch.param]=hatch.isUsingFloats(); + } + } + } else { + maxEUinputMin = 0; + maxEUinputMax = 0; + eMaxAmpereFlow = 0; + this.setEUVar(0); + } + hatchInit_EM(); + } + + if (mStartUpCheck < 0) {//E + if (mMachine) {//S + final byte Tick = (byte) (aTick % 20); + if (MULTI_PURGE_1_AT == Tick || MULTI_PURGE_2_AT == Tick) + purgeAllOverflowEM_EM(); + else if (MULTI_CHECK_AT == Tick) + for (GT_MetaTileEntity_Hatch_Maintenance tHatch : mMaintenanceHatches) { + if (isValidMetaTileEntity(tHatch)) { + if (disableMaintenance) { + mWrench = true; + mScrewdriver = true; + mSoftHammer = true; + mHardHammer = true; + mSolderingTool = true; + mCrowbar = true; + } else { + if (tHatch.mAuto && !(mWrench && mScrewdriver && mSoftHammer && mHardHammer && mSolderingTool && mCrowbar)) + tHatch.autoMaintainance(); + if (tHatch.mWrench) mWrench = true; + if (tHatch.mScrewdriver) mScrewdriver = true; + if (tHatch.mSoftHammer) mSoftHammer = true; + if (tHatch.mHardHammer) mHardHammer = true; + if (tHatch.mSolderingTool) mSolderingTool = true; + if (tHatch.mCrowbar) mCrowbar = true; + + tHatch.mWrench = false; + tHatch.mScrewdriver = false; + tHatch.mSoftHammer = false; + tHatch.mHardHammer = false; + tHatch.mSolderingTool = false; + tHatch.mCrowbar = false; + } + } + } + else if (MOVE_AT == Tick && eSafeVoid) { + for (GT_MetaTileEntity_Hatch_MufflerElemental voider : eMufflerHatches) { + if (voider.overflowMax < voider.getOverflowMatter()) continue; + float remaining = voider.overflowMax - voider.getOverflowMatter(); + for (GT_MetaTileEntity_Hatch_InputElemental in : eInputHatches) { + for (cElementalInstanceStack instance : in.getContainerHandler().values()) { + long qty = (long) Math.floor(remaining / instance.definition.getMass()); + if (qty > 0) { + qty = Math.min(qty, instance.amount); + if (voider.addOverflowMatter(instance.definition.getMass() * qty)) + voider.setOverflowMatter(voider.overflowMax); + in.getContainerHandler().removeAmount(false, new cElementalDefinitionStack(instance.definition, qty)); + } + } + } + for (GT_MetaTileEntity_Hatch_OutputElemental out : eOutputHatches) { + for (cElementalInstanceStack instance : out.getContainerHandler().values()) { + long qty = (long)Math.floor(remaining / instance.definition.getMass()); + if (qty > 0) { + qty = Math.min(qty, instance.amount); + if (voider.addOverflowMatter(instance.definition.getMass() * qty)) + voider.setOverflowMatter(voider.overflowMax); + out.getContainerHandler().removeAmount(false, new cElementalDefinitionStack(instance.definition, qty)); + } + } + } + } + } + + if (getRepairStatus() >= minRepairStatus) {//S + if (MULTI_CHECK_AT == Tick) + hatchesStatusUpdate_EM(); + + //region power pass and controller charging + {//DO + long euVar; + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { + if (this.getEUVar() > this.getMinimumStoredEU()) break; + if (isValidMetaTileEntity(tHatch)) { + euVar = tHatch.maxEUInput(); + if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euVar, false)) + this.setEUVar(this.getEUVar() + euVar); + } + } + for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) { + if (this.getEUVar() > this.getMinimumStoredEU()) break; + if (isValidMetaTileEntity(tHatch)) { + euVar = tHatch.maxEUInput() * tHatch.Amperes; + if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euVar, false)) + this.setEUVar(this.getEUVar() + euVar); + } + } + if (ePowerPass) { + for (GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) { + if (isValidMetaTileEntity(tHatch)) { + euVar = tHatch.maxEUOutput(); + if (tHatch.getBaseMetaTileEntity().getStoredEU() <= (tHatch.maxEUStore() - euVar) && + aBaseMetaTileEntity.decreaseStoredEnergyUnits(euVar + Math.min(euVar >> 7,1), false)) + tHatch.setEUVar(tHatch.getBaseMetaTileEntity().getStoredEU() + euVar); + } + } + for (GT_MetaTileEntity_Hatch_DynamoMulti tHatch : eDynamoMulti) { + if (isValidMetaTileEntity(tHatch)) { + euVar = tHatch.maxEUOutput() * tHatch.Amperes; + if (tHatch.getBaseMetaTileEntity().getStoredEU() <= tHatch.maxEUStore() - euVar && + aBaseMetaTileEntity.decreaseStoredEnergyUnits(euVar + Math.min(euVar >> 7,tHatch.Amperes), false)) + tHatch.setEUVar(tHatch.getBaseMetaTileEntity().getStoredEU() + euVar); + } + } + } + } + //endregion + + if (mMaxProgresstime > 0 && doRandomMaintenanceDamage()) {//Start + if (onRunningTick(mInventory[1])) {//Compute EU + if (!polluteEnvironment(getPollutionPerTick(mInventory[1]))) stopMachine(); + if (!polluteEnvironment_EM(getPollutionPerTick_EM(mInventory[1]))) stopMachine(); + + if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime && RECIPE_AT == Tick) {//progress increase and done + hatchesStatusUpdate_EM(); + + outputAfterRecipe_EM(); + cleanOutputEM_EM(); + + if (mOutputItems != null) for (ItemStack tStack : mOutputItems) + if (tStack != null) addOutput(tStack); + mOutputItems = null; + + if (mOutputFluids != null) { + if (mOutputFluids.length == 1) { + for (FluidStack tStack : mOutputFluids) + if (tStack != null) addOutput(tStack); + } else if (mOutputFluids.length > 1) addFluidOutputs(mOutputFluids); + } + mOutputFluids = null; + + updateSlots(); + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + if (aBaseMetaTileEntity.isAllowedToWork()) { + if (checkRecipe(mInventory[1])) { + mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); + }else { + mMaxProgresstime=0; + } + updateSlots(); + } else notAllowedToWork_stopMachine_EM(); + } + }// else {//failed to consume power/resources - inside on running tick + // stopMachine(); + //} + } else if (RECIPE_AT == Tick || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) { + if (aBaseMetaTileEntity.isAllowedToWork()) { + if (checkRecipe(mInventory[1])) { + mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); + }else { + mMaxProgresstime=0; + } + updateSlots(); + } //else notAllowedToWork_stopMachine_EM(); //it is already stopped here + } + } else {//not repaired + stopMachine(); + } + } else {//not complete + stopMachine(); + } + } + + aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & -512) | (mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8) | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64) | ((eCertainStatus == 0) ? 0 : 128) | (eParameters ? 0 : 256)); + aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); + boolean active = aBaseMetaTileEntity.isActive() && mPollution > 0; + for (GT_MetaTileEntity_Hatch_Muffler aMuffler : mMufflerHatches) + aMuffler.getBaseMetaTileEntity().setActive(active); + } + } + + public boolean polluteEnvironment_EM(int aPollutionLevel) { + return true; //TODO + } + + @Deprecated + public final int getAmountOfOutputs() { + throw new NoSuchMethodError("Deprecated Do not use"); + } + + @Override + protected void addFluidOutputs(FluidStack[] mOutputFluids) { + int min=mOutputFluids.length>mOutputHatches.size()?mOutputHatches.size():mOutputFluids.length; + for (int i = 0; i < min; ++i) { + if (this.mOutputHatches.get(i) != null && mOutputFluids[i] != null && isValidMetaTileEntity(this.mOutputHatches.get(i))) { + this.mOutputHatches.get(i).fill(mOutputFluids[i], true); + } + } + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getIdealStatus() { + return super.getIdealStatus() + 2; + } + + @Override + public int getRepairStatus() { + return super.getRepairStatus() + ((eCertainStatus == 0) ? 1 : 0) + (this.eParameters ? 1 : 0); + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (eRequiredData > eAvailableData) { + if(energyFlow(aStack,false)) + stopMachine(); + return false; + } + return energyFlow(aStack,true); + } + + //new method + private boolean energyFlow(ItemStack aStack,boolean allowProduction) { + long temp = mEUt * eAmpereFlow;//quick scope sign + if (allowProduction && temp > 0) { + this.addEnergyOutput_EM((long) mEUt * (long) mEfficiency / getMaxEfficiency(aStack), eAmpereFlow); + } else if (temp < 0) { + if (!this.drainEnergyInput_EM(mEUt,(long) mEUt * getMaxEfficiency(aStack) / Math.max(1000L, this.mEfficiency), eAmpereFlow)) { + stopMachine(); + return false; + } + } + return true; + } + + //region energy + public final boolean energyFlowWithoutEffieciencyComputation(int eu,long ampere) { + long temp = eu * ampere;//quick scope sign + if (temp > 0) { + this.addEnergyOutput_EM(eu, ampere); + } else if (temp < 0) { + if (!this.drainEnergyInput_EM(eu,eu, ampere)) { + stopMachine(); + return false; + } + } + return true; + } + + @Override + public final long maxEUStore() { + return (maxEUinputMin * eMaxAmpereFlow) << 3; + } + + @Override + public final long getMinimumStoredEU() { + return maxEUStore() >> 1; + } + + @Override + public final long maxAmperesIn() { + return 0L; + } + + @Override + public final long maxAmperesOut() { + return 0L; + } + + @Deprecated + @Override + public final boolean addEnergyOutput(long EU) { + if (EU <= 0L) return true; + for (GT_MetaTileEntity_Hatch tHatch : eDynamoMulti) + if (isValidMetaTileEntity(tHatch)){ + if(tHatch.maxEUOutput() 0) { + if (euVar > diff) { + tHatch.setEUVar(tHatch.maxEUStore()); + euVar -= diff; + } else if (euVar <= diff) { + tHatch.setEUVar(tHatch.getBaseMetaTileEntity().getStoredEU() + euVar); + return true; + } + } + } + } + for (GT_MetaTileEntity_Hatch_DynamoMulti tHatch : eDynamoMulti) { + if (isValidMetaTileEntity(tHatch)) { + if (tHatch.maxEUOutput() < EU) explodeMultiblock(); + diff = tHatch.maxEUStore() - tHatch.getBaseMetaTileEntity().getStoredEU(); + if (diff > 0) { + if (euVar > diff) { + tHatch.setEUVar(tHatch.maxEUStore()); + euVar -= diff; + } else if (euVar <= diff) { + tHatch.setEUVar(tHatch.getBaseMetaTileEntity().getStoredEU() + euVar); + return true; + } + } + } + } + return false; + } + + @Deprecated + @Override + public final boolean drainEnergyInput(long EU) { + if (EU <= 0L) return true; + for (GT_MetaTileEntity_Hatch tHatch : eEnergyMulti) + if (isValidMetaTileEntity(tHatch) && tHatch.maxEUInput()>EU && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(EU, false)) + return true; + for (GT_MetaTileEntity_Hatch tHatch : mEnergyHatches) + if (isValidMetaTileEntity(tHatch) && tHatch.maxEUInput()>EU && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(EU, false)) + return true; + return false; + } + + private boolean drainEnergyInput_EM(long EUt, long EUtEff, long Amperes) { + if(EUt<0) EUt=-EUt; + if(EUtEff<0) EUtEff=-EUtEff; + if(Amperes<0) Amperes=-Amperes; + long EUuse = EUtEff * Amperes; + if (EUuse > getEUVar() || //not enough power + EUt > maxEUinputMax || //TIER IS BASED ON BEST HATCH! not total EUtEff input + ((EUt*Amperes) - 1) / maxEUinputMin + 1 > eMaxAmpereFlow) {// EUuse==0? --> (EUuse - 1) / maxEUinputMin + 1 = 1! //if not too much A + if (DEBUG_MODE) { + TecTech.Logger.debug("L1 " + EUuse + " " + getEUVar() + " " + (EUuse > getEUVar())); + TecTech.Logger.debug("L2 " + EUtEff + " " + maxEUinputMax + " " + (EUtEff > maxEUinputMax)); + TecTech.Logger.debug("L3 " + EUuse + " " + eMaxAmpereFlow); + TecTech.Logger.debug("L4 " + ((EUuse - 1) / maxEUinputMin + 1) + " " + eMaxAmpereFlow + " " + ((EUuse - 1) / maxEUinputMin + 1 > eMaxAmpereFlow)); + } + return false; + } + //sub eu + setEUVar(getEUVar() - EUuse); + return true; + } + + //new method + public final boolean overclockAndPutValuesIn_EM(long EU, int time) {//TODO revise + if (EU == 0L) { + mEUt = 0; + mMaxProgresstime = time; + return true; + } + long tempEUt = EU < V[1] ? V[1] : EU; + long tempTier = maxEUinputMax >> 2; + while (tempEUt < tempTier) { + tempEUt <<= 2; + time >>= 1; + EU = time == 0 ? EU >> 1 : EU << 2;//U know, if the time is less than 1 tick make the machine use less power + } + if (EU > Integer.MAX_VALUE || EU < Integer.MIN_VALUE) { + mEUt = Integer.MAX_VALUE - 1; + mMaxProgresstime = Integer.MAX_VALUE - 1; + return false; + } + mEUt = (int) EU; + mMaxProgresstime = time == 0 ? 1 : time; + return true; + }//Use in EM check recipe return statement if you want overclocking + + @Override // same as gt sum of all hatches + public final long getMaxInputVoltage() { + long rVoltage = 0; + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) + if (isValidMetaTileEntity(tHatch)) rVoltage += tHatch.maxEUInput(); + for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) + if (isValidMetaTileEntity(tHatch)) rVoltage += tHatch.maxEUInput(); + return rVoltage; + } + + //new Method + public final long getMaxInputEnergy(){ + long energy = 0; + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) + if (isValidMetaTileEntity(tHatch)) energy += tHatch.maxEUInput(); + for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) + if (isValidMetaTileEntity(tHatch)) energy += tHatch.maxEUInput() * tHatch.Amperes; + return energy; + } + + //new Method + public final int getMaxEnergyInputTier_EM() { + return Util.getTier(maxEUinputMax); + } + + //new Method + public final int getMinEnergyInputTier_EM() { + return Util.getTier(maxEUinputMin); + } + + public final long getMaxAmpereFlowAtMinTierOfEnergyHatches(){ + return eAmpereFlow; + } + + //endregion + + //new Method + public final cElementalInstanceStackMap getInputsClone_EM(){ + cElementalInstanceStackMap in=new cElementalInstanceStackMap(); + for(GT_MetaTileEntity_Hatch_ElementalContainer hatch:eInputHatches){ + in.putUnifyAll(hatch.getContainerHandler()); + } + return in.hasStacks()?in:null; + } + + //new Method + public final cElementalInstanceStackMap getOutputsClone_EM(){ + cElementalInstanceStackMap out=new cElementalInstanceStackMap(); + for(GT_MetaTileEntity_Hatch_ElementalContainer hatch:eOutputHatches){ + out.putUnifyAll(hatch.getContainerHandler()); + } + return out.hasStacks()?out:null; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + @Override + public void updateSlots() { + super.updateSlots(); + purgeAllOverflowEM_EM(); + } + + //region em cleaning + private void purgeAllOverflowEM_EM() { + float mass = 0; + for (GT_MetaTileEntity_Hatch_InputElemental tHatch : eInputHatches) { + if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); + mass += tHatch.overflowMatter; + tHatch.overflowMatter = 0; + } + for (GT_MetaTileEntity_Hatch_OutputElemental tHatch : eOutputHatches) { + if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); + mass += tHatch.overflowMatter; + tHatch.overflowMatter = 0; + } + if (mass > 0) { + if (eMufflerHatches.size() < 1) explodeMultiblock(); + mass /= eMufflerHatches.size(); + for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) + if (dump.addOverflowMatter(mass)) explodeMultiblock(); + } + } + + public void cleanHatchContentEM_EM(GT_MetaTileEntity_Hatch_ElementalContainer target) { + if (target == null) return; + float mass = target.getContainerHandler().getMass(); + if (mass > 0) { + if (eMufflerHatches.size() < 1) explodeMultiblock(); + mass /= eMufflerHatches.size(); + for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) + if (dump.addOverflowMatter(mass)) explodeMultiblock(); + } + } + + public void cleanStackEM_EM(cElementalInstanceStack target) { + if (target == null) return; + cleanMassEM_EM(target.getMass()); + } + + public void cleanMassEM_EM(float mass) { + if (mass > 0) { + if (eMufflerHatches.size() < 1) explodeMultiblock(); + mass /= eMufflerHatches.size(); + for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) + if (dump.addOverflowMatter(mass)) explodeMultiblock(); + } + } + + private void cleanOutputEM_EM() { + if (outputEM == null) return; + float mass = 0; + for (cElementalInstanceStackMap map : outputEM) + mass = map.removeOverflow(0, 0); + + if (mass > 0) { + if (eMufflerHatches.size() < 1) explodeMultiblock(); + mass /= eMufflerHatches.size(); + for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) + if (dump.addOverflowMatter(mass)) explodeMultiblock(); + } + outputEM = null; + } + //endregion + + @Override + public final boolean checkRecipe(ItemStack itemStack) {//do recipe checks, based on "machine content and state" + hatchesStatusUpdate_EM(); + return checkRecipe_EM(itemStack, eParamHatches.size()==0); + } + + private void hatchesStatusUpdate_EM() { + for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) { + if (!isValidMetaTileEntity(hatch) || hatch.param < 0) continue; + final int paramID = hatch.param; + iParamsIn[paramID] = hatch.value0i; + iParamsIn[paramID + 10] = hatch.value1i; + hatch.input0i = iParamsOut[paramID]; + hatch.input1i = iParamsOut[paramID + 10]; + bParamsAreFloats[hatch.param]=hatch.isUsingFloats(); + } + updateParameters_EM(mMaxProgresstime>0); + + eAvailableData = getAvailableData_EM(); + + for (GT_MetaTileEntity_Hatch_Uncertainty uncertainty : eUncertainHatches) + eCertainStatus = uncertainty.update(eCertainMode); + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public final void explodeMultiblock() { + if(explodedThisTick)return; + explodedThisTick=true; + if (!TecTech.ModConfig.BOOM_ENABLE) { + TecTech.proxy.broadcast("Multi Explode BOOM! " + getBaseMetaTileEntity().getXCoord() + " " + getBaseMetaTileEntity().getYCoord() + " " + getBaseMetaTileEntity().getZCoord()); + StackTraceElement[] ste = Thread.currentThread().getStackTrace(); + TecTech.proxy.broadcast("Multi Explode BOOM! " + ste[2].toString()); + return; + } + extraExplosions_EM(); + GT_Pollution.addPollution(getBaseMetaTileEntity(), 600000); + mInventory[1] = null; + for (MetaTileEntity tTileEntity : mInputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + for (MetaTileEntity tTileEntity : mOutputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + for (MetaTileEntity tTileEntity : mInputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + for (MetaTileEntity tTileEntity : mOutputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + for (MetaTileEntity tTileEntity : mDynamoHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); + for (MetaTileEntity tTileEntity : mMufflerHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + for (MetaTileEntity tTileEntity : mEnergyHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); + for (MetaTileEntity tTileEntity : mMaintenanceHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + for (MetaTileEntity tTileEntity : eParamHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + for (MetaTileEntity tTileEntity : eInputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); + for (MetaTileEntity tTileEntity : eOutputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); + for (MetaTileEntity tTileEntity : eMufflerHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); + for (MetaTileEntity tTileEntity : eEnergyMulti) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); + for (MetaTileEntity tTileEntity : eUncertainHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + for (MetaTileEntity tTileEntity : eDynamoMulti) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); + for (MetaTileEntity tTileEntity : eInputData) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + for (MetaTileEntity tTileEntity : eOutputData) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + getBaseMetaTileEntity().doExplosion(V[15]); + } + + @Override + public void doExplosion(long aExplosionPower) { + explodeMultiblock(); + super.doExplosion(aExplosionPower); + }//Redirecting to explodemultiblock + + @Override + public void onRemoval() { + try { + if (eOutputHatches != null) { + for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eOutputHatches) + hatch_elemental.id = -1; + for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eInputHatches) + hatch_elemental.id = -1; + for (GT_MetaTileEntity_Hatch_OutputData hatch_data : eOutputData) { + hatch_data.id = -1; + hatch_data.q = null; + } + for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eInputData) + hatch_data.id = -1; + for (GT_MetaTileEntity_Hatch_Uncertainty hatch : eUncertainHatches) + hatch.getBaseMetaTileEntity().setActive(false); + for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) + hatch.getBaseMetaTileEntity().setActive(false); + } + if ((ePowerPass && getEUVar()>V[3]) || (eDismantleBoom && mMaxProgresstime > 0 && areChunksAroundLoaded_EM())) explodeMultiblock(); + if (outputEM != null) + for (cElementalInstanceStackMap output : outputEM) + if (output.hasStacks()) explodeMultiblock(); + } catch (Exception e) { + if (DEBUG_MODE) e.printStackTrace(); + } + } + + //region adder methods + @Override + public final boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) + return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) + return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) + return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) + return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) + return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) + return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) + return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) + return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputElemental) + return eInputHatches.add((GT_MetaTileEntity_Hatch_InputElemental) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputElemental) + return eOutputHatches.add((GT_MetaTileEntity_Hatch_OutputElemental) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) + return eParamHatches.add((GT_MetaTileEntity_Hatch_Param) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Uncertainty) + return eUncertainHatches.add((GT_MetaTileEntity_Hatch_Uncertainty) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MufflerElemental) + return eMufflerHatches.add((GT_MetaTileEntity_Hatch_MufflerElemental) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) + return eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) + return eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputData) + return eInputData.add((GT_MetaTileEntity_Hatch_InputData) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputData) + return eOutputData.add((GT_MetaTileEntity_Hatch_OutputData) aMetaTileEntity); + return false; + } + + public final boolean addClassicToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) + return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) + return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) + return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) + return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) + return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) + return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) + return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) + return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) + return eParamHatches.add((GT_MetaTileEntity_Hatch_Param) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Uncertainty) + return eUncertainHatches.add((GT_MetaTileEntity_Hatch_Uncertainty) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) + return eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) + return eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputData) + return eInputData.add((GT_MetaTileEntity_Hatch_InputData) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputData) + return eOutputData.add((GT_MetaTileEntity_Hatch_OutputData) aMetaTileEntity); + return false; + } + + public final boolean addElementalToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputElemental) + return eInputHatches.add((GT_MetaTileEntity_Hatch_InputElemental) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputElemental) + return eOutputHatches.add((GT_MetaTileEntity_Hatch_OutputElemental) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MufflerElemental) + return eMufflerHatches.add((GT_MetaTileEntity_Hatch_MufflerElemental) aMetaTileEntity); + return false; + } + + public final boolean addClassicMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); + } + return false; + } + + public final boolean addElementalMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MufflerElemental) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eMufflerHatches.add((GT_MetaTileEntity_Hatch_MufflerElemental) aMetaTileEntity); + } + return false; + } + + @Override + public final boolean addMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MufflerElemental) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eMufflerHatches.add((GT_MetaTileEntity_Hatch_MufflerElemental) aMetaTileEntity); + } + return false; + } + + @Override + public final boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap(); + return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = getRecipeMap(); + return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputElemental) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + //((GT_MetaTileEntity_Hatch_Elemental) aMetaTileEntity).mRecipeMap = getRecipeMap(); + return eInputHatches.add((GT_MetaTileEntity_Hatch_InputElemental) aMetaTileEntity); + } + return false; + } + + @Override + public final boolean addOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputElemental) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eOutputHatches.add((GT_MetaTileEntity_Hatch_OutputElemental) aMetaTileEntity); + } + return false; + } + + @Deprecated + @Override + public final boolean addEnergyInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); + } + return false; + } + + @Deprecated + @Override + public final boolean addDynamoToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity); + } + return false; + } + + //New Method + public final boolean addEnergyIOToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity); + } + return false; + } + + //NEW METHOD + public final boolean addElementalInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputElemental) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + //((GT_MetaTileEntity_Hatch_Elemental) aMetaTileEntity).mRecipeMap = getRecipeMap(); + return eInputHatches.add((GT_MetaTileEntity_Hatch_InputElemental) aMetaTileEntity); + } + return false; + } + + //NEW METHOD + public final boolean addElementalOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputElemental) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eOutputHatches.add((GT_MetaTileEntity_Hatch_OutputElemental) aMetaTileEntity); + } + return false; + } + + //NEW METHOD + public final boolean addClassicInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap(); + return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = getRecipeMap(); + return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); + } + return false; + } + + //NEW METHOD + public final boolean addClassicOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); + } + return false; + } + + //NEW METHOD + public final boolean addParametrizerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eParamHatches.add((GT_MetaTileEntity_Hatch_Param) aMetaTileEntity); + } + return false; + } + + //NEW METHOD + public final boolean addUncertainToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Uncertainty) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eUncertainHatches.add((GT_MetaTileEntity_Hatch_Uncertainty) aMetaTileEntity); + } + return false; + } + + @Override + public final boolean addMaintenanceToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eParamHatches.add((GT_MetaTileEntity_Hatch_Param) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Uncertainty) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eUncertainHatches.add((GT_MetaTileEntity_Hatch_Uncertainty) aMetaTileEntity); + } + return false; + } + + //NEW METHOD + public final boolean addClassicMaintenanceToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); + } + return false; + } + + //NEW METHOD + public final boolean addDataConnectorToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputData) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eInputData.add((GT_MetaTileEntity_Hatch_InputData) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputData) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eOutputData.add((GT_MetaTileEntity_Hatch_OutputData) aMetaTileEntity); + } + return false; + } + //endregion + + public static void run() { + try { + adderMethodMap.put("addToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addClassicToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addElementalToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addElementalToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addMufflerToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addMufflerToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addClassicMufflerToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicMufflerToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addElementalMufflerToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addElementalMufflerToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addInputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addInputToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addOutputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addOutputToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addEnergyInputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addEnergyInputToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addDynamoToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addDynamoToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addEnergyIOToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addEnergyIOToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addElementalInputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addElementalInputToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addElementalOutputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addElementalOutputToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addClassicInputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicInputToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addClassicOutputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicOutputToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addParametrizerToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addParametrizerToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addUncertainToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addUncertainToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addMaintenanceToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addMaintenanceToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addClassicMaintenanceToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicMaintenanceToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addDataConnectorToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addDataConnectorToMachineList", IGregTechTileEntity.class, int.class)); + adderMethod = GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addThing", String.class, IGregTechTileEntity.class, int.class); + } catch (NoSuchMethodException e) { + if (DEBUG_MODE) e.printStackTrace(); + } + } + + //CALLBACK + public boolean addThing(String methodName, IGregTechTileEntity igt, int casing) { + try { + return (boolean) adderMethodMap.get(methodName).invoke(this, igt, casing); + } catch (InvocationTargetException | IllegalAccessException e) { + if (DEBUG_MODE) e.printStackTrace(); + } + return false; + } + + @Override + public String[] getInfoData() {//TODO Do it + long storedEnergy = 0; + long maxEnergy = 0; + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { + if (isValidMetaTileEntity(tHatch)) { + storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); + maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); + } + } + for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) { + if (isValidMetaTileEntity(tHatch)) { + storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); + maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); + } + } + + return new String[]{ + "Progress:", + EnumChatFormatting.GREEN + Integer.toString(mProgresstime / 20) + EnumChatFormatting.RESET + " s / " + + EnumChatFormatting.YELLOW + Integer.toString(mMaxProgresstime / 20) + EnumChatFormatting.RESET + " s", + "Energy Hatches:", + EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET + " EU / " + + EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET + " EU", + (mEUt <= 0 ? "Probably uses: " : "Probably makes: ") + + EnumChatFormatting.RED + Integer.toString(Math.abs(mEUt)) + EnumChatFormatting.RESET + " EU/t at " + + EnumChatFormatting.RED + eAmpereFlow + EnumChatFormatting.RESET + " A", + "Tier Rating: " + EnumChatFormatting.YELLOW + VN[getMaxEnergyInputTier_EM()] + EnumChatFormatting.RESET + " / " + EnumChatFormatting.GREEN + VN[getMinEnergyInputTier_EM()] + EnumChatFormatting.RESET + + " Amp Rating: " + EnumChatFormatting.GREEN + eMaxAmpereFlow + EnumChatFormatting.RESET + " A", + "Problems: " + EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + + " Efficiency: " + EnumChatFormatting.YELLOW + Float.toString(mEfficiency / 100.0F) + EnumChatFormatting.RESET + " %", + "PowerPass: " + EnumChatFormatting.BLUE + ePowerPass + EnumChatFormatting.RESET + + " SafeVoid: " + EnumChatFormatting.BLUE + eSafeVoid, + "Computation: " + EnumChatFormatting.GREEN + eAvailableData + EnumChatFormatting.RESET + " / " + EnumChatFormatting.YELLOW + eRequiredData + EnumChatFormatting.RESET + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/gui/GT_Container_MultiMachineEM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/gui/GT_Container_MultiMachineEM.java deleted file mode 100644 index 769953d0ef..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/gui/GT_Container_MultiMachineEM.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.github.technus.tectech.thing.metaTileEntity.multi.gui; - -import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_MultiblockBase_EM; -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Holo; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class GT_Container_MultiMachineEM extends GT_ContainerMetaTile_Machine { - public byte[] eParamsInStatus = new byte[20];//unused 0,G ok 1, B too low 2, R too high 3, Y blink dangerous 4,5 - public byte[] eParamsOutStatus = new byte[20]; - public byte eCertainMode = 5, eCertainStatus = 127; - public boolean ePowerPass = false, eSafeVoid = false, allowedToWork = false; - public final boolean ePowerPassButton, eSafeVoidButton, allowedToWorkButton; - - public GT_Container_MultiMachineEM(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean enablePowerPass, boolean enableSafeVoid, boolean enablePowerButton) { - super(aInventoryPlayer, aTileEntity); - ePowerPassButton=enablePowerPass; - eSafeVoidButton=enableSafeVoid; - allowedToWorkButton=enablePowerButton; - } - - public GT_Container_MultiMachineEM(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - ePowerPassButton=eSafeVoidButton=allowedToWorkButton=true; - } - - public GT_Container_MultiMachineEM(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean bindInventory) { - super(aInventoryPlayer, aTileEntity, bindInventory); - ePowerPassButton=eSafeVoidButton=allowedToWorkButton=true; - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new Slot(mTileEntity, 1, 152, -21)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, -2, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 15, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 32, false, false, 1)); - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex < 0) - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); - if ((tSlot != null) && (this.mTileEntity.getMetaTileEntity() != null)) { - GT_MetaTileEntity_MultiblockBase_EM base = (GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity(); - switch (aSlotIndex) { - case 1: - if(ePowerPassButton) { - base.ePowerPass ^= true; - if (!allowedToWorkButton) {//TRANSFORMER HACK - if (base.ePowerPass) base.getBaseMetaTileEntity().enableWorking(); - else base.getBaseMetaTileEntity().disableWorking(); - } - } - break; - case 2: - if(eSafeVoidButton) base.eSafeVoid ^= true; - break; - case 3: - if(allowedToWorkButton) { - if (base.getBaseMetaTileEntity().isAllowedToWork()) { - base.getBaseMetaTileEntity().disableWorking(); - } else { - base.getBaseMetaTileEntity().enableWorking(); - } - } - break; - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null) || (this.eParamsInStatus == null)) - return; - this.eParamsInStatus = ((GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity()).eParamsInStatus; - this.eParamsOutStatus = ((GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity()).eParamsOutStatus; - this.eCertainMode = ((GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity()).eCertainMode; - this.eCertainStatus = ((GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity()).eCertainStatus; - this.ePowerPass = ((GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity()).ePowerPass; - this.eSafeVoid = ((GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity()).eSafeVoid; - this.allowedToWork = this.mTileEntity.isAllowedToWork(); - - for (Object crafter : this.crafters) { - ICrafting var1 = (ICrafting) crafter; - int i = 100; - for (int j = 0; j < eParamsInStatus.length; j++) - var1.sendProgressBarUpdate(this, i++, eParamsInStatus[j] | (eParamsOutStatus[j] << 8)); - var1.sendProgressBarUpdate(this, 120, eCertainMode | (eCertainStatus << 8)); - var1.sendProgressBarUpdate(this, 121, (ePowerPass ? 1 : 0) + (eSafeVoid ? 2 : 0) + (allowedToWork ? 4 : 0)); - } - } - - @Override - public void updateProgressBar(int par1, int par2) { - super.updateProgressBar(par1, par2); - if (this.eParamsInStatus == null) return; - if (par1 >= 100 && par1 < 120) { - this.eParamsInStatus[par1 - 100] = (byte) (par2 & 0xff); - this.eParamsOutStatus[par1 - 100] = (byte) (par2 >>> 8); - } else if (par1 == 120) { - this.eCertainMode = (byte) (par2 & 0xff); - this.eCertainStatus = (byte) (par2 >>> 8); - } else if (par1 == 121) { - this.ePowerPass = (par2 & 1) == 1; - this.eSafeVoid = (par2 & 2) == 2; - this.allowedToWork = (par2 & 4) == 4; - } - } - - @Override - public int getSlotCount() { - return 1; - } - - @Override - public int getShiftClickSlotCount() { - return 1; - } -} \ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/gui/GT_GUIContainer_MultiMachineEM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/gui/GT_GUIContainer_MultiMachineEM.java deleted file mode 100644 index f5a39ae779..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/gui/GT_GUIContainer_MultiMachineEM.java +++ /dev/null @@ -1,205 +0,0 @@ -package com.github.technus.tectech.thing.metaTileEntity.multi.gui; - -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; -import org.lwjgl.opengl.GL11; - -import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_MultiblockBase_EM.*; -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - -/** - * Created by Tec on 21.02.2017. - */ - -public class GT_GUIContainer_MultiMachineEM extends GT_GUIContainerMetaTile_Machine { - String mName = ""; - private static byte counter = 0; - public final boolean ePowerPassButton, eSafeVoidButton, allowedToWorkButton; - - public GT_GUIContainer_MultiMachineEM(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aTextureFile, boolean enablePowerPass, boolean enableSafeVoid, boolean enablePowerButton) { - super(new GT_Container_MultiMachineEM(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "multimachines/" + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); - mName = aName; - ePowerPassButton=enablePowerPass; - eSafeVoidButton=enableSafeVoid; - allowedToWorkButton=enablePowerButton; - } - - public GT_GUIContainer_MultiMachineEM(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aTextureFile) { - super(new GT_Container_MultiMachineEM(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "multimachines/" + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); - mName = aName; - ePowerPassButton=eSafeVoidButton=allowedToWorkButton=true; - } - - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - fontRendererObj.drawString(mName, 10, -18, 16448255); - - if (mContainer != null) { - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 1) != 0) - fontRendererObj.drawString("Pipe is loose.", 10, -10, 16448255); - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 2) != 0) - fontRendererObj.drawString("Screws are loose.", 10, -2, 16448255); - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 4) != 0) - fontRendererObj.drawString("Something is stuck.", 10, 6, 16448255); - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 8) != 0) - fontRendererObj.drawString("Plating is dented.", 10, 14, 16448255); - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 16) != 0) - fontRendererObj.drawString("Circuitry burned out.", 10, 22, 16448255); - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 32) != 0) - fontRendererObj.drawString("That doesn't belong there.", 10, 30, 16448255); - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 64) != 0) - fontRendererObj.drawString("Incomplete Structure.", 10, 38, 16448255); - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 128) != 0) - fontRendererObj.drawString("Too Uncertain.", 10, 46, 16448255); - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 256) != 0) - fontRendererObj.drawString("Invalid Parameters.", 10, 54, 16448255); - - if (((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode == 0) { - if (((GT_Container_MultiMachineEM) mContainer).mActive == 0) { - fontRendererObj.drawString("Soft Hammer or press Button", 10, -10, 16448255); - fontRendererObj.drawString("to (re-)start the Machine", 10, -2, 16448255); - fontRendererObj.drawString("if it doesn't start.", 10, 6, 16448255); - } else { - fontRendererObj.drawString("Running perfectly.", 10, -10, 16448255); - } - } - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - y -= 26; - drawTexturedModalRect(x, y, 0, 0, xSize, ySize + 26); - if (this.mContainer != null && ((GT_Container_MultiMachineEM) this.mContainer).eParamsInStatus != null) { - counter = (byte) ((1 + counter) % 6); - GL11.glColor4f(1f, 1f, 1f, 1f); - - if(!ePowerPassButton) - drawTexturedModalRect(x + 151, y + 23, 215, 23, 18, 18); - else if (((GT_Container_MultiMachineEM) mContainer).ePowerPass) - drawTexturedModalRect(x + 151, y + 23, 183, 23, 18, 18); - - if(!eSafeVoidButton) - drawTexturedModalRect(x + 151, y + 41, 215, 41, 18, 18); - else if (((GT_Container_MultiMachineEM) mContainer).eSafeVoid) - drawTexturedModalRect(x + 151, y + 41, 183, 41, 18, 18); - - if(!allowedToWorkButton) - drawTexturedModalRect(x + 151, y + 57, 215, 57, 18, 18); - else if (((GT_Container_MultiMachineEM) mContainer).allowedToWork) - drawTexturedModalRect(x + 151, y + 57, 183, 57, 18, 18); - - x += 11; - y += 96; - for (int i = 0; i < 20; ) { - byte j = (byte) (i >>> 1); - LEDdrawP(x, y, i, 0, ((GT_Container_MultiMachineEM) this.mContainer).eParamsInStatus[j]); - LEDdrawP(x, y, i++, 1, ((GT_Container_MultiMachineEM) this.mContainer).eParamsOutStatus[j]); - LEDdrawP(x, y, i, 0, ((GT_Container_MultiMachineEM) this.mContainer).eParamsInStatus[j + 10]); - LEDdrawP(x, y, i++, 1, ((GT_Container_MultiMachineEM) this.mContainer).eParamsOutStatus[j + 10]); - } - - final short rU = 183, Vs = 77; - x += 140; - y -= 19; - final byte state = ((GT_Container_MultiMachineEM) this.mContainer).eCertainStatus; - switch (((GT_Container_MultiMachineEM) this.mContainer).eCertainMode) { - case 1://ooo oxo ooo - drawTexturedModalRect(x + 6, y + 6, - rU + (state == 0 ? 38 : 6), - Vs + 6, 6, 6); - break; - case 2://ooo xox ooo - drawTexturedModalRect(x, y + 6, - rU + ((state & 1) == 0 ? 32 : 0), - Vs + 6, 6, 6); - drawTexturedModalRect(x + 12, y + 6, - rU + ((state & 2) == 0 ? 44 : 12), - Vs + 6, 6, 6); - break; - case 3://oxo xox oxo - drawTexturedModalRect(x + 6, y, - rU + ((state & 1) == 0 ? 38 : 6), - Vs, 6, 6); - drawTexturedModalRect(x, y + 6, - rU + ((state & 2) == 0 ? 32 : 0), - Vs + 6, 6, 6); - drawTexturedModalRect(x + 12, y + 6, - rU + ((state & 4) == 0 ? 44 : 12), - Vs + 6, 6, 6); - drawTexturedModalRect(x + 6, y + 12, - rU + ((state & 8) == 0 ? 38 : 6), - Vs + 12, 6, 6); - break; - case 4://xox ooo xox - drawTexturedModalRect(x, y, - rU + ((state & 1) == 0 ? 32 : 0), - Vs, 6, 6); - drawTexturedModalRect(x + 12, y, - rU + ((state & 2) == 0 ? 44 : 12), - Vs, 6, 6); - drawTexturedModalRect(x, y + 12, - rU + ((state & 4) == 0 ? 32 : 0), - Vs + 12, 6, 6); - drawTexturedModalRect(x + 12, y + 12, - rU + ((state & 8) == 0 ? 44 : 12), - Vs + 12, 6, 6); - break; - case 5://xox oxo xox - drawTexturedModalRect(x, y, - rU + ((state & 1) == 0 ? 32 : 0), - Vs, 6, 6); - drawTexturedModalRect(x + 12, y, - rU + ((state & 2) == 0 ? 44 : 12), - Vs, 6, 6); - drawTexturedModalRect(x + 6, y + 6, - rU + ((state & 4) == 0 ? 38 : 6), - Vs + 6, 6, 6); - drawTexturedModalRect(x, y + 12, - rU + ((state & 8) == 0 ? 32 : 0), - Vs + 12, 6, 6); - drawTexturedModalRect(x + 12, y + 12, - rU + ((state & 16) == 0 ? 44 : 12), - Vs + 12, 6, 6); - break; - } - } - } - - private void LEDdrawP(int x, int y, int i, int j, byte status) { - final int v = 192, su = 8, sv = 6, u = 11; - switch (status) { - case STATUS_WRONG: - if (counter < 2) { - drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * j, su, sv); - break; - } else if (counter < 4) { - drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (8 + j), su, sv); - break; - } - case STATUS_OK://ok - drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (4 + j), su, sv); - break; - case STATUS_TOO_LOW://too low blink - if (counter < 3) { - drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * j, su, sv); - break; - } - case STATUS_LOW:// too low - drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (2 + j), su, sv); - break; - case STATUS_TOO_HIGH://too high blink - if (counter < 3) { - drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (8 + j), su, sv); - break; - } - case STATUS_HIGH:// too high - drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (6 + j), su, sv); - break; - } - } -} \ No newline at end of file -- cgit