From 73bd4c1cc06267ff3574230e5076c654ea300429 Mon Sep 17 00:00:00 2001 From: Technus Date: Tue, 21 Mar 2017 11:00:59 +0100 Subject: Initial work on computation multiblocks, implementing cables and I/O's --- .../java/com/github/technus/tectech/TecTech.java | 2 +- .../technus/tectech/loader/GT_Loader_Machines.java | 18 +- .../technus/tectech/thing/CustomItemList.java | 4 +- ...GT_MetaTileEntity_Hatch_ElementalContainer.java | 249 ---- .../GT_MetaTileEntity_MultiblockBase_EM.java | 1410 ------------------- .../GT_MetaTileEntity_Hatch_DataConnector.java | 152 +++ ...GT_MetaTileEntity_Hatch_ElementalContainer.java | 246 ++++ .../hatch/GT_MetaTileEntity_Hatch_InputData.java | 43 + .../GT_MetaTileEntity_Hatch_InputElemental.java | 1 - .../hatch/GT_MetaTileEntity_Hatch_OutputData.java | 71 + .../GT_MetaTileEntity_Hatch_OutputElemental.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_crafter.java | 1 - .../multi/GT_MetaTileEntity_EM_dequantizer.java | 1 - .../multi/GT_MetaTileEntity_EM_infuser.java | 30 +- .../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_scanner.java | 1 - .../multi/GT_MetaTileEntity_EM_stabilizer.java | 1 - .../multi/GT_MetaTileEntity_EM_transformer.java | 1 - .../multi/GT_MetaTileEntity_EM_wormhole.java | 1 - .../multi/GT_MetaTileEntity_MultiblockBase_EM.java | 1417 ++++++++++++++++++++ .../multi/gui/GT_Container_MultiMachineEM.java | 2 +- .../pipe/GT_MetaTileEntity_Pipe_Data.java | 161 +++ .../pipe/GT_MetaTileEntity_Pipe_EM.java | 42 +- .../metaTileEntity/pipe/iConnectsToDataPipe.java | 8 + .../gregtech/textures/blocks/iconsets/EM_BAR.png | Bin 0 -> 1166 bytes .../gregtech/textures/blocks/iconsets/EM_DATA.png | Bin 0 -> 1166 bytes .../textures/blocks/iconsets/EM_DATA_CONN.png | Bin 0 -> 1166 bytes .../textures/blocks/iconsets/EM_PIPE_CONN.png | Bin 0 -> 1166 bytes .../blocks/iconsets/OVERLAY_EM_D_ACTIVE.png | Bin 0 -> 2206 bytes .../blocks/iconsets/OVERLAY_EM_D_ACTIVE.png.mcmeta | 5 + .../blocks/iconsets/OVERLAY_EM_D_SIDES.png | Bin 0 -> 4286 bytes .../blocks/iconsets/OVERLAY_EM_D_SIDES.png.mcmeta | 5 + 37 files changed, 2146 insertions(+), 1733 deletions(-) delete mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/GT_MetaTileEntity_Hatch_ElementalContainer.java delete mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/GT_MetaTileEntity_MultiblockBase_EM.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java create 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/pipe/GT_MetaTileEntity_Pipe_Data.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/iConnectsToDataPipe.java create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_BAR.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_DATA.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_DATA_CONN.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_PIPE_CONN.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_EM_D_ACTIVE.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_EM_D_ACTIVE.png.mcmeta create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_EM_D_SIDES.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_EM_D_SIDES.png.mcmeta (limited to 'src') diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index a2879c16d8..b373ef3ec9 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -29,7 +29,7 @@ import net.minecraft.item.ItemStack; import java.util.List; @Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, dependencies = "required-after:Forge@[10.13.4.1614,);" - + "required-after:YAMCore@[0.5.70,);" + "required-after:gregtech;" + "after:CoFHCore") + + "required-after:YAMCore@[0.5.73,);" + "required-after:gregtech;" + "after:CoFHCore") public class TecTech { @SidedProxy(clientSide = Reference.CLIENTSIDE, serverSide = Reference.SERVERSIDE) diff --git a/src/main/java/com/github/technus/tectech/loader/GT_Loader_Machines.java b/src/main/java/com/github/technus/tectech/loader/GT_Loader_Machines.java index 21824b4579..d149e37da5 100644 --- a/src/main/java/com/github/technus/tectech/loader/GT_Loader_Machines.java +++ b/src/main/java/com/github/technus/tectech/loader/GT_Loader_Machines.java @@ -2,6 +2,7 @@ package com.github.technus.tectech.loader; import com.github.technus.tectech.thing.metaTileEntity.hatch.*; import com.github.technus.tectech.thing.metaTileEntity.multi.*; +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 static com.github.technus.tectech.thing.CustomItemList.*; @@ -175,10 +176,10 @@ public class GT_Loader_Machines implements Runnable { // =================================================================================================== Machine_Multi_Transformer.set(new GT_MetaTileEntity_EM_transformer(12160, "multimachine.em.transformer", "Active Transformer").getStackForm(1L)); - Machine_Multi_Infuser.set(new GT_MetaTileEntity_EM_infuser(12161,"multimachine.em.infuser","Energy infuser").getStackForm(1)); + Machine_Multi_Infuser.set(new GT_MetaTileEntity_EM_infuser(12161,"multimachine.em.infuser","Energy Infuser").getStackForm(1)); Machine_Multi_MatterToEM.set(new GT_MetaTileEntity_EM_quantizer(12162, "multimachine.em.mattertoem", "Matter Quantizer").getStackForm(1L)); Machine_Multi_EMToMatter.set(new GT_MetaTileEntity_EM_dequantizer(12163, "multimachine.em.emtomatter", "Matter Dequantizer").getStackForm(1L)); - Machine_Multi_EMjunction.set(new GT_MetaTileEntity_EM_junction(12164, "multimachine.em.junction", "Matter junction").getStackForm(1L)); + Machine_Multi_EMjunction.set(new GT_MetaTileEntity_EM_junction(12164, "multimachine.em.junction", "Matter Junction").getStackForm(1L)); Machine_Multi_EMmachine.set(new GT_MetaTileEntity_EM_machine(12165, "multimachine.em.processing", "Quantum Processing Machine").getStackForm(1L)); Machine_Multi_EMCrafter.set(new GT_MetaTileEntity_EM_crafter(12166, "multimachine.em.crafter", "Matter Assembler").getStackForm(1L)); Machine_Multi_Collider.set(new GT_MetaTileEntity_EM_collider(12167, "multimachine.em.collider", "Matter Collider").getStackForm(1L)); @@ -186,18 +187,21 @@ public class GT_Loader_Machines implements Runnable { Machine_Multi_Wormhole.set(new GT_MetaTileEntity_EM_wormhole(12169, "multimachine.em.wormhole", "Wormhole").getStackForm(1L)); Machine_Multi_Stabilizer.set(new GT_MetaTileEntity_EM_stabilizer(12170, "multimachine.em.stabilizer", "Elemental Stabilizer").getStackForm(1L)); Machine_Multi_Scanner.set(new GT_MetaTileEntity_EM_scanner(12171, "multimachine.em.scanner", "Elemental Scanner").getStackForm(1L)); - Machine_Multi_Computer.set(new GT_MetaTileEntity_EM_computer(12172, "multimachine.em.computer", "Quantum computer").getStackForm(1L)); + Machine_Multi_Computer.set(new GT_MetaTileEntity_EM_computer(12172, "multimachine.em.computer", "Quantum Computer").getStackForm(1L)); // =================================================================================================== // Hatches EM // =================================================================================================== - Parametrizer_Hatch.set(new GT_MetaTileEntity_Hatch_Param(12180, "hatch.param.tier.06", "Parametrizer for machines", 6).getStackForm(1L)); - Uncertainty_Hatch.set(new GT_MetaTileEntity_Hatch_Uncertainty(12181, "hatch.certain.tier.06", "Uncertainty resolver", 6).getStackForm(1L)); - UncertaintyX_Hatch.set(new GT_MetaTileEntity_Hatch_Uncertainty(12182, "hatch.certain.tier.10", "Uncertainty resolver X", 10).getStackForm(1L)); + Parametrizer_Hatch.set(new GT_MetaTileEntity_Hatch_Param(12180, "hatch.param.tier.08", "Parametrizer", 8).getStackForm(1L)); + Uncertainty_Hatch.set(new GT_MetaTileEntity_Hatch_Uncertainty(12181, "hatch.certain.tier.08", "Uncertainty Resolver", 10).getStackForm(1L)); + UncertaintyX_Hatch.set(new GT_MetaTileEntity_Hatch_Uncertainty(12182, "hatch.certain.tier.10", "Uncertainty Resolver X", 10).getStackForm(1L)); + dataIn_Hatch.set(new GT_MetaTileEntity_Hatch_InputData(12183, "hatch.datain.tier.08", "Optical Host Connector", 8).getStackForm(1L)); + dataOut_Hatch.set(new GT_MetaTileEntity_Hatch_OutputData(12184, "hatch.dataout.tier.08", "Optical Server Connector", 8).getStackForm(1L)); // =================================================================================================== // EM pipe // =================================================================================================== - EMpipe.set(new GT_MetaTileEntity_Pipe_EM(12199, "pipe.elementalmatter", "Quantum tunnel").getStackForm(1L)); + EMpipe.set(new GT_MetaTileEntity_Pipe_EM(12200, "pipe.elementalmatter", "Quantum Tunnel").getStackForm(1L)); + DATApipe.set(new GT_MetaTileEntity_Pipe_Data(12201, "pipe.datastream", "Optical Fiber Cable").getStackForm(1L)); } } diff --git a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java index e40b478325..0de21e30a0 100644 --- a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java +++ b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java @@ -11,7 +11,7 @@ import net.minecraft.item.ItemStack; import static gregtech.api.enums.GT_Values.W; public enum CustomItemList implements IItemContainer { - EMpipe, + EMpipe,DATApipe, eM_dynamomulti4_UV, eM_dynamomulti16_UV, eM_dynamomulti64_UV, eM_dynamomulti4_UHV, eM_dynamomulti16_UHV, eM_dynamomulti64_UHV, eM_dynamomulti4_UEV, eM_dynamomulti16_UEV, eM_dynamomulti64_UEV, @@ -27,7 +27,7 @@ public enum CustomItemList implements IItemContainer { eM_in_UV, eM_in_UHV, eM_in_UEV, eM_in_UIV, eM_in_UMV, eM_in_UXV, eM_out_UV, eM_out_UHV, eM_out_UEV, eM_out_UIV, eM_out_UMV, eM_out_UXV, eM_muffler_UV, eM_muffler_UHV, eM_muffler_UEV, eM_muffler_UIV, eM_muffler_UMV, eM_muffler_UXV, - Parametrizer_Hatch, Uncertainty_Hatch, UncertaintyX_Hatch, + Parametrizer_Hatch, Uncertainty_Hatch, UncertaintyX_Hatch, dataIn_Hatch, dataOut_Hatch, eM_Casing, eM_Field, eM_Field_Casing, eM_Coil, eM_Tele, eM_TimeSpaceWarp, debugBlock, Machine_Multi_MatterToEM, Machine_Multi_EMToMatter, Machine_Multi_EMjunction, diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/GT_MetaTileEntity_Hatch_ElementalContainer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/GT_MetaTileEntity_Hatch_ElementalContainer.java deleted file mode 100644 index 6fd6eaa403..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/GT_MetaTileEntity_Hatch_ElementalContainer.java +++ /dev/null @@ -1,249 +0,0 @@ -package com.github.technus.tectech.thing.metaTileEntity; - -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStackTree; -import com.github.technus.tectech.elementalMatter.classes.tElementalException; -import com.github.technus.tectech.elementalMatter.commonValues; -import com.github.technus.tectech.elementalMatter.interfaces.iElementalInstanceContainer; -import com.github.technus.tectech.thing.machineTT; -import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_MufflerElemental; -import com.github.technus.tectech.thing.metaTileEntity.pipe.iConnectsToEMpipe; -import gregtech.api.enums.Dyes; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; -import gregtech.api.objects.GT_RenderedTexture; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.fluids.FluidStack; - -import static com.github.technus.tectech.elementalMatter.commonValues.*; -import static gregtech.api.enums.Dyes.MACHINE_METAL; -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity; - -/** - * Created by danie_000 on 11.12.2016. - */ -public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_MetaTileEntity_Hatch implements iElementalInstanceContainer, iConnectsToEMpipe, machineTT { - private static Textures.BlockIcons.CustomIcon EM_T_SIDES; - private static Textures.BlockIcons.CustomIcon EM_T_ACTIVE; - - protected cElementalInstanceStackTree content = new cElementalInstanceStackTree(); - //float lifeTimeMult=1f; - public int postEnergize = 0; - public float overflowMatter = 0f; - public short id = -1; - private byte deathDelay = 2; - - public GT_MetaTileEntity_Hatch_ElementalContainer(int aID, String aName, String aNameRegional, int aTier, String descr) { - super(aID, aName, aNameRegional, aTier, 0, descr); - } - - public GT_MetaTileEntity_Hatch_ElementalContainer(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 0, aDescription, aTextures); - } - - @Override - public void registerIcons(IIconRegister aBlockIconRegister) { - super.registerIcons(aBlockIconRegister); - EM_T_ACTIVE = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_EM_T_ACTIVE"); - EM_T_SIDES = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_EM_T_SIDES"); - } - - @Override - public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(EM_T_ACTIVE, Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - @Override - public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, new GT_RenderedTexture(EM_T_SIDES, Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("postEnergize", postEnergize); - //aNBT.setFloat("lifeTimeMult",lifeTimeMult); - aNBT.setFloat("overflowMatter", overflowMatter); - aNBT.setTag("eM_Stacks", content.toNBT()); - aNBT.setShort("eID", id); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - postEnergize = aNBT.getInteger("postEnergize"); - //lifeTimeMult=aNBT.getFloat("lifeTimeMult"); - overflowMatter = aNBT.getFloat("overflowMatter"); - id = aNBT.getShort("eID"); - try { - content = cElementalInstanceStackTree.fromNBT(aNBT.getCompoundTag("eM_Stacks")); - } catch (tElementalException e) { - if (TecTech.ModConfig.DEBUG_MODE) e.printStackTrace(); - if (content == null) content = new cElementalInstanceStackTree(); - } - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - byte Tick = (byte) (aTick % 20); - if (decayAt == Tick) { - purgeOverflow(); - content.tickContent(postEnergize);//Hatches don't life time mult things - purgeOverflow(); - } else if (overflowAt == Tick) { - if (overflowMatter <= 0) { - deathDelay = 3; - } else { - if (deathDelay == 2) { - if (TecTech.ModConfig.BOOM_ENABLE && TecTech.Rnd.nextInt(10) == 0) - aBaseMetaTileEntity.setOnFire(); - else - TecTech.proxy.broadcast("Container0 FIRE! " + getBaseMetaTileEntity().getXCoord() + " " + getBaseMetaTileEntity().getYCoord() + " " + getBaseMetaTileEntity().getZCoord()); - } else if (deathDelay == 1) { - IGregTechTileEntity tGTTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()); - if (tGTTileEntity == null || !(tGTTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_MufflerElemental)) - tGTTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityAtSide((byte) 0); - if (tGTTileEntity == null || !(tGTTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_MufflerElemental)) - tGTTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityAtSide((byte) 1); - if (tGTTileEntity != null && (tGTTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_MufflerElemental)) { - GT_MetaTileEntity_Hatch_MufflerElemental aMetaTileEntity = (GT_MetaTileEntity_Hatch_MufflerElemental) tGTTileEntity.getMetaTileEntity(); - aMetaTileEntity.overflowMatter += overflowMatter; - if (aMetaTileEntity.overflowMatter > aMetaTileEntity.overflowMax) { - if (TecTech.ModConfig.BOOM_ENABLE) tGTTileEntity.doExplosion(V[14]); - else - TecTech.proxy.broadcast("Container1 BOOM! " + getBaseMetaTileEntity().getXCoord() + " " + getBaseMetaTileEntity().getYCoord() + " " + getBaseMetaTileEntity().getZCoord()); - } else overflowMatter = 0F; - } - } else if (deathDelay < 1) { - if (TecTech.ModConfig.BOOM_ENABLE) getBaseMetaTileEntity().doExplosion(V[14]); - else - TecTech.proxy.broadcast("Container2 BOOM! " + getBaseMetaTileEntity().getXCoord() + " " + getBaseMetaTileEntity().getYCoord() + " " + getBaseMetaTileEntity().getZCoord()); - } - deathDelay--; - } - } else if (moveAt == Tick) { - moveAround(aBaseMetaTileEntity); - getBaseMetaTileEntity().setActive(content.hasStacks()); - } - } - } - - public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { - } - - @Override - public cElementalInstanceStackTree getContainerHandler() { - return content; - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return true; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean isLiquidInput(byte aSide) { - return false; - } - - @Override - public boolean isFluidInputAllowed(FluidStack aFluid) { - return false; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean isValidSlot(int aIndex) { - return false; - } - - public int getMaxStacksCount() { - return mTier * 2; - } - - public int getMaxStackSize() { - return mTier * (mTier - 7) * 1000; - } - - @Override - public float purgeOverflow() { - return overflowMatter += content.removeOverflow(getMaxStacksCount(), getMaxStackSize()); - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public String[] getInfoData() { - if (id > 0) { - if (content == null || content.size() == 0) - return new String[]{"ID: " + EnumChatFormatting.AQUA + id, "No Stacks"}; - else { - final String[] lines = content.getElementalInfo(); - final String[] output = new String[lines.length + 1]; - output[0] = "ID: " + EnumChatFormatting.AQUA + id; - System.arraycopy(lines, 0, output, 1, lines.length); - return output; - } - } - if (content == null || content.size() == 0) return new String[]{"No Stacks"}; - return content.getElementalInfo(); - } - - public float updateSlots() { - return purgeOverflow(); - } - - @Override - public String[] getDescription() { - return new String[]{ - commonValues.tecMark, - mDescription, - "Max stacks amount: " + EnumChatFormatting.AQUA + getMaxStacksCount(), - "Stack capacity: " + EnumChatFormatting.AQUA + getMaxStackSize(), - "Place Overflow Hatch behind,on top or below", - "to provide overflow protection while this block", - "is not attached to multi block.", - "Transport range can be extended in straight", - "line up to 15 blocks with quantum tunnels.", - EnumChatFormatting.AQUA + "Must be painted to work" - }; - } - - @Override - public void onRemoval() { - if (isValidMetaTileEntity(this) && getBaseMetaTileEntity().isActive()) - if (TecTech.ModConfig.BOOM_ENABLE) getBaseMetaTileEntity().doExplosion(V[15]); - else - TecTech.proxy.broadcast("BOOM! " + getBaseMetaTileEntity().getXCoord() + " " + getBaseMetaTileEntity().getYCoord() + " " + getBaseMetaTileEntity().getZCoord()); - } -} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/GT_MetaTileEntity_MultiblockBase_EM.java deleted file mode 100644 index dcb4a7a6fc..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/GT_MetaTileEntity_MultiblockBase_EM.java +++ /dev/null @@ -1,1410 +0,0 @@ -package com.github.technus.tectech.thing.metaTileEntity; - -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.elementalMatter.classes.cElementalDefinitionStack; -import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStack; -import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStackTree; -import com.github.technus.tectech.elementalMatter.classes.tElementalException; -import com.github.technus.tectech.elementalMatter.commonValues; -import com.github.technus.tectech.thing.machineTT; -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 gregtech.api.GregTech_API; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.*; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_OreDictUnificator; -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.minecraft.world.ChunkPosition; -import net.minecraftforge.fluids.FluidStack; - -import java.util.ArrayList; - -import static com.github.technus.tectech.elementalMatter.commonValues.*; -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.enums.GT_Values.VN; - -/** - * Created by danie_000 on 27.10.2016. - */ -public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEntity_MultiBlockBase implements machineTT { - protected cElementalInstanceStackTree[] outputEM = new cElementalInstanceStackTree[0]; - - public final static ItemStack[] nothingI = new ItemStack[0]; - public final static FluidStack[] nothingF = new FluidStack[0]; - - private static Textures.BlockIcons.CustomIcon ScreenOFF; - private 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 final float[] eParamsIn = new float[20]; - public final float[] eParamsOut = new float[20]; - public final byte[] eParamsInStatus = new byte[20]; - public final byte[] eParamsOutStatus = new byte[20]; - protected final static byte PARAM_UNUSED = 0, PARAM_OK = 1, PARAM_TOO_LOW = 2, PARAM_LOW = 3, PARAM_TOO_HIGH = 4, PARAM_HIGH = 5, PARAM_WRONG = 6; - - //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, eDismatleBoom = false; - public byte eCertainMode = 0, eCertainStatus = 0, minRepairStatus = 3; - - private long eMaxAmpereFlow = 0; - private long maxEUinputMin = 0, maxEUinputMax = 0; - public long eAmpereFlow = 1; - - //init param states in constructor, or implement it in checkrecipe/outputfunction - - //METHODS TO OVERRIDE - this 3 below + checkMachine - - //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 EM_checkRecipe(ItemStack itemStack) { - return false; - } - //My code handles AMPS, if you want overclocking just modify mEUt and mMaxProgressTime, leave amps as usual! - - public void EM_checkParams() { - } - //update status of parameters in guis and "machine state" - - public void EM_outputFunction() { - } - // based on "machine state" do output, - // this must move to output EM things 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) - - //RATHER LEAVE ALONE Section - - 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 - 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); - } - - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[99], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; - } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[99]}; - } - - @Override - public final byte getTileEntityBaseType() { - return 3; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - - //Fix supermethod shit. - if (mOutputItems != null) - aNBT.setInteger("eItemsOut", mOutputItems.length); - if (mOutputFluids != null) - aNBT.setInteger("eFluidsOut", mOutputFluids.length); - - aNBT.setLong("eMaxEUmin", maxEUinputMin); - aNBT.setLong("eMaxEUmax", maxEUinputMax); - aNBT.setLong("eRating", eAmpereFlow); - aNBT.setLong("eMaxA", eMaxAmpereFlow); - 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", eDismatleBoom); - - 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 < 20; i++) - paramI.setFloat(Integer.toString(i), eParamsIn[i]); - aNBT.setTag("eParamsIn", paramI); - - NBTTagCompound paramO = new NBTTagCompound(); - for (int i = 0; i < 20; i++) - paramO.setFloat(Integer.toString(i), eParamsOut[i]); - aNBT.setTag("eParamsOut", paramO); - - NBTTagCompound paramIs = new NBTTagCompound(); - for (int i = 0; i < 20; i++) - paramIs.setByte(Integer.toString(i), eParamsInStatus[i]); - aNBT.setTag("eParamsInS", paramIs); - - NBTTagCompound paramOs = new NBTTagCompound(); - for (int i = 0; i < 20; 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"); - eCertainMode = aNBT.getByte("eCertainM"); - eCertainStatus = aNBT.getByte("eCertainS"); - minRepairStatus = aNBT.getByte("eMinRepair"); - eParameters = aNBT.getBoolean("eParam"); - ePowerPass = aNBT.getBoolean("ePass"); - eSafeVoid = aNBT.getBoolean("eVoid"); - eDismatleBoom = aNBT.getBoolean("eBoom"); - - //Fix supermethod shit. - mOutputItems = new ItemStack[aNBT.getInteger("eItemsOut")]; - for (int i = 0; i < mOutputItems.length; i++) - mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); - mOutputFluids = new FluidStack[aNBT.getInteger("eFluidsOut")]; - 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 cElementalInstanceStackTree[outputLen]; - for (int i = 0; i < outputEM.length; i++) - try { - outputEM[i] = cElementalInstanceStackTree.fromNBT( - aNBT.getCompoundTag("outputEM").getCompoundTag(Integer.toString(i))); - } catch (tElementalException e) { - if (TecTech.ModConfig.DEBUG_MODE) e.printStackTrace(); - outputEM[i] = new cElementalInstanceStackTree(); - } - } else outputEM = new cElementalInstanceStackTree[0]; - - NBTTagCompound paramI = aNBT.getCompoundTag("eParamsIn"); - for (int i = 0; i < eParamsIn.length; i++) - eParamsIn[i] = paramI.getFloat(Integer.toString(i)); - - NBTTagCompound paramO = aNBT.getCompoundTag("eParamsOut"); - for (int i = 0; i < eParamsOut.length; i++) - eParamsOut[i] = paramO.getFloat(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)); - } - - @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; - } - - @Override - public int getPollutionPerTick(ItemStack itemStack) { - return 0; - } - - @Override - public final void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (mEfficiency < 0) mEfficiency = 0; - if (--mUpdate == 0 || --mStartUpCheck == 0) { - - 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_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(); - - mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); - - if (!mMachine) - if (eDismatleBoom && mMaxProgresstime > 0) explodeMultiblock(); - else if (outputEM != null) - for (cElementalInstanceStackTree tree : outputEM) - if (tree.hasStacks()) { - explodeMultiblock(); - break; - } - - 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++; - - 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); - } else { - maxEUinputMin = 0; - maxEUinputMax = 0; - eMaxAmpereFlow = 0; - this.setEUVar(0); - } - } - - if (mStartUpCheck < 0) {//E - if (mMachine) {//S - final byte Tick = (byte) (aTick % 20); - if (multiPurge1At == Tick || multiPurge2At == Tick) - purgeAll(); - else if (multiCheckAt == 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.isRecipeInputEqual(true); - 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 (moveAt == Tick && eSafeVoid) { - for (GT_MetaTileEntity_Hatch_MufflerElemental voider : eMufflerHatches) { - if (voider.overflowMax < voider.overflowMatter) continue; - float remaining = voider.overflowMax - voider.overflowMatter; - for (GT_MetaTileEntity_Hatch_InputElemental in : eInputHatches) { - for (cElementalInstanceStack instance : in.getContainerHandler().values()) { - int qty = (int) Math.floor(remaining / instance.definition.getMass()); - if (qty > 0) { - qty = Math.min(qty, instance.amount); - voider.overflowMatter += instance.definition.getMass() * qty; - in.getContainerHandler().removeAmount(false, new cElementalDefinitionStack(instance.definition, qty)); - } - } - } - for (GT_MetaTileEntity_Hatch_OutputElemental out : eOutputHatches) { - for (cElementalInstanceStack instance : out.getContainerHandler().values()) { - int qty = (int) Math.floor(remaining / instance.definition.getMass()); - if (qty > 0) { - qty = Math.min(qty, instance.amount); - voider.overflowMatter += instance.definition.getMass() * qty; - out.getContainerHandler().removeAmount(false, new cElementalDefinitionStack(instance.definition, qty)); - } - } - } - //in case some weird shit happened here, it will still be safe - if (voider.overflowMatter > voider.overflowMax) voider.overflowMatter = voider.overflowMax; - } - } - - if (getRepairStatus() >= minRepairStatus) {//S - if (multiCheckAt == Tick) - paramsUpdate(); - - if (mMaxProgresstime > 0 && doRandomMaintenanceDamage()) {//Start - if (onRunningTick(mInventory[1])) {//Compute EU - if (!polluteEnvironment(getPollutionPerTick(mInventory[1]))) - stopMachine(); - - if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime && recipeAt == Tick) {//progress increase and done - paramsUpdate(); - EM_outputFunction(); - if (mOutputItems != null) for (ItemStack tStack : mOutputItems) - if (tStack != null) - addOutput(tStack); - - if (mOutputFluids != null && mOutputFluids.length == 1) - for (FluidStack tStack : mOutputFluids) - if (tStack != null) - addOutput(tStack); - else if (mOutputFluids != null && mOutputFluids.length > 1) - addFluidOutputs(mOutputFluids); - updateSlots(); - mOutputItems = null; - mOutputFluids = null; - outputEM = new cElementalInstanceStackTree[0]; - 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))); - } - updateSlots(); - } - } - } - } else { - if (recipeAt == Tick || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) { - if (aBaseMetaTileEntity.isAllowedToWork()) { - if (checkRecipe(mInventory[1])) { - mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); - } - updateSlots(); - } - } - } - - {//DO ONCE - 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 + (euVar >> 7), 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 + (euVar >> 7), false)) - tHatch.setEUVar(tHatch.getBaseMetaTileEntity().getStoredEU() + euVar); - } - } - } - } - } else {//not repaired - stopMachine(); - } - } else {//not machine - 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); - } - } - - @Deprecated - @Override - public final int getAmountOfOutputs() { - return 0; - } - - private void addFluidOutputs(FluidStack[] mOutputFluids2) { - for (int i = 0; i < mOutputFluids2.length; ++i) { - if (this.mOutputHatches.size() > i && this.mOutputHatches.get(i) != null && mOutputFluids2[i] != null && isValidMetaTileEntity((MetaTileEntity) this.mOutputHatches.get(i))) { - this.mOutputHatches.get(i).fill(mOutputFluids2[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 (this.mEUt > 0) { - this.EMaddEnergyOutput((long) mEUt * (long) mEfficiency / getMaxEfficiency(aStack), eAmpereFlow); - return true; - } else if (this.mEUt < 0 && !this.EMdrainEnergyInput((long) (-this.mEUt) * getMaxEfficiency(aStack) / (long) Math.max(1000, this.mEfficiency), eAmpereFlow)) { - this.stopMachine(); - return false; - } else return true; - } - - @Deprecated - @Override - public final boolean addEnergyOutput(long EU) { - if (EU <= 0L) return true; - for (GT_MetaTileEntity_Hatch tHatch : eDynamoMulti) - if (isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(EU, false)) - return true; - for (GT_MetaTileEntity_Hatch tHatch : mDynamoHatches) - if (isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(EU, false)) - return true; - return false; - } - - //new method - public final boolean EMaddEnergyOutput(long EU, long Amperes) { - if (EU <= 0L || Amperes <= 0) return true; - long euVar = EU * Amperes; - long diff; - for (GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) { - 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; - } - } - } - } - 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.getBaseMetaTileEntity().decreaseStoredEnergyUnits(EU, false)) - return true; - for (GT_MetaTileEntity_Hatch tHatch : mEnergyHatches) - if (isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(EU, false)) - return true; - return false; - } - - //new method - public final boolean EMdrainEnergyInput(long EU, long Amperes) { - if (EU <= 0L || Amperes <= 0) return true; - long euVar = EU * Amperes; - if (euVar > getEUVar() || - EU > maxEUinputMax || - (euVar - 1) / maxEUinputMin + 1 > eMaxAmpereFlow) { - if (TecTech.ModConfig.DEBUG_MODE) { - TecTech.Logger.debug("OMG1 " + euVar + " " + getEUVar() + " " + (euVar > getEUVar())); - TecTech.Logger.debug("OMG2 " + EU + " " + maxEUinputMax + " " + (EU > maxEUinputMax)); - TecTech.Logger.debug("OMG3 " + euVar + " " + eMaxAmpereFlow); - TecTech.Logger.debug("OMG4 " + ((euVar - 1) / maxEUinputMin + 1) + " " + eMaxAmpereFlow + " " + ((euVar - 1) / maxEUinputMin + 1 > eMaxAmpereFlow)); - } - return false; - } - //sub eu - setEUVar(getEUVar() - euVar); - return true; - } - - //new method - public final boolean EMoverclockAndPutValuesIn(long EU, int time) { - if (EU == 0) { - 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 - 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 int getMaxEnergyInputTier() { - return GT_Utility.getTier(maxEUinputMax); - } - - //new Method - public final int getMinEnergyInputTier() { - return GT_Utility.getTier(maxEUinputMin); - } - - @Override - public final void stopMachine() { - mOutputItems = null; - mOutputFluids = null; - //mEUt = 0; - mEfficiency = 0; - mProgresstime = 0; - mMaxProgresstime = 0; - mEfficiencyIncrease = 0; - getBaseMetaTileEntity().disableWorking(); - - float mass = 0; - if (outputEM == null) return; - for (cElementalInstanceStackTree tree : outputEM) - mass += tree.getMass(); - if (mass > 0) { - if (eMufflerHatches.size() < 1) explodeMultiblock(); - mass /= eMufflerHatches.size(); - for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) { - dump.overflowMatter += mass; - if (dump.overflowMatter > dump.overflowMax) explodeMultiblock(); - } - } - outputEM = null; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return null; - } - - @Override - public void updateSlots() { - super.updateSlots(); - purgeAll(); - } - - private void purgeAll() { - 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(); - return; - } - mass /= eMufflerHatches.size(); - for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) { - dump.overflowMatter += mass; - if (dump.overflowMatter > dump.overflowMax) explodeMultiblock(); - } - } - } - - public void cleanHatchContent(GT_MetaTileEntity_Hatch_ElementalContainer target) { - float mass = target.getContainerHandler().getMass(); - if (mass > 0) { - if (eMufflerHatches.size() < 1) explodeMultiblock(); - mass /= eMufflerHatches.size(); - for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) { - dump.overflowMatter += mass; - if (dump.overflowMatter > dump.overflowMax) explodeMultiblock(); - } - } - } - - @Override - public final boolean checkRecipe(ItemStack itemStack) {//do recipe checks, based on "machine content and state" - paramsUpdate(); - return EM_checkRecipe(itemStack); - } - - private void paramsUpdate() { - for (GT_MetaTileEntity_Hatch_Param param : eParamHatches) { - int paramID = param.param; - if (paramID < 0) continue; - eParamsIn[paramID] = param.value1f; - eParamsIn[paramID + 10] = param.value2f; - param.input1f = eParamsOut[paramID]; - param.input2f = eParamsOut[paramID + 10]; - } - EM_checkParams(); - 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 void explodeMultiblock() {//BEST METHOD EVER!!! - 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; - } - GT_Pollution.addPollution(new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), 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]); - getBaseMetaTileEntity().doExplosion(V[15]); - } - - @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).mMachineBlock = (byte) 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); - 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).mMachineBlock = (byte) aBaseCasingIndex; - return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MufflerElemental) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) 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).mMachineBlock = (byte) 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).mMachineBlock = (byte) 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).mMachineBlock = (byte) 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).mMachineBlock = (byte) aBaseCasingIndex; - return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputElemental) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) 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).mMachineBlock = (byte) aBaseCasingIndex; - return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) 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_Dynamo) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) { - ((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity).mMachineBlock = (byte) 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).mMachineBlock = (byte) aBaseCasingIndex; - return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - return eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { - ((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) { - ((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity).mMachineBlock = (byte) 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).mMachineBlock = (byte) 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).mMachineBlock = (byte) 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).mMachineBlock = (byte) 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).mMachineBlock = (byte) 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).mMachineBlock = (byte) aBaseCasingIndex; - return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) 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).mMachineBlock = (byte) 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).mMachineBlock = (byte) 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).mMachineBlock = (byte) aBaseCasingIndex; - return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - return eParamHatches.add((GT_MetaTileEntity_Hatch_Param) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Uncertainty) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) 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).mMachineBlock = (byte) aBaseCasingIndex; - return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); - } - 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()] + EnumChatFormatting.RESET + " / " + EnumChatFormatting.GREEN + VN[getMinEnergyInputTier()] + 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 - }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - //Check Machine Structure based on string array array, ond offset of the controller - public static boolean stuctureCheck(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, - IGregTechTileEntity aBaseMetaTileEntity) { - //TE Rotation - byte facing = aBaseMetaTileEntity.getFrontFacing(); - - int x, y, z, a, c;//b is y no matter what - - //perform your duties - c = -depthOffset; - for (String[] _structure : structure) {//front to back - y = verticalOffset; - for (String __structure : _structure) {//top to bottom - a = -horizontalOffset; - for (char block : __structure.toCharArray()) {//left to right - if (block > '`') {//small characters allow to skip check a-1 skip, b-2 skips etc. - a += block - '`'; - } else { - //get x y z from rotation - switch (facing) {//translation - case 4: - x = c; - z = a; - break; - case 3: - x = a; - z = -c; - break; - case 5: - x = -c; - z = -a; - break; - case 2: - x = -a; - z = c; - break; - default: - return false; - } - //Check block - switch (block) { - case '-'://must be air - if (!aBaseMetaTileEntity.getAirOffset(x, y, z)) return false; - break; - case '+'://must not be air - if (aBaseMetaTileEntity.getAirOffset(x, y, z)) return false; - break; - default: {//check for block (countable) - int pointer = block - '0'; - //countable air -> net.minecraft.block.BlockAir - if (aBaseMetaTileEntity.getBlockOffset(x, y, z) != blockType[pointer]) { - if (TecTech.ModConfig.DEBUG_MODE) - TecTech.Logger.info("Struct-block-error " + x + " " + y + " " + z + "/" + a + " " + c + "/" + aBaseMetaTileEntity.getBlockOffset(x, y, z) + " " + blockType[pointer]); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(x, y, z) != blockMeta[pointer]) { - if (TecTech.ModConfig.DEBUG_MODE) - TecTech.Logger.info("Struct-meta-id-error " + x + " " + y + " " + z + "/" + a + " " + c + "/" + aBaseMetaTileEntity.getMetaIDOffset(x, y, z) + " " + blockMeta[pointer]); - return false; - } - } - } - a++;//block in horizontal layer - } - } - y--;//horizontal layer - } - c++;//depth - } - return true; - } - - @Override - public String[] getDescription() { - return new String[]{ - commonValues.tecMark, - "Nothing special just override me." - }; - } - - @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_Uncertainty hatch : eUncertainHatches) - hatch.getBaseMetaTileEntity().setActive(false); - for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) - hatch.getBaseMetaTileEntity().setActive(false); - } - if (eDismatleBoom && mMaxProgresstime > 0) explodeMultiblock(); - else if (outputEM != null) - for (cElementalInstanceStackTree output : outputEM) - if (output.hasStacks()) { - explodeMultiblock(); - return; - } - } catch (Exception e) { - if (TecTech.ModConfig.DEBUG_MODE) e.printStackTrace(); - } - } - - protected boolean isInputEqual(boolean aDecreaseStacksizeBySuccess, boolean aDontCheckStackSizes, FluidStack[] requiredFluidInputs, ItemStack[] requiredInputs, FluidStack[] givenFluidInputs, ItemStack... givenInputs) { - if (!GregTech_API.sPostloadFinished) return false; - if (requiredFluidInputs.length > 0 && givenFluidInputs == null) return false; - int amt; - for (FluidStack tFluid : requiredFluidInputs) - if (tFluid != null) { - boolean temp = true; - amt = tFluid.amount; - for (FluidStack aFluid : givenFluidInputs) - if (aFluid != null && aFluid.isFluidEqual(tFluid)) { - if (aDontCheckStackSizes) { - temp = false; - break; - } - amt -= aFluid.amount; - if (amt < 1) { - temp = false; - break; - } - } - if (temp) return false; - } - - if (requiredInputs.length > 0 && givenInputs == null) return false; - for (ItemStack tStack : requiredInputs) { - if (tStack != null) { - amt = tStack.stackSize; - boolean temp = true; - for (ItemStack aStack : givenInputs) { - if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) { - if (aDontCheckStackSizes) { - temp = false; - break; - } - amt -= aStack.stackSize; - if (amt < 1) { - temp = false; - break; - } - } - } - if (temp) return false; - } - } - - if (aDecreaseStacksizeBySuccess) { - if (givenFluidInputs != null) { - for (FluidStack tFluid : requiredFluidInputs) { - if (tFluid != null) { - amt = tFluid.amount; - for (FluidStack aFluid : givenFluidInputs) { - if (aFluid != null && aFluid.isFluidEqual(tFluid)) { - if (aDontCheckStackSizes) { - aFluid.amount -= amt; - break; - } - if (aFluid.amount < amt) { - amt -= aFluid.amount; - aFluid.amount = 0; - } else { - aFluid.amount -= amt; - amt = 0; - break; - } - } - } - } - } - } - - if (givenInputs != null) { - for (ItemStack tStack : requiredInputs) { - if (tStack != null) { - amt = tStack.stackSize; - for (ItemStack aStack : givenInputs) { - if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) { - if (aDontCheckStackSizes) { - aStack.stackSize -= amt; - break; - } - if (aStack.stackSize < amt) { - amt -= aStack.stackSize; - aStack.stackSize = 0; - } else { - aStack.stackSize -= amt; - amt = 0; - break; - } - } - } - } - } - } - } - - return true; - } - - /** - * finds a Recipe matching the aFluid and ItemStack Inputs. - * - * @param aNotUnificated if this is T the Recipe searcher will unificate the ItemStack Inputs - * @param aVoltage Voltage of the Machine or Long.MAX_VALUE if it has no Voltage - * @param aFluids the Fluid Inputs - * @param aSpecialSlot the content of the Special Slot, the regular Manager doesn't do anything with this, but some custom ones do. - * @param aInputs the Item Inputs - * @return the Recipe it has found or null for no matching Recipe - */ - - //protected static GT_Recipe findRecipe(boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { - // // Some Recipe Classes require a certain amount of Inputs of certain kinds. Like "at least 1 Fluid + 1 Stack" or "at least 2 Stacks" before they start searching for Recipes. - // // This improves Performance massively, especially if people leave things like Circuits, Molds or Shapes in their Machines to select Sub Recipes. - // if (GregTech_API.sPostloadFinished) { - // if (mMinimalInputFluids > 0) { - // if (aFluids == null) return null; - // int tAmount = 0; - // for (FluidStack aFluid : aFluids) if (aFluid != null) tAmount++; - // if (tAmount < mMinimalInputFluids) return null; - // } - // if (mMinimalInputItems > 0) { - // if (aInputs == null) return null; - // int tAmount = 0; - // for (ItemStack aInput : aInputs) if (aInput != null) tAmount++; - // if (tAmount < mMinimalInputItems) return null; - // } - // } - // // Unification happens here in case the Input isn't already unificated. - // if (aNotUnificated) aInputs = GT_OreDictUnificator.getStackArray(true, (Object[]) aInputs); - // // Check the Recipe which has been used last time in order to not have to search for it again, if possible. - // if (aRecipe != null) - // if (!aRecipe.mFakeRecipe && aRecipe.mCanBeBuffered && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) - // return aRecipe.mEnabled && aVoltage * mAmperage >= aRecipe.mEUt ? aRecipe : null; - // // Now look for the Recipes inside the Item HashMaps, but only when the Recipes usually have Items. - // if (mUsualInputCount > 0 && aInputs != null) for (ItemStack tStack : aInputs) - // if (tStack != null) { - // Collection - // tRecipes = mRecipeItemMap.get(new GT_ItemStack(tStack)); - // if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes) - // if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) - // return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; - // tRecipes = mRecipeItemMap.get(new GT_ItemStack(GT_Utility.copyMetaData(W, tStack))); - // if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes) - // if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) - // return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; - // } - // // If the minimal Amount of Items for the Recipe is 0, then it could be a Fluid-Only Recipe, so check that Map too. - // if (mMinimalInputItems == 0 && aFluids != null) for (FluidStack aFluid : aFluids) - // if (aFluid != null) { - // Collection - // tRecipes = mRecipeFluidMap.get(aFluid.getFluid()); - // if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes) - // if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) - // return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; - // } - // // And nothing has been found. - // return null; - //} -} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java new file mode 100644 index 0000000000..ea4c7f0e2b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java @@ -0,0 +1,152 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import com.github.technus.tectech.elementalMatter.commonValues; +import com.github.technus.tectech.thing.machineTT; +import com.github.technus.tectech.thing.metaTileEntity.pipe.iConnectsToDataPipe; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.objects.GT_RenderedTexture; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.FluidStack; + +import static com.github.technus.tectech.elementalMatter.commonValues.moveAt; +import static gregtech.api.enums.Dyes.MACHINE_METAL; + +/** + * Created by danie_000 on 11.12.2016. + */ +public abstract class GT_MetaTileEntity_Hatch_DataConnector extends GT_MetaTileEntity_Hatch implements iConnectsToDataPipe, machineTT { + private static Textures.BlockIcons.CustomIcon EM_D_SIDES; + private static Textures.BlockIcons.CustomIcon EM_D_ACTIVE; + private static Textures.BlockIcons.CustomIcon EM_D_CONN; + + public short id = -1; + public int data = 0; + public byte timeout=3; + + public GT_MetaTileEntity_Hatch_DataConnector(int aID, String aName, String aNameRegional, int aTier, String descr) { + super(aID, aName, aNameRegional, aTier, 0, descr); + } + + public GT_MetaTileEntity_Hatch_DataConnector(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + } + + @Override + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + EM_D_ACTIVE = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_EM_D_ACTIVE"); + EM_D_SIDES = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_EM_D_SIDES"); + EM_D_CONN = new Textures.BlockIcons.CustomIcon("iconsets/EM_DATA_CONN"); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(EM_D_ACTIVE, Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())), new GT_RenderedTexture(EM_D_CONN)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(EM_D_SIDES, Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())), new GT_RenderedTexture(EM_D_CONN)}; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setShort("eID", id); + aNBT.setInteger("eDATA",data); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + id = aNBT.getShort("eID"); + data=aNBT.getInteger("eDATA"); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (moveAt == aTick % 20) { + if(timeout>0) timeout--; + else data=0; + moveAround(aBaseMetaTileEntity); + getBaseMetaTileEntity().setActive(data>0); + } + } + } + + public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isLiquidInput(byte aSide) { + return false; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + if (id > 0) return new String[]{ + "ID: "+ EnumChatFormatting.AQUA +id, + "Computation: "+ EnumChatFormatting.AQUA +data + }; + return new String[]{"Computation: "+ EnumChatFormatting.AQUA +data}; + } + + @Override + public String[] getDescription() { + return new String[]{ + commonValues.tecMark, + mDescription, + "High speed fibre optics connector.", + EnumChatFormatting.AQUA + "Must be painted to work" + }; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java new file mode 100644 index 0000000000..212d14586e --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java @@ -0,0 +1,246 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStackTree; +import com.github.technus.tectech.elementalMatter.classes.tElementalException; +import com.github.technus.tectech.elementalMatter.commonValues; +import com.github.technus.tectech.elementalMatter.interfaces.iElementalInstanceContainer; +import com.github.technus.tectech.thing.machineTT; +import com.github.technus.tectech.thing.metaTileEntity.pipe.iConnectsToEMpipe; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.objects.GT_RenderedTexture; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.FluidStack; + +import static com.github.technus.tectech.elementalMatter.commonValues.*; +import static gregtech.api.enums.Dyes.MACHINE_METAL; +import static gregtech.api.enums.GT_Values.V; +import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity; + +/** + * Created by danie_000 on 11.12.2016. + */ +public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_MetaTileEntity_Hatch implements iElementalInstanceContainer, iConnectsToEMpipe, machineTT { + private static Textures.BlockIcons.CustomIcon EM_T_SIDES; + private static Textures.BlockIcons.CustomIcon EM_T_ACTIVE; + private static Textures.BlockIcons.CustomIcon EM_T_CONN; + + protected cElementalInstanceStackTree content = new cElementalInstanceStackTree(); + //float lifeTimeMult=1f; + public int postEnergize = 0; + public float overflowMatter = 0f; + public short id = -1; + private byte deathDelay = 2; + + public GT_MetaTileEntity_Hatch_ElementalContainer(int aID, String aName, String aNameRegional, int aTier, String descr) { + super(aID, aName, aNameRegional, aTier, 0, descr); + } + + public GT_MetaTileEntity_Hatch_ElementalContainer(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + } + + @Override + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + EM_T_ACTIVE = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_EM_T_ACTIVE"); + EM_T_SIDES = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_EM_T_SIDES"); + EM_T_CONN = new Textures.BlockIcons.CustomIcon("iconsets/EM_PIPE_CONN"); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(EM_T_ACTIVE, Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())), new GT_RenderedTexture(EM_T_CONN)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(EM_T_SIDES, Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())), new GT_RenderedTexture(EM_T_CONN)}; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("postEnergize", postEnergize); + //aNBT.setFloat("lifeTimeMult",lifeTimeMult); + aNBT.setFloat("overflowMatter", overflowMatter); + aNBT.setTag("eM_Stacks", content.toNBT()); + aNBT.setShort("eID", id); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + postEnergize = aNBT.getInteger("postEnergize"); + //lifeTimeMult=aNBT.getFloat("lifeTimeMult"); + overflowMatter = aNBT.getFloat("overflowMatter"); + id = aNBT.getShort("eID"); + try { + content = cElementalInstanceStackTree.fromNBT(aNBT.getCompoundTag("eM_Stacks")); + } catch (tElementalException e) { + if (TecTech.ModConfig.DEBUG_MODE) e.printStackTrace(); + if (content == null) content = new cElementalInstanceStackTree(); + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + byte Tick = (byte) (aTick % 20); + if (decayAt == Tick) { + purgeOverflow(); + content.tickContent(postEnergize);//Hatches don't life time mult things + purgeOverflow(); + } else if (overflowAt == Tick) { + if (overflowMatter <= 0) { + deathDelay = 3; + } else { + if (deathDelay == 1) { + IGregTechTileEntity tGTTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()); + if (tGTTileEntity == null || !(tGTTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_MufflerElemental)) + tGTTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityAtSide((byte) 0); + if (tGTTileEntity == null || !(tGTTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_MufflerElemental)) + tGTTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityAtSide((byte) 1); + if (tGTTileEntity != null && (tGTTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_MufflerElemental)) { + GT_MetaTileEntity_Hatch_MufflerElemental aMetaTileEntity = (GT_MetaTileEntity_Hatch_MufflerElemental) tGTTileEntity.getMetaTileEntity(); + aMetaTileEntity.overflowMatter += overflowMatter; + overflowMatter = 0F; + deathDelay=3;//needed in some cases like repetitive failures. Should be 4 since there is -- at end but meh... + if (aMetaTileEntity.overflowMatter > aMetaTileEntity.overflowMax) { + if (TecTech.ModConfig.BOOM_ENABLE) tGTTileEntity.doExplosion(V[14]); + else + TecTech.proxy.broadcast("Container1 BOOM! " + getBaseMetaTileEntity().getXCoord() + " " + getBaseMetaTileEntity().getYCoord() + " " + getBaseMetaTileEntity().getZCoord()); + } + } + } else if (deathDelay < 1) { + if (TecTech.ModConfig.BOOM_ENABLE) getBaseMetaTileEntity().doExplosion(V[14]); + else + TecTech.proxy.broadcast("Container0 BOOM! " + getBaseMetaTileEntity().getXCoord() + " " + getBaseMetaTileEntity().getYCoord() + " " + getBaseMetaTileEntity().getZCoord()); + } + deathDelay--; + } + } else if (moveAt == Tick) { + moveAround(aBaseMetaTileEntity); + getBaseMetaTileEntity().setActive(content.hasStacks()); + } + } + } + + public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) {} + + @Override + public cElementalInstanceStackTree getContainerHandler() { + return content; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isLiquidInput(byte aSide) { + return false; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + public int getMaxStacksCount() { + return mTier * 2; + } + + public int getMaxStackSize() { + return mTier * (mTier - 7) * 1000; + } + + @Override + public float purgeOverflow() { + return overflowMatter += content.removeOverflow(getMaxStacksCount(), getMaxStackSize()); + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + if (id > 0) { + if (content == null || content.size() == 0) + return new String[]{"ID: " + EnumChatFormatting.AQUA + id, "No Stacks"}; + else { + final String[] lines = content.getElementalInfo(); + final String[] output = new String[lines.length + 1]; + output[0] = "ID: " + EnumChatFormatting.AQUA + id; + System.arraycopy(lines, 0, output, 1, lines.length); + return output; + } + } + if (content == null || content.size() == 0) return new String[]{"No Stacks"}; + return content.getElementalInfo(); + } + + public float updateSlots() { + return purgeOverflow(); + } + + @Override + public String[] getDescription() { + return new String[]{ + commonValues.tecMark, + mDescription, + "Max stacks amount: " + EnumChatFormatting.AQUA + getMaxStacksCount(), + "Stack capacity: " + EnumChatFormatting.AQUA + getMaxStackSize(), + "Place Overflow Hatch behind,on top or below", + "to provide overflow protection while this block", + "is not attached to multi block.", + "Transport range can be extended in straight", + "line up to 15 blocks with quantum tunnels.", + EnumChatFormatting.AQUA + "Must be painted to work" + }; + } + + @Override + public void onRemoval() { + if (isValidMetaTileEntity(this) && getBaseMetaTileEntity().isActive()) + if (TecTech.ModConfig.BOOM_ENABLE) getBaseMetaTileEntity().doExplosion(V[15]); + else + TecTech.proxy.broadcast("BOOM! " + getBaseMetaTileEntity().getXCoord() + " " + getBaseMetaTileEntity().getYCoord() + " " + getBaseMetaTileEntity().getZCoord()); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java new file mode 100644 index 0000000000..121f91b76a --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java @@ -0,0 +1,43 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; + +/** + * Created by danie_000 on 27.10.2016. + */ +public class GT_MetaTileEntity_Hatch_InputData extends GT_MetaTileEntity_Hatch_DataConnector { + public GT_MetaTileEntity_Hatch_InputData(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, "Data Input for Multiblocks"); + } + + public GT_MetaTileEntity_Hatch_InputData(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_InputData(mName, mTier, mDescription, mTextures); + } + + @Override + public boolean isInputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return false; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean canConnect(byte side) { + return isInputFacing(side); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputElemental.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputElemental.java index 4cb7f22284..c0b825d12b 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputElemental.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputElemental.java @@ -1,6 +1,5 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.thing.metaTileEntity.GT_MetaTileEntity_Hatch_ElementalContainer; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java new file mode 100644 index 0000000000..5bab844128 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java @@ -0,0 +1,71 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Data; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.util.GT_Utility; + +/** + * Created by danie_000 on 27.10.2016. + */ +public class GT_MetaTileEntity_Hatch_OutputData extends GT_MetaTileEntity_Hatch_DataConnector { + public GT_MetaTileEntity_Hatch_OutputData(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, "Data Output for Multiblocks"); + } + + public GT_MetaTileEntity_Hatch_OutputData(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_OutputData(mName, mTier, mDescription, mTextures); + } + + @Override + public boolean isInputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return false; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean canConnect(byte side) { + return isInputFacing(side); + } + + @Override + public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) {//TODO + byte color = getBaseMetaTileEntity().getColorization(); + if (color < 0) return; + byte front = aBaseMetaTileEntity.getFrontFacing(); + byte opposite = GT_Utility.getOppositeSide(getBaseMetaTileEntity().getFrontFacing()); + for (byte dist = 1; dist < 16; dist++) { + IGregTechTileEntity tGTTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityAtSideAndDistance(front, dist); + if (tGTTileEntity != null && tGTTileEntity.getColorization() == color) { + IMetaTileEntity aMetaTileEntity = tGTTileEntity.getMetaTileEntity(); + if (aMetaTileEntity != null) { + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputData && + opposite == aMetaTileEntity.getBaseMetaTileEntity().getFrontFacing()) { + return; + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Pipe_Data) { + if (((GT_MetaTileEntity_Pipe_Data) aMetaTileEntity).connectionCount > 2) return; + } else return; + } else return; + } else return; + } + //trace optics all the way to the end, no branching splitting etc. + //Coloring requirement! + //set data to match this and timout to 3 + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java index c8e65b6451..221e00e514 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java @@ -1,6 +1,5 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.thing.metaTileEntity.GT_MetaTileEntity_Hatch_ElementalContainer; import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_EM; 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_bhg.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java index f139972dd0..1bbcb939e8 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,7 +3,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.elementalMatter.commonValues; import com.github.technus.tectech.thing.block.QuantumGlass; import com.github.technus.tectech.thing.casing.GT_Container_CasingsTT; -import com.github.technus.tectech.thing.metaTileEntity.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_collider.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java index ca83d78e39..918c2041d6 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 @@ -1,7 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.elementalMatter.commonValues; -import com.github.technus.tectech.thing.metaTileEntity.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_computer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java index 224cd38926..822b7aed1c 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 @@ -1,7 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.elementalMatter.commonValues; -import com.github.technus.tectech.thing.metaTileEntity.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_crafter.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafter.java index 52774a7d29..ea354a38d8 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafter.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafter.java @@ -1,7 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.elementalMatter.commonValues; -import com.github.technus.tectech.thing.metaTileEntity.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_dequantizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java index 5b4405ce4f..38f6e9e4a8 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 @@ -3,7 +3,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.elementalMatter.commonValues; import com.github.technus.tectech.thing.block.QuantumGlass; import com.github.technus.tectech.thing.casing.GT_Container_CasingsTT; -import com.github.technus.tectech.thing.metaTileEntity.GT_MetaTileEntity_MultiblockBase_EM; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.item.ItemStack; 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 7cd9c590f3..984a2c2a67 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 @@ -3,14 +3,11 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import cofh.api.energy.IEnergyContainerItem; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.elementalMatter.commonValues; -import com.github.technus.tectech.thing.metaTileEntity.GT_MetaTileEntity_MultiblockBase_EM; import com.github.technus.tectech.thing.metaTileEntity.multi.gui.GT_GUIContainer_MultiMachineEM; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; -import ic2.api.item.IElectricItemManager; -import ic2.api.item.ISpecialElectricItem; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.Item; @@ -39,10 +36,12 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa public GT_MetaTileEntity_EM_infuser(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); + minRepairStatus=(byte) getIdealStatus(); } public GT_MetaTileEntity_EM_infuser(String aName) { super(aName); + minRepairStatus=(byte) getIdealStatus(); } public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { @@ -82,11 +81,9 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa @Override public boolean EM_checkRecipe(ItemStack itemStack) { - if (getBaseMetaTileEntity().isAllowedToWork() && getRepairStatus()==getIdealStatus() && itemStack!=null && itemStack.stackSize==1) { + if (getBaseMetaTileEntity().isAllowedToWork() && itemStack!=null && itemStack.stackSize==1) { Item ofThis=itemStack.getItem(); - if(itemStack.getItem() instanceof ISpecialElectricItem){ - doChargeItemStackSpecial((ISpecialElectricItem) ofThis,itemStack); - }else if(itemStack.getItem() instanceof IElectricItem){ + if(itemStack.getItem() instanceof IElectricItem){ doChargeItemStack((IElectricItem) ofThis,itemStack); }else if(TecTech.hasCOFH && itemStack.getItem() instanceof IEnergyContainerItem){ doChargeItemStackRF((IEnergyContainerItem) ofThis,itemStack); @@ -100,7 +97,6 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa eDismatleBoom=false; } eAmpereFlow = 0; - mEUt = 0; return ePowerPass; } @@ -132,24 +128,6 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa } } - private void doChargeItemStackSpecial(ISpecialElectricItem item, ItemStack stack ) - { - try { - final IElectricItemManager manager=item.getManager(stack); - double euDiff=item.getMaxCharge(stack) - manager.getCharge(stack); - if(euDiff>0)this.setEUVar(this.getEUVar()-this.getEUVar()>>5); - this.setEUVar( - this.getEUVar()-(long)Math.ceil( - manager.charge(stack, - Math.min(euDiff,this.getEUVar()) - ,item.getTier(stack),true,false) - )); - } catch( Exception e ) { - if(TecTech.ModConfig.DEBUG_MODE) - e.printStackTrace(); - } - } - private void doChargeItemStackRF(IEnergyContainerItem item, ItemStack stack ) { try { 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 d4d00f5195..46ad5f74f2 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 @@ -3,7 +3,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.elementalMatter.commonValues; import com.github.technus.tectech.thing.block.QuantumGlass; import com.github.technus.tectech.thing.casing.GT_Container_CasingsTT; -import com.github.technus.tectech.thing.metaTileEntity.GT_MetaTileEntity_MultiblockBase_EM; 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 gregtech.api.interfaces.metatileentity.IMetaTileEntity; 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 d20cdfc671..98a67f5c2d 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 @@ -1,7 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.elementalMatter.commonValues; -import com.github.technus.tectech.thing.metaTileEntity.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_quantizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java index 15535e8a20..706a8b7958 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,7 +11,6 @@ import com.github.technus.tectech.elementalMatter.definitions.dHadronDefinition; import com.github.technus.tectech.elementalMatter.definitions.eLeptonDefinition; import com.github.technus.tectech.thing.block.QuantumGlass; import com.github.technus.tectech.thing.casing.GT_Container_CasingsTT; -import com.github.technus.tectech.thing.metaTileEntity.GT_MetaTileEntity_MultiblockBase_EM; import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; 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 e20ff2d0bf..daa0894539 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 @@ -1,7 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.elementalMatter.commonValues; -import com.github.technus.tectech.thing.metaTileEntity.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_stabilizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java index f108020e0e..52cc4abcb2 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 @@ -1,7 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.elementalMatter.commonValues; -import com.github.technus.tectech.thing.metaTileEntity.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_transformer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java index d7865f1e53..8c06ceb7e6 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 @@ -1,7 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.elementalMatter.commonValues; -import com.github.technus.tectech.thing.metaTileEntity.GT_MetaTileEntity_MultiblockBase_EM; import com.github.technus.tectech.thing.metaTileEntity.multi.gui.GT_GUIContainer_MultiMachineEM; 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_wormhole.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java index 843e8edbfc..f332a65de4 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 @@ -1,7 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.elementalMatter.commonValues; -import com.github.technus.tectech.thing.metaTileEntity.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_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java new file mode 100644 index 0000000000..9fdd922c83 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java @@ -0,0 +1,1417 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.elementalMatter.classes.cElementalDefinitionStack; +import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStack; +import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStackTree; +import com.github.technus.tectech.elementalMatter.classes.tElementalException; +import com.github.technus.tectech.elementalMatter.commonValues; +import com.github.technus.tectech.thing.machineTT; +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 gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_OreDictUnificator; +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.minecraft.world.ChunkPosition; +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; + +import static com.github.technus.tectech.elementalMatter.commonValues.*; +import static gregtech.api.enums.GT_Values.V; +import static gregtech.api.enums.GT_Values.VN; + +/** + * Created by danie_000 on 27.10.2016. + */ +public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEntity_MultiBlockBase implements machineTT { + protected cElementalInstanceStackTree[] outputEM = new cElementalInstanceStackTree[0]; + + public final static ItemStack[] nothingI = new ItemStack[0]; + public final static FluidStack[] nothingF = new FluidStack[0]; + + private static Textures.BlockIcons.CustomIcon ScreenOFF; + private 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<>(); + + public final float[] eParamsIn = new float[20]; + public final float[] eParamsOut = new float[20]; + public final byte[] eParamsInStatus = new byte[20]; + public final byte[] eParamsOutStatus = new byte[20]; + public final static byte PARAM_UNUSED = 0, PARAM_OK = 1, PARAM_TOO_LOW = 2, PARAM_LOW = 3, PARAM_TOO_HIGH = 4, PARAM_HIGH = 5, PARAM_WRONG = 6; + + //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, eDismatleBoom = false; + public byte eCertainMode = 0, eCertainStatus = 0, minRepairStatus = 3; + + private long eMaxAmpereFlow = 0; + private long maxEUinputMin = 0, maxEUinputMax = 0; + public long eAmpereFlow = 1; + public long eRequiredData = 0; + protected long eAvailableData=0; + + //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 EM_checkRecipe(ItemStack itemStack) { + 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 EM_checkParams() {} + // update status of parameters in guis and "machine state" + // Called before check recipe, before outputting, and every second the machine is active + + public void EM_outputFunction() {} + // 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 + + //RATHER LEAVE ALONE Section + + 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 + 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); + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[99], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[99]}; + } + + @Override + public final byte getTileEntityBaseType() { + return 3; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + + //Fix supermethod shit. + if (mOutputItems != null) + aNBT.setInteger("eItemsOut", mOutputItems.length); + if (mOutputFluids != null) + aNBT.setInteger("eFluidsOut", mOutputFluids.length); + + 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", eDismatleBoom); + + 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 < 20; i++) + paramI.setFloat(Integer.toString(i), eParamsIn[i]); + aNBT.setTag("eParamsIn", paramI); + + NBTTagCompound paramO = new NBTTagCompound(); + for (int i = 0; i < 20; i++) + paramO.setFloat(Integer.toString(i), eParamsOut[i]); + aNBT.setTag("eParamsOut", paramO); + + NBTTagCompound paramIs = new NBTTagCompound(); + for (int i = 0; i < 20; i++) + paramIs.setByte(Integer.toString(i), eParamsInStatus[i]); + aNBT.setTag("eParamsInS", paramIs); + + NBTTagCompound paramOs = new NBTTagCompound(); + for (int i = 0; i < 20; 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"); + eDismatleBoom = aNBT.getBoolean("eBoom"); + + //Fix supermethod shit. + mOutputItems = new ItemStack[aNBT.getInteger("eItemsOut")]; + for (int i = 0; i < mOutputItems.length; i++) + mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); + mOutputFluids = new FluidStack[aNBT.getInteger("eFluidsOut")]; + 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 cElementalInstanceStackTree[outputLen]; + for (int i = 0; i < outputEM.length; i++) + try { + outputEM[i] = cElementalInstanceStackTree.fromNBT( + aNBT.getCompoundTag("outputEM").getCompoundTag(Integer.toString(i))); + } catch (tElementalException e) { + if (TecTech.ModConfig.DEBUG_MODE) e.printStackTrace(); + outputEM[i] = new cElementalInstanceStackTree(); + } + } else outputEM = new cElementalInstanceStackTree[0]; + + NBTTagCompound paramI = aNBT.getCompoundTag("eParamsIn"); + for (int i = 0; i < eParamsIn.length; i++) + eParamsIn[i] = paramI.getFloat(Integer.toString(i)); + + NBTTagCompound paramO = aNBT.getCompoundTag("eParamsOut"); + for (int i = 0; i < eParamsOut.length; i++) + eParamsOut[i] = paramO.getFloat(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)); + } + + @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; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public final void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (mEfficiency < 0) mEfficiency = 0; + if (--mUpdate == 0 || --mStartUpCheck == 0) { + + 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(); + + mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); + + if (!mMachine) + if (eDismatleBoom && mMaxProgresstime > 0) explodeMultiblock(); + else if (outputEM != null) + for (cElementalInstanceStackTree tree : outputEM) + if (tree.hasStacks()) { + explodeMultiblock(); + break; + } + + 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); + } else { + maxEUinputMin = 0; + maxEUinputMax = 0; + eMaxAmpereFlow = 0; + this.setEUVar(0); + } + } + + if (mStartUpCheck < 0) {//E + if (mMachine) {//S + final byte Tick = (byte) (aTick % 20); + if (multiPurge1At == Tick || multiPurge2At == Tick) + purgeAll(); + else if (multiCheckAt == 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.isRecipeInputEqual(true); + 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 (moveAt == Tick && eSafeVoid) { + for (GT_MetaTileEntity_Hatch_MufflerElemental voider : eMufflerHatches) { + if (voider.overflowMax < voider.overflowMatter) continue; + float remaining = voider.overflowMax - voider.overflowMatter; + for (GT_MetaTileEntity_Hatch_InputElemental in : eInputHatches) { + for (cElementalInstanceStack instance : in.getContainerHandler().values()) { + int qty = (int) Math.floor(remaining / instance.definition.getMass()); + if (qty > 0) { + qty = Math.min(qty, instance.amount); + voider.overflowMatter += instance.definition.getMass() * qty; + in.getContainerHandler().removeAmount(false, new cElementalDefinitionStack(instance.definition, qty)); + } + } + } + for (GT_MetaTileEntity_Hatch_OutputElemental out : eOutputHatches) { + for (cElementalInstanceStack instance : out.getContainerHandler().values()) { + int qty = (int) Math.floor(remaining / instance.definition.getMass()); + if (qty > 0) { + qty = Math.min(qty, instance.amount); + voider.overflowMatter += instance.definition.getMass() * qty; + out.getContainerHandler().removeAmount(false, new cElementalDefinitionStack(instance.definition, qty)); + } + } + } + //in case some weird shit happened here, it will still be safe + if (voider.overflowMatter > voider.overflowMax) voider.overflowMatter = voider.overflowMax; + } + } + + if (getRepairStatus() >= minRepairStatus) {//S + if (multiCheckAt == Tick) + hatchesStatusUpdate(); + + if (mMaxProgresstime > 0 && doRandomMaintenanceDamage()) {//Start + if (onRunningTick(mInventory[1])) {//Compute EU + if (!polluteEnvironment(getPollutionPerTick(mInventory[1]))) + stopMachine(); + + if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime && recipeAt == Tick) {//progress increase and done + hatchesStatusUpdate(); + EM_outputFunction(); + if (mOutputItems != null) for (ItemStack tStack : mOutputItems) + if (tStack != null) + addOutput(tStack); + + if (mOutputFluids != null && mOutputFluids.length == 1) + for (FluidStack tStack : mOutputFluids) + if (tStack != null) + addOutput(tStack); + else if (mOutputFluids != null && mOutputFluids.length > 1) + addFluidOutputs(mOutputFluids); + updateSlots(); + mOutputItems = null; + mOutputFluids = null; + outputEM = new cElementalInstanceStackTree[0]; + 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))); + } + updateSlots(); + }else hatchesStatusUpdate(); + } + } + } else { + if (recipeAt == Tick || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) { + if (aBaseMetaTileEntity.isAllowedToWork()) { + if (checkRecipe(mInventory[1])) { + mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); + } + updateSlots(); + }else hatchesStatusUpdate(); + } + } + + {//DO ONCE + 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 + (euVar >> 7), 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 + (euVar >> 7), false)) + tHatch.setEUVar(tHatch.getBaseMetaTileEntity().getStoredEU() + euVar); + } + } + } + } + } else {//not repaired + stopMachine(); + } + } else {//not machine + 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); + } + } + + @Deprecated + @Override + public final int getAmountOfOutputs() { + return 0; + } + + private void addFluidOutputs(FluidStack[] mOutputFluids2) { + for (int i = 0; i < mOutputFluids2.length; ++i) { + if (this.mOutputHatches.size() > i && this.mOutputHatches.get(i) != null && mOutputFluids2[i] != null && isValidMetaTileEntity((MetaTileEntity) this.mOutputHatches.get(i))) { + this.mOutputHatches.get(i).fill(mOutputFluids2[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); + } + + private long getAvailableData() { + long result=0; + for(GT_MetaTileEntity_Hatch_InputData in:eInputData) + result+=in.data; + return result; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if(eRequiredData>eAvailableData) return false; + if (this.mEUt > 0) { + this.EMaddEnergyOutput((long) mEUt * (long) mEfficiency / getMaxEfficiency(aStack), eAmpereFlow); + return true; + } else if (this.mEUt < 0 && !this.EMdrainEnergyInput((long) (-this.mEUt) * getMaxEfficiency(aStack) / (long) Math.max(1000, this.mEfficiency), eAmpereFlow)) { + this.stopMachine(); + return false; + } else return true; + } + + @Deprecated + @Override + public final boolean addEnergyOutput(long EU) { + if (EU <= 0L) return true; + for (GT_MetaTileEntity_Hatch tHatch : eDynamoMulti) + if (isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(EU, false)) + return true; + for (GT_MetaTileEntity_Hatch tHatch : mDynamoHatches) + if (isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(EU, false)) + return true; + return false; + } + + //new method + public final boolean EMaddEnergyOutput(long EU, long Amperes) { + if (EU <= 0L || Amperes <= 0) return true; + long euVar = EU * Amperes; + long diff; + for (GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) { + 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; + } + } + } + } + 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.getBaseMetaTileEntity().decreaseStoredEnergyUnits(EU, false)) + return true; + for (GT_MetaTileEntity_Hatch tHatch : mEnergyHatches) + if (isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(EU, false)) + return true; + return false; + } + + //new method + public final boolean EMdrainEnergyInput(long EU, long Amperes) { + if (EU <= 0L || Amperes <= 0) return true; + long euVar = EU * Amperes; + if (euVar > getEUVar() || + EU > maxEUinputMax || + (euVar - 1) / maxEUinputMin + 1 > eMaxAmpereFlow) { + if (TecTech.ModConfig.DEBUG_MODE) { + TecTech.Logger.debug("OMG1 " + euVar + " " + getEUVar() + " " + (euVar > getEUVar())); + TecTech.Logger.debug("OMG2 " + EU + " " + maxEUinputMax + " " + (EU > maxEUinputMax)); + TecTech.Logger.debug("OMG3 " + euVar + " " + eMaxAmpereFlow); + TecTech.Logger.debug("OMG4 " + ((euVar - 1) / maxEUinputMin + 1) + " " + eMaxAmpereFlow + " " + ((euVar - 1) / maxEUinputMin + 1 > eMaxAmpereFlow)); + } + return false; + } + //sub eu + setEUVar(getEUVar() - euVar); + return true; + } + + //new method + public final boolean EMoverclockAndPutValuesIn(long EU, int time) { + if (EU == 0) { + 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 + 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 int getMaxEnergyInputTier() { + return GT_Utility.getTier(maxEUinputMax); + } + + //new Method + public final int getMinEnergyInputTier() { + return GT_Utility.getTier(maxEUinputMin); + } + + @Override + public final void stopMachine() { + mOutputItems = null; + mOutputFluids = null; + //mEUt = 0; + mEfficiency = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + getBaseMetaTileEntity().disableWorking(); + + for(GT_MetaTileEntity_Hatch_OutputData data:eOutputData) + data.timeout = 0; + + float mass = 0; + if (outputEM == null) return; + for (cElementalInstanceStackTree tree : outputEM) + mass += tree.getMass(); + if (mass > 0) { + if (eMufflerHatches.size() < 1) explodeMultiblock(); + mass /= eMufflerHatches.size(); + for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) { + dump.overflowMatter += mass; + if (dump.overflowMatter > dump.overflowMax) explodeMultiblock(); + } + } + outputEM = null; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + @Override + public void updateSlots() { + super.updateSlots(); + purgeAll(); + } + + private void purgeAll() { + 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(); + return; + } + mass /= eMufflerHatches.size(); + for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) { + dump.overflowMatter += mass; + if (dump.overflowMatter > dump.overflowMax) explodeMultiblock(); + } + } + } + + public void cleanHatchContent(GT_MetaTileEntity_Hatch_ElementalContainer target) { + float mass = target.getContainerHandler().getMass(); + if (mass > 0) { + if (eMufflerHatches.size() < 1) explodeMultiblock(); + mass /= eMufflerHatches.size(); + for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) { + dump.overflowMatter += mass; + if (dump.overflowMatter > dump.overflowMax) explodeMultiblock(); + } + } + } + + @Override + public final boolean checkRecipe(ItemStack itemStack) {//do recipe checks, based on "machine content and state" + hatchesStatusUpdate(); + return EM_checkRecipe(itemStack); + } + + private void hatchesStatusUpdate() { + for (GT_MetaTileEntity_Hatch_Param param : eParamHatches) { + int paramID = param.param; + if (paramID < 0) continue; + eParamsIn[paramID] = param.value1f; + eParamsIn[paramID + 10] = param.value2f; + param.input1f = eParamsOut[paramID]; + param.input2f = eParamsOut[paramID + 10]; + } + EM_checkParams(); + + eAvailableData=getAvailableData(); + for(GT_MetaTileEntity_Hatch_OutputData data:eOutputData) + data.timeout=3; + + 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 void explodeMultiblock() {//BEST METHOD EVER!!! + 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; + } + GT_Pollution.addPollution(new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), 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 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).mMachineBlock = (byte) 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_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; + } + + @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).mMachineBlock = (byte) aBaseCasingIndex; + return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MufflerElemental) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) 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).mMachineBlock = (byte) 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).mMachineBlock = (byte) 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).mMachineBlock = (byte) 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).mMachineBlock = (byte) aBaseCasingIndex; + return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputElemental) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) 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).mMachineBlock = (byte) aBaseCasingIndex; + return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) 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_Dynamo) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) { + ((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity).mMachineBlock = (byte) 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).mMachineBlock = (byte) aBaseCasingIndex; + return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { + ((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) { + ((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity).mMachineBlock = (byte) 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).mMachineBlock = (byte) 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).mMachineBlock = (byte) 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).mMachineBlock = (byte) 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).mMachineBlock = (byte) 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).mMachineBlock = (byte) aBaseCasingIndex; + return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) 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).mMachineBlock = (byte) 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).mMachineBlock = (byte) 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).mMachineBlock = (byte) aBaseCasingIndex; + return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return eParamHatches.add((GT_MetaTileEntity_Hatch_Param) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Uncertainty) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) 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).mMachineBlock = (byte) 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).mMachineBlock = (byte) aBaseCasingIndex; + return eInputData.add((GT_MetaTileEntity_Hatch_InputData) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputData) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return eOutputData.add((GT_MetaTileEntity_Hatch_OutputData) aMetaTileEntity); + } + 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()] + EnumChatFormatting.RESET + " / " + EnumChatFormatting.GREEN + VN[getMinEnergyInputTier()] + 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 +" TFLOPS / "+EnumChatFormatting.YELLOW+eRequiredData+EnumChatFormatting.RESET+" TFLOPS" + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + //Check Machine Structure based on string array array, ond offset of the controller + public static boolean stuctureCheck(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, + IGregTechTileEntity aBaseMetaTileEntity) { + //TE Rotation + byte facing = aBaseMetaTileEntity.getFrontFacing(); + + int x, y, z, a, c;//b is y no matter what + + //perform your duties + c = -depthOffset; + for (String[] _structure : structure) {//front to back + y = verticalOffset; + for (String __structure : _structure) {//top to bottom + a = -horizontalOffset; + for (char block : __structure.toCharArray()) {//left to right + if (block > '`') {//small characters allow to skip check a-1 skip, b-2 skips etc. + a += block - '`'; + } else { + //get x y z from rotation + switch (facing) {//translation + case 4: + x = c; + z = a; + break; + case 3: + x = a; + z = -c; + break; + case 5: + x = -c; + z = -a; + break; + case 2: + x = -a; + z = c; + break; + default: + return false; + } + //Check block + switch (block) { + case '-'://must be air + if (!aBaseMetaTileEntity.getAirOffset(x, y, z)) return false; + break; + case '+'://must not be air + if (aBaseMetaTileEntity.getAirOffset(x, y, z)) return false; + break; + default: {//check for block (countable) + int pointer = block - '0'; + //countable air -> net.minecraft.block.BlockAir + if (aBaseMetaTileEntity.getBlockOffset(x, y, z) != blockType[pointer]) { + if (TecTech.ModConfig.DEBUG_MODE) + TecTech.Logger.info("Struct-block-error " + x + " " + y + " " + z + "/" + a + " " + c + "/" + aBaseMetaTileEntity.getBlockOffset(x, y, z) + " " + blockType[pointer]); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(x, y, z) != blockMeta[pointer]) { + if (TecTech.ModConfig.DEBUG_MODE) + TecTech.Logger.info("Struct-meta-id-error " + x + " " + y + " " + z + "/" + a + " " + c + "/" + aBaseMetaTileEntity.getMetaIDOffset(x, y, z) + " " + blockMeta[pointer]); + return false; + } + } + } + a++;//block in horizontal layer + } + } + y--;//horizontal layer + } + c++;//depth + } + return true; + } + + @Override + public String[] getDescription() { + return new String[]{ + commonValues.tecMark, + "Nothing special just override me." + }; + } + + @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_DataConnector hatch_data : eOutputData) { + hatch_data.timeout=0; + hatch_data.id = -1; + } + 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 (eDismatleBoom && mMaxProgresstime > 0) explodeMultiblock(); + else if (outputEM != null) + for (cElementalInstanceStackTree output : outputEM) + if (output.hasStacks()) { + explodeMultiblock(); + return; + } + } catch (Exception e) { + if (TecTech.ModConfig.DEBUG_MODE) e.printStackTrace(); + } + } + + protected boolean isInputEqual(boolean aDecreaseStacksizeBySuccess, boolean aDontCheckStackSizes, FluidStack[] requiredFluidInputs, ItemStack[] requiredInputs, FluidStack[] givenFluidInputs, ItemStack... givenInputs) { + if (!GregTech_API.sPostloadFinished) return false; + if (requiredFluidInputs.length > 0 && givenFluidInputs == null) return false; + int amt; + for (FluidStack tFluid : requiredFluidInputs) + if (tFluid != null) { + boolean temp = true; + amt = tFluid.amount; + for (FluidStack aFluid : givenFluidInputs) + if (aFluid != null && aFluid.isFluidEqual(tFluid)) { + if (aDontCheckStackSizes) { + temp = false; + break; + } + amt -= aFluid.amount; + if (amt < 1) { + temp = false; + break; + } + } + if (temp) return false; + } + + if (requiredInputs.length > 0 && givenInputs == null) return false; + for (ItemStack tStack : requiredInputs) { + if (tStack != null) { + amt = tStack.stackSize; + boolean temp = true; + for (ItemStack aStack : givenInputs) { + if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) { + if (aDontCheckStackSizes) { + temp = false; + break; + } + amt -= aStack.stackSize; + if (amt < 1) { + temp = false; + break; + } + } + } + if (temp) return false; + } + } + + if (aDecreaseStacksizeBySuccess) { + if (givenFluidInputs != null) { + for (FluidStack tFluid : requiredFluidInputs) { + if (tFluid != null) { + amt = tFluid.amount; + for (FluidStack aFluid : givenFluidInputs) { + if (aFluid != null && aFluid.isFluidEqual(tFluid)) { + if (aDontCheckStackSizes) { + aFluid.amount -= amt; + break; + } + if (aFluid.amount < amt) { + amt -= aFluid.amount; + aFluid.amount = 0; + } else { + aFluid.amount -= amt; + amt = 0; + break; + } + } + } + } + } + } + + if (givenInputs != null) { + for (ItemStack tStack : requiredInputs) { + if (tStack != null) { + amt = tStack.stackSize; + for (ItemStack aStack : givenInputs) { + if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) { + if (aDontCheckStackSizes) { + aStack.stackSize -= amt; + break; + } + if (aStack.stackSize < amt) { + amt -= aStack.stackSize; + aStack.stackSize = 0; + } else { + aStack.stackSize -= amt; + amt = 0; + break; + } + } + } + } + } + } + } + + 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 index 3b3245e3a3..25ad29c33c 100644 --- 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 @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.gui; -import com.github.technus.tectech.thing.metaTileEntity.GT_MetaTileEntity_MultiblockBase_EM; +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; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java new file mode 100644 index 0000000000..bef132bab5 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java @@ -0,0 +1,161 @@ +package com.github.technus.tectech.thing.metaTileEntity.pipe; + +import com.github.technus.tectech.elementalMatter.commonValues; +import com.github.technus.tectech.thing.machineTT; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IColoredTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaPipeEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Client; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +import static gregtech.api.enums.Dyes.MACHINE_METAL; + +/** + * Created by Tec on 26.02.2017. + */ +public class GT_MetaTileEntity_Pipe_Data extends MetaPipeEntity implements iConnectsToDataPipe, machineTT { + private static Textures.BlockIcons.CustomIcon EMpipe; + private static Textures.BlockIcons.CustomIcon EMcandy; + public byte connectionCount = 0; + + public GT_MetaTileEntity_Pipe_Data(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 0); + } + + public GT_MetaTileEntity_Pipe_Data(String aName) { + super(aName, 0); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_MetaTileEntity_Pipe_Data(mName); + } + + @Override + public float getThickNess() { + return 0.375F; + } + + @Override + public void registerIcons(IIconRegister aBlockIconRegister) { + EMpipe = new Textures.BlockIcons.CustomIcon("iconsets/EM_DATA"); + EMcandy = new Textures.BlockIcons.CustomIcon("iconsets/EM_BAR"); + super.registerIcons(aBlockIconRegister); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { + return new ITexture[]{new GT_RenderedTexture(EMpipe), new GT_RenderedTexture(EMcandy, Dyes.getModulation(aColorIndex, MACHINE_METAL.getRGBA()))}; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, byte b, ItemStack itemStack) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, byte b, ItemStack itemStack) { + return false; + } + + @Override + public void loadNBTData(NBTTagCompound nbtTagCompound) { + } + + @Override + public void saveNBTData(NBTTagCompound nbtTagCompound) { + } + + @Override + public boolean renderInside(byte b) { + return false; + } + + @Override + public byte getTileEntityBaseType() { + return 4; + } + + @Override + public String[] getDescription() { + return new String[]{ + commonValues.tecMark, + "Advanced data transmission", + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "Don't stare at the beam!", + EnumChatFormatting.AQUA + "Must be painted to work", + EnumChatFormatting.AQUA + "Do not cross,split or turn" + }; + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + return AxisAlignedBB.getBoundingBox(aX + 0.125D, aY + 0.125D, aZ + 0.125D, aX + 0.875D, aY + 0.875D, aZ + 0.875D); + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + onPostTick(aBaseMetaTileEntity,31); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if ((aTick & 31) == 31) { + byte mOld = 0; + mConnections = 0; + connectionCount = 0; + if (aBaseMetaTileEntity.getColorization() < 0) return; + for (byte i = 0, j; i < 6; i++) { + j = GT_Utility.getOppositeSide(i); + //if (!aBaseMetaTileEntity.getCoverBehaviorAtSide(i).alwaysLookConnected(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity)) { + TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i); + if (tTileEntity instanceof IColoredTileEntity) { + //if (aBaseMetaTileEntity.getColorization() >= 0) { + byte tColor = ((IColoredTileEntity) tTileEntity).getColorization(); + if (tColor != aBaseMetaTileEntity.getColorization()) continue; + //} + } + if (tTileEntity instanceof iConnectsToDataPipe && (((iConnectsToDataPipe) tTileEntity).canConnect(j))) { + mConnections |= (1 << i); + connectionCount++; + } + else if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof iConnectsToDataPipe) { + if (//((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).alwaysLookConnected(j, ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity) tTileEntity)) || + ((iConnectsToDataPipe) ((IGregTechTileEntity) tTileEntity).getMetaTileEntity()).canConnect(j)) { + mConnections |= (1 << i); + connectionCount++; + } + } + //} + //else { + // mConnections |= (1 << i); + // if (mOld != mConnections) { + // connectionCount++; + // mOld = mConnections; + // } + //} + } + } + + } else if (aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected == 4) { + aBaseMetaTileEntity.issueTextureUpdate(); + } + } + + @Override + public boolean canConnect(byte side) { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java index 9a3a86163e..f457de8e0d 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java @@ -90,7 +90,6 @@ public class GT_MetaTileEntity_Pipe_EM extends MetaPipeEntity implements iConnec @Override public String[] getDescription() { - String tecMark; return new String[]{ commonValues.tecMark, "Quantum tunneling device.", @@ -105,17 +104,21 @@ public class GT_MetaTileEntity_Pipe_EM extends MetaPipeEntity implements iConnec return AxisAlignedBB.getBoundingBox(aX + 0.125D, aY + 0.125D, aZ + 0.125D, aX + 0.875D, aY + 0.875D, aZ + 0.875D); } + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + onPostTick(aBaseMetaTileEntity,31); + } + @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { - if ((aTick & 31) == 0) { - byte mOld = 0; + if ((aTick & 31) == 31) { mConnections = 0; connectionCount = 0; if (aBaseMetaTileEntity.getColorization() < 0) return; for (byte i = 0, j; i < 6; i++) { j = GT_Utility.getOppositeSide(i); - if (!aBaseMetaTileEntity.getCoverBehaviorAtSide(i).alwaysLookConnected(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity)) { + //if (!aBaseMetaTileEntity.getCoverBehaviorAtSide(i).alwaysLookConnected(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity)) { TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i); if (tTileEntity instanceof IColoredTileEntity) { //if (aBaseMetaTileEntity.getColorization() >= 0) { @@ -125,30 +128,23 @@ public class GT_MetaTileEntity_Pipe_EM extends MetaPipeEntity implements iConnec } if (tTileEntity instanceof iConnectsToEMpipe && (((iConnectsToEMpipe) tTileEntity).canConnect(j))) { mConnections |= (1 << i); - if (mOld != mConnections) { - connectionCount++; - mOld = mConnections; - } - continue; + connectionCount++; } - if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof iConnectsToEMpipe) { - if (((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).alwaysLookConnected(j, ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity) tTileEntity)) || + else if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof iConnectsToEMpipe) { + if (//((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).alwaysLookConnected(j, ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity) tTileEntity)) || ((iConnectsToEMpipe) ((IGregTechTileEntity) tTileEntity).getMetaTileEntity()).canConnect(j)) { mConnections |= (1 << i); - if (mOld != mConnections) { - connectionCount++; - mOld = mConnections; - } + connectionCount++; } } - } else { - mConnections |= (1 << i); - if (mOld != mConnections) { - connectionCount++; - mOld = mConnections; - } - } - + //} + //else { + // mConnections |= (1 << i); + // if (mOld != mConnections) { + // connectionCount++; + // mOld = mConnections; + // } + //} } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/iConnectsToDataPipe.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/iConnectsToDataPipe.java new file mode 100644 index 0000000000..f78799e8c9 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/iConnectsToDataPipe.java @@ -0,0 +1,8 @@ +package com.github.technus.tectech.thing.metaTileEntity.pipe; + +/** + * Created by Tec on 26.02.2017. + */ +public interface iConnectsToDataPipe { + boolean canConnect(byte side); +} diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_BAR.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_BAR.png new file mode 100644 index 0000000000..b555f62ec8 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_BAR.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_DATA.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_DATA.png new file mode 100644 index 0000000000..c3b889dc79 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_DATA.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_DATA_CONN.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_DATA_CONN.png new file mode 100644 index 0000000000..222b9329ea Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_DATA_CONN.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_PIPE_CONN.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_PIPE_CONN.png new file mode 100644 index 0000000000..8754166137 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_PIPE_CONN.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_EM_D_ACTIVE.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_EM_D_ACTIVE.png new file mode 100644 index 0000000000..abfcf2b8f0 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_EM_D_ACTIVE.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_EM_D_ACTIVE.png.mcmeta b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_EM_D_ACTIVE.png.mcmeta new file mode 100644 index 0000000000..60af678259 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_EM_D_ACTIVE.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation":{ + "frametime":4 + } +} \ No newline at end of file diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_EM_D_SIDES.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_EM_D_SIDES.png new file mode 100644 index 0000000000..b50c1b7707 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_EM_D_SIDES.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_EM_D_SIDES.png.mcmeta b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_EM_D_SIDES.png.mcmeta new file mode 100644 index 0000000000..97596ba817 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_EM_D_SIDES.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation":{ + "frametime":2 + } +} \ No newline at end of file -- cgit