diff options
Diffstat (limited to 'src')
15 files changed, 337 insertions, 2375 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_DEHP.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_DEHP.java index 35e9667204..381d17463f 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_DEHP.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_DEHP.java @@ -23,6 +23,7 @@ package com.github.bartimaeusnek.bartworks.common.tileentities.multis; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; @@ -32,6 +33,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.util.GT_Config; import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Utility; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_DrillerBase; import ic2.core.block.reactor.tileentity.TileEntityNuclearReactorElectric; @@ -45,6 +47,8 @@ import net.minecraftforge.fluids.FluidRegistry; import java.lang.reflect.Field; import java.util.Arrays; +import static gregtech.api.enums.GT_Values.VN; + public class GT_TileEntity_DEHP extends GT_MetaTileEntity_DrillerBase { private static float nulearHeatMod = 2f; private byte mMode; @@ -99,10 +103,36 @@ public class GT_TileEntity_DEHP extends GT_MetaTileEntity_DrillerBase { } @Override - public String[] getDescription() { - String[] dscSteam = {"Controller Block for the Deep Earth Heat Pump " + (this.mTier > 1 ? this.mTier : ""), "Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)", "3x1x3 Base of " + this.getCasingBlockItem().name(), "1x3x1 " + this.getCasingBlockItem().name() + " pillar (Center of base)", "1x3x1 " + this.getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)", "1x Input Hatch (One of base casings)", "1x Output Hatch (One of base casings)", "1x Maintenance Hatch (One of base casings)", "1x " + GT_Values.VN[this.getMinTier()] + "+ Energy Hatch (Any bottom layer casing)", "Consumes " + GT_Values.V[this.mTier + 2] + "EU/t", "Has 4 Modes, use the Screwdriver to change them:", "0 Idle, 1 Steam, 2 Superheated Steam (requires Distilled Water), 3 Retract", "Explodes when it runs out of Water/Distilled Water", "Converts " + (long) (this.mTier * 1200 * 20) + "L/s Water(minus 10% per Maintenance Problem) to Steam", "Converts " + (long) (this.mTier * 600 * 20) + "L/s Distilled Water(minus 10% per Maintenance Problem) to SuperheatedSteam"}; - String[] dscCooleant = {"Controller Block for the Deep Earth Heat Pump " + (this.mTier > 1 ? this.mTier : ""), "Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)", "3x1x3 Base of " + this.getCasingBlockItem().name(), "1x3x1 " + this.getCasingBlockItem().name() + " pillar (Center of base)", "1x3x1 " + this.getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)", "1x Input Hatch (One of base casings)", "1x Output Hatch (One of base casings)", "1x Maintenance Hatch (One of base casings)", "1x " + GT_Values.VN[this.getMinTier()] + "+ Energy Hatch (Any bottom layer casing)", "Consumes " + GT_Values.V[this.mTier + 2] + "EU/t", "Has 4 Modes, use the Screwdriver to change them:", "0 Idle, 1 & 2 Coolant Heating Mode (no Difference between them), 3 Retract", "Explodes when it runs out of Coolant", "Heats up " + (long) (this.mTier * 24 * ((double) GT_TileEntity_DEHP.nulearHeatMod)) * 20 + "L/s Coolant(minus 10% per Maintenance Problem)"}; - return ConfigHandler.DEHPDirectSteam ? dscSteam : dscCooleant; + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + String casings = getCasingBlockItem().get(0).getDisplayName(); + tt.addMachineType("Geothermal Heat Pump") + .addInfo("Consumes " + GT_Values.V[this.mTier + 2] + "EU/t") + .addInfo("Has 4 Modes, use the Screwdriver to change them:"); + if (ConfigHandler.DEHPDirectSteam) { + tt.addInfo("0 Idle, 1 Steam, 2 Superheated Steam (requires Distilled Water), 3 Retract") + .addInfo("Explodes when it runs out of Water/Distilled Water") + .addInfo("Converts " + (long) (this.mTier * 1200 * 20) + "L/s Water(minus 10% per Maintenance Problem) to Steam") + .addInfo("Converts " + (long) (this.mTier * 600 * 20) + "L/s Distilled Water(minus 10% per Maintenance Problem) to SuperheatedSteam"); + + } else { + tt.addInfo("0 Idle, 1 & 2 Coolant Heating Mode (no Difference between them), 3 Retract") + .addInfo("Explodes when it runs out of Coolant") + .addInfo("Heats up " + (long) (this.mTier * 24 * ((double) GT_TileEntity_DEHP.nulearHeatMod)) * 20 + "L/s Coolant(minus 10% per Maintenance Problem)"); + } + tt.addSeparator() + .beginStructureBlock(3, 7, 3, false) + .addController("Front bottom") + .addStructureInfo(casings + " form the 3x1x3 Base") + .addOtherStructurePart(casings, " 1x3x1 pillar above the center of the base (2 minimum total)") + .addOtherStructurePart(getFrameMaterial().mName + " Frame Boxes", "Each pillar's side and 1x3x1 on top") + .addEnergyHatch(VN[getMinTier()] + "+, Any base casing") + .addMaintenanceHatch("Any base casing") + .addInputBus("Mining Pipes, optional, any base casing") + .addInputHatch("Any base casing") + .addOutputHatch("Any base casing") + .toolTipFinisher(BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get()); + return tt; } @Override @@ -188,7 +218,7 @@ public class GT_TileEntity_DEHP extends GT_MetaTileEntity_DrillerBase { return true; } - if (!this.tryLowerPipe()) { + if (tryLowerPipeState(false) != 0) { if (this.waitForPipes()) { return false; } else { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java index 74e540f46e..f13352e09d 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java @@ -23,7 +23,6 @@ package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega; import com.github.bartimaeusnek.bartworks.API.LoaderReference; -import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; @@ -32,49 +31,94 @@ import com.github.bartimaeusnek.bartworks.util.MegaUtils; import com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti; import com.github.bartimaeusnek.crossmod.tectech.helper.TecTechUtils; import com.github.bartimaeusnek.crossmod.tectech.tileentites.tiered.LowPowerLaser; +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import cpw.mods.fml.common.Optional; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; +import gregtech.api.enums.HeatingCoilLevel; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_ElectricBlastFurnace; +import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; -import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import java.lang.reflect.Field; import java.util.*; import java.util.stream.Collectors; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAdder; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.GT_Values.V; +import static gregtech.api.util.GT_StructureUtility.*; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; @Optional.Interface(iface = "com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti", modid = "tectech", striprefs = true) public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBlastFurnace implements TecTechEnabledMulti { + private static final int CASING_INDEX = 11; + private static final IStructureDefinition<GT_TileEntity_MegaBlastFurnace> STRUCTURE_DEFINITION = StructureDefinition.<GT_TileEntity_MegaBlastFurnace>builder() + .addShape("main", createShape()) + .addElement('t', ofHatchAdderOptional(GT_TileEntity_MegaBlastFurnace::addOutputHatchToTopList, CASING_INDEX, 1, GregTech_API.sBlockCasings1, CASING_INDEX)) + .addElement('m', ofHatchAdder(GT_TileEntity_MegaBlastFurnace::addMufflerToMachineList, CASING_INDEX, 2)) + .addElement('C', ofCoil(GT_TileEntity_MegaBlastFurnace::setCoilLevel, GT_MetaTileEntity_ElectricBlastFurnace::getCoilLevel)) + .addElement('g', ofBlockAdder(GT_TileEntity_MegaBlastFurnace::addGlas, ItemRegistry.bw_glasses[0], 1)) + .addElement('b', ofHatchAdderOptional(GT_TileEntity_MegaBlastFurnace::addBottomHatch, CASING_INDEX, 3, GregTech_API.sBlockCasings1, CASING_INDEX)) + .build(); + + private static String[][] createShape() { + String[][] raw = new String[20][]; + + raw[0] = new String[15]; + String topCasing = "ttttttttttttttt"; + String mufflerLine = "tmmmmmmmmmmmmmt"; + raw[0][0] = topCasing; + for (int i = 1; i < 14; i++) { + raw[0][i] = mufflerLine; + } + raw[0][14] = topCasing; + + raw[1] = new String[15]; + String allGlass = "ggggggggggggggg"; + String allCoil = "gCCCCCCCCCCCCCg"; + String middleLine = "gC-----------Cg"; + raw[1][0] = allGlass; + raw[1][1] = allCoil; + raw[1][13] = allCoil; + raw[1][14] = allGlass; + for (int i = 2; i < 13; i++) { + raw[1][i] = middleLine; + } + for (int i = 2; i < 19; i++) { + raw[i] = raw[1]; + } + String bottomCasing = "bbbbbbbbbbbbbbb"; + raw[19] = new String[15]; + for (int i = 0; i < 15; i++) { + raw[19][i] = bottomCasing; + } + + raw[17] = Arrays.copyOf(raw[17], raw[17].length); + raw[17][0] = "ggggggg~ggggggg"; + + return transpose(raw); + } + private int mHeatingCapacity; private byte glasTier; private int polPtick = super.getPollutionPerTick(null) * ConfigHandler.megaMachinesMax; - static Field controllerY; - - static { - try { - controllerY = GT_MetaTileEntity_ElectricBlastFurnace.class.getDeclaredField("controllerY"); - } catch (NoSuchFieldException e) { - MainMod.LOGGER.catching(e); - } - controllerY.setAccessible(true); - } public GT_TileEntity_MegaBlastFurnace(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -84,16 +128,36 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl super(aName); } - public String[] getDescription() { - String[] dsc = StatCollector.translateToLocal("tooltip.tile.mbf.0.name").split(";"); - String tmp = dsc[dsc.length - 1]; - dsc[dsc.length - 1] = tmp + " " + 20 * this.getPollutionPerTick(null) + " " + StatCollector.translateToLocal("tooltip.tile.mbf.1.name"); - String[] fdsc = new String[dsc.length + 1]; - for (int i = 0; i < dsc.length; i++) { - fdsc[i] = dsc[i]; - fdsc[dsc.length] = BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get(); - } - return fdsc; + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Blast Furnace") + .addInfo("Controller block for the Mega Blast Furnace") + .addInfo("You can use some fluids to reduce recipe time. Place the circuit in the Input Bus") + .addInfo("Each 900K over the min. Heat required multiplies EU/t by 0.95") + .addInfo("Each 1800K over the min. Heat required allows for one upgraded overclock instead of normal") + .addInfo("Upgraded overclocks reduce recipe time to 25% (instead of 50%) and increase EU/t to 400%") + .addInfo("Additionally gives +100K for every tier past MV") + .addPollutionAmount(20 * getPollutionPerTick(null)) + .addSeparator() + .beginStructureBlock(15, 20, 15, true) + .addController("Front bottom") + .addCasingInfo("Heat Proof Machine Casing", 0) + .addOtherStructurePart("Heating Coils", "Inner 13x18x13 (Hollow)") + .addOtherStructurePart("Borosilicate Glass", "Outer 15x18x15") + .addStructureInfo("The glass tier limits the Energy Input tier") + .addEnergyHatch("Any bottom layer casing") + .addMaintenanceHatch("Any bottom layer casing") + .addMufflerHatch("Top middle 13x13") + .addInputBus("Any bottom layer casing") + .addInputHatch("Any bottom layer casing") + .addOutputBus("Any bottom layer casing") + .addOutputHatch("Gasses, Any top layer casing") + .addStructureInfo("Recovery amount scales with Muffler Hatch tier") + .addOutputHatch("Platline fluids, Any bottom layer casing") + .addStructureHint("This Mega Multiblock is too big to have its structure hologram displayed fully.") + .toolTipFinisher(BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get()); + return tt; } @SuppressWarnings("rawtypes") @@ -223,6 +287,7 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl return timesOverclocked; } + @Override public String[] getInfoData() { int mPollutionReduction = 0; @@ -263,60 +328,6 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl return super.getMaxInputVoltage(); } - private boolean getCoilHeat(IGregTechTileEntity iGregTechTileEntity, int y) { - int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX * 7; - int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ * 7; - int internalH = 0; - for (int x = -6; x <= 6; x++) { - for (int z = -6; z <= 6; z++) { - if (Math.abs(x) < 6 && Math.abs(z) != 6) - continue; - byte tUsedMeta = iGregTechTileEntity.getMetaIDOffset(xDir + x, y, zDir + z); - switch (tUsedMeta) { - case 0: // cupronickel coil - internalH = 1801; - break; - case 1: // Kanthal coil - internalH = 2701; - break; - case 2: // nichrome coil - internalH = 3601; - break; - case 3: // tungstensteel coil - internalH = 4501; - break; - case 4: // HSS-G coil - internalH = 5401; - break; - case 5: // naquadah coil - internalH = 7201; - break; - case 6: // naquadah alloy coil - internalH = 8101; - break; - case 7: // fluxed electrum coil - internalH = 9901; - break; - case 8: // awakened draconium coil - internalH = 10801; - break; - case 9: // HSS-S coil - internalH = 6301; - break; - case 10: // trinium coil - internalH = 9001; - default: - break; - } - if (this.mHeatingCapacity > 0 && internalH != this.mHeatingCapacity) - return false; - else if (this.mHeatingCapacity == 0) - this.mHeatingCapacity = internalH; - } - } - return true; - } - @Override public int getPollutionPerTick(ItemStack aStack) { return this.polPtick; @@ -409,45 +420,54 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl } @Override - public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - try { - controllerY.set(this, iGregTechTileEntity.getYCoord() - 2); - } catch (IllegalAccessException e) { - MainMod.LOGGER.catching(e); - } + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped(); + } + + @Override + @SuppressWarnings({"rawtypes", "unchecked"}) + public IStructureDefinition<GT_MetaTileEntity_ElectricBlastFurnace> getStructureDefinition() { + // hack to get around generic + return (IStructureDefinition) STRUCTURE_DEFINITION; + } + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece("main", stackSize, hintsOnly, 7, 17, 0); + } + + private boolean addGlas(Block block, int meta) { + if (block != ItemRegistry.bw_glasses[0]) + return false; + byte tier = BW_Util.getTierFromGlasMeta(meta); + if (glasTier > 0) + return tier == glasTier; + glasTier = tier; + return true; + } + + @Override + public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { if (LoaderReference.tectech) { this.getTecTechEnergyMultis().clear(); this.getTecTechEnergyTunnels().clear(); } this.mHeatingCapacity = 0; - boolean ret; - ret = BW_Util.check_layer(iGregTechTileEntity, 7, -2, -1, GregTech_API.sBlockCasings1, 11, 7, false, false, true, GregTech_API.sBlockCasings1, 11, true, 11); - ret &= BW_Util.check_layer(iGregTechTileEntity, 7, 17, 18, GregTech_API.sBlockCasings1, 11, 7, false, null, -1, 11); - ret &= BW_Util.check_layer(iGregTechTileEntity, 6, -1, 17, GregTech_API.sBlockCasings5, -1, 7, false, false, true, Blocks.air, -1, false, 11); - - for (int y = -1; y < 17; y++) { - ret &= BW_Util.check_layer(iGregTechTileEntity, 7, y, y + 1, ItemRegistry.bw_glasses[0], -1, 7, y == 0, false, false, null, -1, false, 11); - if (!this.getCoilHeat(iGregTechTileEntity, y)) - return false; - List<Byte> metasFromLayer = BW_Util.getMetasFromLayer(iGregTechTileEntity, 7, y, y + 1, 7, y == 0, false, false); - for (Byte meta : metasFromLayer) { - byte inttier = BW_Util.getTierFromGlasMeta(meta); - if (this.glasTier > 0 && inttier != this.glasTier) - return false; - else if (this.glasTier == 0) - this.glasTier = inttier; - } - } + glasTier = 0; - int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX * 7; - int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ * 7; + setCoilLevel(HeatingCoilLevel.None); - for (int z = -6; z <= 6; z++) - for (int x = -6; x <= 6; x++) - if (!this.addMufflerToMachineList(iGregTechTileEntity.getIGregTechTileEntityOffset(xDir + x, 17, zDir + z), 11)) - return false; + this.mPollutionOutputHatches.clear(); + + if (!checkPiece("main", 7, 17, 0)) + return false; + + if (getCoilLevel() == HeatingCoilLevel.None) + return false; + + if (mMaintenanceHatches.size() != 1) + return false; if (LoaderReference.tectech && this.glasTier != 8) if (!areLazorsLowPowa() || areThingsNotProperlyTiered(this.getTecTechEnergyTunnels()) || areThingsNotProperlyTiered(this.getTecTechEnergyMultis())) @@ -458,7 +478,9 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl if (this.glasTier < hatchEnergy.mTier) return false; - return ret && !this.mMaintenanceHatches.isEmpty() && !this.mOutputBusses.isEmpty() && !this.mInputBusses.isEmpty(); + this.mHeatingCapacity = (int) getCoilLevel().getHeat() + 100 * (GT_Utility.getTier(getMaxInputVoltage()) - 2); + + return true; } @SuppressWarnings("rawtypes") diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java index 64b0dd182f..7c1f13d200 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java @@ -24,25 +24,111 @@ package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import com.github.bartimaeusnek.bartworks.util.*; -import com.google.common.collect.ArrayListMultimap; +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.IStructureElement; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_DistillationTower; -import net.minecraft.block.Block; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; +import java.util.List; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; public class GT_TileEntity_MegaDistillTower extends GT_MetaTileEntity_DistillationTower { + private static final IStructureDefinition<GT_TileEntity_MegaDistillTower> STRUCTURE_DEFINITION = StructureDefinition.<GT_TileEntity_MegaDistillTower>builder() + .addShape(STRUCTURE_PIECE_BASE, transpose(new String[][]{ + {"bbbbbbb~bbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb"}, + })) + .addShape(STRUCTURE_PIECE_LAYER, transpose(new String[][]{ + {"lllllllllllllll", "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", "lllllllllllllll"}, + {"lllllllllllllll", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "lllllllllllllll"}, + {"lllllllllllllll", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "lllllllllllllll"}, + {"lllllllllllllll", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "lllllllllllllll"}, + {"lllllllllllllll", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "l-------------l", "lllllllllllllll"}, + })) + .addElement('b', ofChain( + ofHatchAdder(GT_TileEntity_MegaDistillTower::addEnergyInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_TileEntity_MegaDistillTower::addOutputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_TileEntity_MegaDistillTower::addInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_TileEntity_MegaDistillTower::addMaintenanceToMachineList, CASING_INDEX, 1), + onElementPass(GT_TileEntity_MegaDistillTower::onCasingFound, ofBlock(GregTech_API.sBlockCasings4, 1)) + )) + .addElement('l', ofChain( + ofHatchAdder(GT_TileEntity_MegaDistillTower::addEnergyInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_TileEntity_MegaDistillTower::addLayerOutputHatch, CASING_INDEX, 2), + ofHatchAdder(GT_TileEntity_MegaDistillTower::addMaintenanceToMachineList, CASING_INDEX, 1), + onElementPass(GT_TileEntity_MegaDistillTower::onCasingFound, ofBlock(GregTech_API.sBlockCasings4, 1)) + )) + // this one is too complex and cannot be expressed with a combination of existing IStructureElement + .addElement('c', new IStructureElement<GT_TileEntity_MegaDistillTower>() { + @Override + public boolean check(GT_TileEntity_MegaDistillTower t, World world, int x, int y, int z) { + if (world.isAirBlock(x, y, z)) { + if (t.mTopState < 1) { + t.mTopState = 0; + return true; + } + // definitely top - cannot be air + return false; + } + // from here on we must be looking at a top layer, since it's not air + if (t.mTopState == 0) + // must be air but failed, so no + return false; + t.mTopState = 1; + // hatch adder + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof IGregTechTileEntity) { + IGregTechTileEntity entity = (IGregTechTileEntity) tileEntity; + if (t.addLayerOutputHatch(entity, CASING_INDEX)) { + t.onTopLayerFound(false); + return true; + } + } + // block adder + if(world.getBlock(x, y, z) == GregTech_API.sBlockCasings4 && world.getBlockMetadata(x, y, z) == 1) { + t.onTopLayerFound(true); + return true; + } else { + return false; + } + } + + @Override + public boolean spawnHint(GT_TileEntity_MegaDistillTower t, World world, int x, int y, int z, ItemStack trigger) { + if (trigger.stackSize == 1) + StructureLibAPI.hintParticle(world, x, y, z, GregTech_API.sBlockCasings4, 1); + return true; + } - private static final int CASING_INDEX = 49; + @Override + public boolean placeBlock(GT_TileEntity_MegaDistillTower t, World world, int x, int y, int z, ItemStack trigger) { + if (trigger.stackSize == 1) { + world.setBlock(x, y, z, GregTech_API.sBlockCasings4, 1, 3); + return true; + } + world.setBlockToAir(x, y, z); + return false; + } + } + ) + .build(); + + // -1 => maybe top, maybe not, 0 => definitely not top, 1 => definitely top + private int mTopState = -1; public GT_TileEntity_MegaDistillTower(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -58,106 +144,64 @@ public class GT_TileEntity_MegaDistillTower extends GT_MetaTileEntity_Distillati } @Override - public String[] getDescription() { - return new String[]{ - "Controller Block for the Mega Distillation Tower", - "Size(WxHxD): 15xhx15 (Hollow), with h ranging from 16 to 56", - "Controller (Front bottom)", - "1+ Input Hatch (Any bottom layer casing)", - "1+ Output Bus (Any bottom layer casing)", - "An \"Output Layer\" consists of 5 layers!", - "2-11+ Output Hatch (One or more per Output Layer)", - "1x Maintenance Hatch (Any casing)", - "1+ Energy Hatch (Any casing)", - "Fluids are only put out at the correct height", - "The correct height equals the slot number in the NEI recipe", - "Clean Stainless Steel Machine Casings for the rest (15 x h - 5 at least!)", - BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get() - }; + protected GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Distillery") + .addInfo("Controller block for the Distillation Tower") + .addInfo("Fluids are only put out at the correct height") + .addInfo("The correct height equals the slot number in the NEI recipe") + .addSeparator() + .beginVariableStructureBlock(15, 15, 16, 56, 15, 15, true) + .addController("Front bottom") + .addOtherStructurePart("Clean Stainless Steel Machine Casing", "15 x h - 5 (minimum)") + .addEnergyHatch("Any casing") + .addMaintenanceHatch("Any casing") + .addInputHatch("Any bottom layer casing") + .addOutputBus("Any bottom layer casing") + .addOutputHatch("2-11x Output Hatches (One per Output Layer except bottom layer)") + .addStructureInfo("An \"Output Layer\" consists of 5 layers!") + .addStructureHint("This Mega Multiblock is too big to have its structure hologram displayed fully.") + .toolTipFinisher(BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get()); + return tt; } - private short controllerY = 0; - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { - LAYERMAP.clear(); - controllerY = aBaseMetaTileEntity.getYCoord(); - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 7; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 7; - int x, z, y = 0, casingAmount = 0; - boolean reachedTop = false; - - IGregTechTileEntity tileEntity; - Block block; - for (x = xDir - 7; x <= xDir + 7; ++x) { - for (z = zDir - 7; z <= zDir + 7; ++z) { - if (x != 0 || z != 0) { - tileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(x, y, z); - block = aBaseMetaTileEntity.getBlockOffset(x, y, z); - if (!this.addInputToMachineList(tileEntity, CASING_INDEX) && !this.addOutputToMachineList(tileEntity, CASING_INDEX) && !this.addMaintenanceToMachineList(tileEntity, CASING_INDEX) && !this.addEnergyInputToMachineList(tileEntity, CASING_INDEX)) { - if (block != GregTech_API.sBlockCasings4 || aBaseMetaTileEntity.getMetaIDOffset(x, y, z) != 1) { - return false; - } + @SuppressWarnings({"rawtypes", "unchecked"}) + public IStructureDefinition<GT_MetaTileEntity_DistillationTower> getStructureDefinition() { + return (IStructureDefinition) STRUCTURE_DEFINITION; + } - ++casingAmount; - } - } - } - } - for (y = y + 1; y <= 60 && !reachedTop; ++y) { - for (x = -7; x <= 7; ++x) { - for (z = -7; z <= 7; ++z) { - tileEntity = aBaseMetaTileEntity.getIGregTechTileEntity(aBaseMetaTileEntity.getXCoord() + xDir + x, aBaseMetaTileEntity.getYCoord() + y, aBaseMetaTileEntity.getZCoord() + zDir + z); - block = aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getXCoord() + xDir + x, aBaseMetaTileEntity.getYCoord() + y, aBaseMetaTileEntity.getZCoord() + zDir + z); - final boolean middle = Math.abs(x) < 7 && Math.abs(z) != 7; - if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getXCoord() + xDir + x, aBaseMetaTileEntity.getYCoord() + y, aBaseMetaTileEntity.getZCoord() + zDir + z)) { - if (!middle) { - //aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getXCoord() + xDir + x, aBaseMetaTileEntity.getYCoord() + y, aBaseMetaTileEntity.getZCoord() + zDir + z,GregTech_API.sBlockCasings4,1,2); - return false; - } - } else { - if (middle) { - reachedTop = true; - } - if (!this.addOutputToMachineList(tileEntity, CASING_INDEX) && !this.addMaintenanceToMachineList(tileEntity, CASING_INDEX) && !this.addEnergyInputToMachineList(tileEntity, CASING_INDEX)) { - if (block != GregTech_API.sBlockCasings4 || aBaseMetaTileEntity.getMetaID(aBaseMetaTileEntity.getXCoord() + xDir + x, aBaseMetaTileEntity.getYCoord() + y, aBaseMetaTileEntity.getZCoord() + zDir + z) != 1) { - return false; - } + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + // reset + mOutputHatchesByLayer.forEach(List::clear); + mHeight = 1; + mTopLayerFound = false; + mTopState = -1; - ++casingAmount; - } - } - } - } - } + // check base + if (!checkPiece(STRUCTURE_PIECE_BASE, 7, 0, 0)) + return false; - return casingAmount >= 15 * y - 5 && y >= 16 && y <= 56 && reachedTop; - } + // check each layer + while (mHeight < 12 && checkPiece(STRUCTURE_PIECE_LAYER, 7, mHeight * 5, 0) && !mTopLayerFound) { + if (mOutputHatchesByLayer.get(mHeight - 1).isEmpty()) + // layer without output hatch + return false; + mTopState = -1; + // not top + mHeight++; + } - @Override - public boolean addOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (super.addOutputToMachineList(aTileEntity, aBaseCasingIndex)) { - if (aTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Output) { - int layer = aTileEntity.getYCoord() - controllerY; - layer = MathUtils.ceilInt(((double)layer) /5D)-1; - LAYERMAP.put(layer,(GT_MetaTileEntity_Hatch_Output) aTileEntity.getMetaTileEntity()); - } - return true; - } - return false; + // validate final invariants... + return mCasing >= 75 * mHeight + 10 && mHeight >= 2 && mTopLayerFound && mMaintenanceHatches.size() == 1; } @Override - protected void addFluidOutputs(FluidStack[] mOutputFluids2) { - for (int i = 0; i < mOutputFluids2.length; i++) { - for (int j = 0; j < LAYERMAP.get(i).size(); j++) { - LAYERMAP.get(i).get(j).fill(new FluidStack(mOutputFluids2[i],mOutputFluids2[i].amount/LAYERMAP.get(i).size()), true); - } - } + public void construct(ItemStack stackSize, boolean hintsOnly) { + // no op, to big to be displayed } - private final ArrayListMultimap<Integer,GT_MetaTileEntity_Hatch_Output> LAYERMAP = ArrayListMultimap.create(); - @Override public boolean checkRecipe(ItemStack aStack) { ArrayList<FluidStack> tFluidList = this.getStoredFluids(); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java index e93d7342eb..865f06e6a7 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java @@ -29,6 +29,7 @@ import com.github.bartimaeusnek.bartworks.util.BW_Util; import com.github.bartimaeusnek.bartworks.util.MegaUtils; import com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti; import com.github.bartimaeusnek.crossmod.tectech.helper.TecTechUtils; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import cpw.mods.fml.common.Optional; import gregtech.api.GregTech_API; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -143,6 +144,15 @@ public class GT_TileEntity_MegaVacuumFreezer extends GT_MetaTileEntity_VacuumFre return false; } + @Override + public IStructureDefinition<GT_MetaTileEntity_VacuumFreezer> getStructureDefinition() { + throw new UnsupportedOperationException(); + } + + @Override + public void construct(ItemStack aStack, boolean aHintsOnly) { + } + // -------------- TEC TECH COMPAT ---------------- @Override diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java b/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java index 9975fd8d2d..7f0a8ef426 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java @@ -27,7 +27,6 @@ import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.crossmod.GTpp.loader.RadioHatchCompat; import com.github.bartimaeusnek.crossmod.galacticraft.GalacticraftProxy; import com.github.bartimaeusnek.crossmod.tectech.TecTechResearchLoader; -import com.github.bartimaeusnek.crossmod.tectech.tileentites.multi.GT_Replacement.*; import com.github.bartimaeusnek.crossmod.thaumcraft.CustomAspects; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.event.FMLInitializationEvent; @@ -78,17 +77,6 @@ public class BartWorksCrossmod { public void init(FMLInitializationEvent init) { if (LoaderReference.GalacticraftCore) GalacticraftProxy.init(init); - //Base GT -> TT Replacement - if (LoaderReference.tectech) { - new TT_VacuumFreezer(null,null); - new TT_OilCrackingUnit(null,null); - new TT_ImplosionCompressor(null,null); - new TT_ElectronicBlastFurnace(null,null); - new TT_MultiSmelter(null,null); - new TT_PyrolyseOven(null, null); - - new BW_TT_HeatExchanger(null, null); - } } @Mod.EventHandler diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/GT_TileEntity_VoidMiner_Base.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/GT_TileEntity_VoidMiner_Base.java index 6a8eaefa9c..267f9d372e 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/GT_TileEntity_VoidMiner_Base.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticgreg/GT_TileEntity_VoidMiner_Base.java @@ -43,6 +43,7 @@ import gregtech.api.enums.Materials; import gregtech.api.interfaces.ISubTagContainer; import gregtech.api.objects.XSTR; import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.common.GT_Worldgen_GT_Ore_Layer; import gregtech.common.GT_Worldgen_GT_Ore_SmallPieces; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_DrillerBase; @@ -58,6 +59,7 @@ import java.util.function.Predicate; import java.util.stream.Collectors; import static bloodasp.galacticgreg.registry.GalacticGregRegistry.getModContainers; +import static gregtech.api.enums.GT_Values.VN; @SuppressWarnings("ALL") public abstract class GT_TileEntity_VoidMiner_Base extends GT_MetaTileEntity_DrillerBase { @@ -144,24 +146,28 @@ public abstract class GT_TileEntity_VoidMiner_Base extends GT_MetaTileEntity_Dri } @Override - public String[] getDescription() { - String casingName = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(this.getCasingBlockItem().get(1L))); - return new String[]{"Controller Block for the Void Miner "+ GT_Values.VN[this.getMinTier()], - "Size(WxHxD): 3x7x3", - "Controller (Front middle at bottom)", - "3x1x3 Base of " + casingName, - "1x3x1 " + casingName + " pillar (Center of base)", - "1x3x1 " + this.getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)", - "1x Output Bus (One of base casings)", - "Optional: 0+ Input Hatch (One of base casings)", - "1x Maintenance Hatch (One of base casings)", - "1x " + GT_Values.VN[this.getMinTier()] + "+ Energy Hatch (Any bottom layer casing)", - "Consumes " + GT_Values.V[this.getMinTier()] + "EU/t", - "Can be supplied with 2L/s of Neon(x4), Krypton(x8), Xenon(x16) or Oganesson(x64)", - "for higher outputs.", - "Will output "+(2*TIER_MULTIPLIER)+" Ores per Second depending on the Dimension it is build in", - BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get() - }; + protected GT_Multiblock_Tooltip_Builder createTooltip() { + String casings = getCasingBlockItem().get(0).getDisplayName(); + + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Miner") + .addInfo("Controller Block for the Void Miner "+ GT_Values.VN[this.getMinTier()]) + .addInfo("Consumes " + GT_Values.V[this.getMinTier()] + "EU/t") + .addInfo("Can be supplied with 2L/s of Neon(x4), Krypton(x8), Xenon(x16) or Oganesson(x64) for higher outputs.") + .addInfo("Will output "+(2*TIER_MULTIPLIER)+" Ores per Second depending on the Dimension it is build in") + .addSeparator() + .beginStructureBlock(3, 7, 3, false) + .addController("Front bottom") + .addStructureInfo(casings + " form the 3x1x3 Base") + .addOtherStructurePart(casings, " 1x3x1 pillar above the center of the base (2 minimum total)") + .addOtherStructurePart(getFrameMaterial().mName + " Frame Boxes", "Each pillar's side and 1x3x1 on top") + .addEnergyHatch(VN[getMinTier()] + "+, Any base casing") + .addMaintenanceHatch("Any base casing") + .addInputBus("Mining Pipes, optional, any base casing") + .addInputHatch("Optional noble gas, any base casing") + .addOutputBus("Any base casing") + .toolTipFinisher("Gregtech"); + return tt; } public static ArrayListMultimap<Integer, Pair<Pair<Integer, Boolean>, Float>> getExtraDropsDimMap() { diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/BW_TT_HeatExchanger.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/BW_TT_HeatExchanger.java deleted file mode 100644 index ae07cdfe37..0000000000 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/BW_TT_HeatExchanger.java +++ /dev/null @@ -1,369 +0,0 @@ -package com.github.bartimaeusnek.crossmod.tectech.tileentites.multi.GT_Replacement; - -import com.github.technus.tectech.mechanics.structure.IStructureDefinition; -import com.github.technus.tectech.mechanics.structure.StructureDefinition; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; -import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.StatCollector; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - -import java.util.Collection; - -import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.ADV_STR_CHECK; -import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.TT_BLUEPRINT; -import static com.github.technus.tectech.mechanics.structure.StructureUtility.*; - -public class BW_TT_HeatExchanger extends TT_Abstract_GT_Replacement { - public static float penalty_per_config = 0.015f; // penalize 1.5% efficiency per circuitry level (1-25) - - private GT_MetaTileEntity_Hatch_Input mInputHotFluidHatch; - private GT_MetaTileEntity_Hatch_Output mOutputColdFluidHatch; - private boolean superheated = false; - private int superheated_threshold = 0; - private float water; - private byte blocks = 0; - - public BW_TT_HeatExchanger(Object unused, Object unused2) { - super(1154, "multimachine.heatexchanger", "Large Heat Exchanger"); - } - - public BW_TT_HeatExchanger(String aName) { - super(aName); - } - - private static final byte TEXTURE_INDEX = 50; - private static final byte SOLID_CASING_META = 2; - private static final byte PIPE_CASING_META = 14; - private static final IStructureDefinition<BW_TT_HeatExchanger> STRUCTURE_DEFINITION = StructureDefinition - .<BW_TT_HeatExchanger>builder() - .addShape("main", - transpose(new String[][]{ - {"AAA", "ACA", "AAA"}, - {"AAA", "ABA", "AAA"}, - {"AAA", "ABA", "AAA"}, - {"A~A", "ADA", "AAA"} - }) - ).addElement( - 'A', - ofChain( - ofHatchAdder( - BW_TT_HeatExchanger::addClassicToMachineList, TEXTURE_INDEX, - GregTech_API.sBlockCasings4, SOLID_CASING_META - ), - onElementPass( - x -> ++x.blocks, - ofBlock( - GregTech_API.sBlockCasings4, SOLID_CASING_META - ) - ) - ) - - ).addElement( - 'B', - ofBlock( - GregTech_API.sBlockCasings2, PIPE_CASING_META, - GregTech_API.sBlockCasings2, PIPE_CASING_META - ) - ).addElement( - 'C', - ofHatchAdder( - BW_TT_HeatExchanger::addColdFluidOutputToMachineList,TEXTURE_INDEX, - 1 - ) - ).addElement( - 'D', - ofHatchAdder( - BW_TT_HeatExchanger::addHotFluidInputToMachineList,TEXTURE_INDEX, - 2 - ) - ) - .build(); - - @Override - public IStructureDefinition<BW_TT_HeatExchanger> getStructure_EM() { - return STRUCTURE_DEFINITION; - } - - @Override - protected boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - this.blocks = 0; - return this.structureCheck_EM("main", 1, 3, 0) && this.blocks >= 20; - } - - private final static String[] desc = new String[]{ - "Heat Exchanger", - "Controller Block for the Large Heat Exchanger", - "Inputs are Hot Fluids and Distilled Water", - "Outputs Cold Fluids and SH Steam/Steam", - "Requires an additional Input and Output Hatch anywhere!", - ADV_STR_CHECK, - TT_BLUEPRINT - }; - - public String[] getDescription() { - return desc; - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - superheated = aNBT.getBoolean("superheated"); - super.loadNBTData(aNBT); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setBoolean("superheated", superheated); - super.saveNBTData(aNBT); - } - - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][50], TextureFactory.of(aActive ? TextureFactory.of(TextureFactory.of(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE), TextureFactory.builder().addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE_GLOW).glow().build()) : TextureFactory.of(TextureFactory.of(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER), TextureFactory.builder().addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_GLOW).glow().build()))}; - } - return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][50]}; - } - - private void checkRecipeClassic(float efficiency){ - int fluidAmountToConsume = mInputHotFluidHatch.getFluidAmount(); - float steam_output_multiplier = 20f; // default: multiply output by 4 * 10 (boosted x5) - boolean do_lava = false; - // If we're working with lava, adjust the threshold and multipliers accordingly. - if (GT_ModHandler.isLava(mInputHotFluidHatch.getFluid())) { - steam_output_multiplier /= 5f; // lava is not boosted - superheated_threshold /= 4f; // unchanged - do_lava = true; - } else if (mInputHotFluidHatch.getFluid().isFluidEqual(FluidRegistry.getFluidStack("ic2hotcoolant", 1))) { - steam_output_multiplier /= 2f; // was boosted x2 on top of x5 -> total x10 -> nerf with this code back to 5x - superheated_threshold /= 5f; // 10x smaller since the Hot Things production in reactor is the same. - } - - superheated = fluidAmountToConsume >= superheated_threshold; // set the internal superheated flag if we have enough hot fluid. Used in the onRunningTick method. - fluidAmountToConsume = Math.min(fluidAmountToConsume, superheated_threshold * 2); // Don't consume too much hot fluid per second - mInputHotFluidHatch.drain(fluidAmountToConsume, true); - this.mMaxProgresstime = 20; - this.mEUt = (int) (fluidAmountToConsume * steam_output_multiplier * efficiency); - if (do_lava) { - mOutputColdFluidHatch.fill(FluidRegistry.getFluidStack("ic2pahoehoelava", fluidAmountToConsume), true); - } else { - mOutputColdFluidHatch.fill(FluidRegistry.getFluidStack("ic2coolant", fluidAmountToConsume), true); - } - this.mEfficiencyIncrease = 80; - } - - Materials last = null; - - private void checkRecipe_Additions(float efficiency){ - Materials m = null; - if (last != null && mInputHotFluidHatch.getFluid().isFluidEqual(last.getPlasma(1))) { - m = last; - } else { - for (Materials materials : Materials.values()) { - if (mInputHotFluidHatch.getFluid().isFluidEqual(materials.getPlasma(1))) { - last = m = materials; - break; - } - else if (mInputHotFluidHatch.getFluid().isFluidEqual(materials.getMolten(1))){ - GT_Log.exp.println(this.mName + " had Molten Metal Injected!"); - explodeMultiblock(); // Generate crater - return; - } - } - } - - if (m == null) - return; - - int heat = getFuelValue(mInputHotFluidHatch.getFluid(), (int) (100 * efficiency)); - - superheated_threshold /= 4f; - - superheated = heat >= superheated_threshold; // set the internal superheated flag if we have enough hot fluid. Used in the onRunningTick method. - - mInputHotFluidHatch.drain(1, true); - this.mMaxProgresstime = 20; - this.mEUt = heat; - mOutputColdFluidHatch.fill(m.getMolten(1), true); - this.mEfficiencyIncrease = 80; - } - - private int getFuelValue(FluidStack aLiquid, int efficency) { - if (aLiquid == null || getRecipes() == null) - return 0; - FluidStack tLiquid; - Collection<GT_Recipe> tRecipeList = getRecipes().mRecipeList; - if (tRecipeList == null) - return 0; - for (GT_Recipe tFuel : tRecipeList) { - tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true); - if (tLiquid == null) { - continue; - } - if (!aLiquid.isFluidEqual(tLiquid)) { - continue; - } - long val = (long) tFuel.mSpecialValue * efficency / 100; - if (val > Integer.MAX_VALUE) { - throw new ArithmeticException("Integer LOOPBACK!"); - } - return (int) val; - } - return 0; - } - - private GT_Recipe.GT_Recipe_Map getRecipes() { - return GT_Recipe.GT_Recipe_Map.sPlasmaFuels; - } - - public boolean checkRecipe_EM(ItemStack aStack) { - if (mInputHotFluidHatch.getFluid() == null) - return true; - FluidStack fluid = mInputHotFluidHatch.getFluid(); // how much fluid is in hatch - superheated_threshold = 4000; // default: must have 4000L per second to generate superheated steam - float efficiency = calculateEfficiency(); - - if (GT_ModHandler.isLava(fluid) || fluid.isFluidEqual(FluidRegistry.getFluidStack("ic2hotcoolant", 1))) - checkRecipeClassic(efficiency); - else - checkRecipe_Additions(efficiency); - - return true; - } - - private float calculateEfficiency(){ - float defaultEff = 1f; // default: operate at 100% efficiency with no integrated circuitry - float penalty; // penalty to apply to output based on circuitry level (1-25). - int shs_reduction_per_config = 150; // reduce threshold 150L/s per circuitry level (1-25) - - // Do we have an integrated circuit? - if (mInventory[1] == null || mInventory[1].getItem() != GT_Utility.getIntegratedCircuit(0).getItem()) - return defaultEff; - - //valid configuration? - int circuit_config = mInventory[1].getItemDamage(); - if (circuit_config < 1 || circuit_config > 25) - return defaultEff; - - // If so, apply the penalty and reduced threshold. - penalty = (circuit_config - 1) * penalty_per_config; - superheated_threshold -= (shs_reduction_per_config * (circuit_config - 1)); - return defaultEff - penalty; - } - - private int useWater(float input) { - water = water + input; - int usage = (int) water; - water = water - usage; - return usage; - } - - public boolean onRunningTick(ItemStack aStack) { - if (this.mEUt <= 0) { - return false; - } - int tGeneratedEU = (int) (this.mEUt * 2L * this.mEfficiency / 100_00L); // APPROXIMATELY how much steam to generate. - if (tGeneratedEU <= 0) { - return false; - } - - if (superheated) - tGeneratedEU /= 2; // We produce half as much superheated steam if necessary - - int distilledConsumed = useWater(tGeneratedEU / 160f); // how much distilled water to consume - //tGeneratedEU = distilledConsumed * 160; // EXACTLY how much steam to generate, producing a perfect 1:160 ratio with distilled water consumption - - FluidStack distilledStack = GT_ModHandler.getDistilledWater(distilledConsumed); - if (depleteInput(distilledStack)) // Consume the distilled water - { - if (superheated) { - addOutput(FluidRegistry.getFluidStack("ic2superheatedsteam", tGeneratedEU)); // Generate superheated steam - } else { - addOutput(GT_ModHandler.getSteam(tGeneratedEU)); // Generate regular steam - } - } else { - GT_Log.exp.println(this.mName + " had no more Distilled water!"); - explodeMultiblock(); // Generate crater - return false; - } - return true; - } - - - public boolean addColdFluidOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) - return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (!(aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output)) { - return false; - } - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - mOutputColdFluidHatch = (GT_MetaTileEntity_Hatch_Output) aMetaTileEntity; - return true; - } - - public boolean addHotFluidInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (!(aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input)) { - return false; - } - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - mInputHotFluidHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; - mInputHotFluidHatch.mRecipeMap = null; - return true; - } - - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new BW_TT_HeatExchanger(this.mName); - } - - @Override - public String[] getInfoData() { - return new String[]{ - StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + - EnumChatFormatting.GREEN + mProgresstime / 20 + EnumChatFormatting.RESET + " s / " + - EnumChatFormatting.YELLOW + mMaxProgresstime / 20 + EnumChatFormatting.RESET + " s", - StatCollector.translateToLocal("GT5U.multiblock.usage") + " " + StatCollector.translateToLocal("GT5U.LHE.steam") + ": " + - (superheated ? EnumChatFormatting.RED : EnumChatFormatting.YELLOW) + (superheated ? -2 * mEUt : -mEUt) + EnumChatFormatting.RESET + " EU/t", - StatCollector.translateToLocal("GT5U.multiblock.problems") + ": " + - EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + - " " + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + ": " + - EnumChatFormatting.YELLOW + mEfficiency / 100.0F + EnumChatFormatting.RESET + " %", - StatCollector.translateToLocal("GT5U.LHE.superheated") + ": " + (superheated ? EnumChatFormatting.RED : EnumChatFormatting.BLUE) + superheated + EnumChatFormatting.RESET, - StatCollector.translateToLocal("GT5U.LHE.superheated") + " " + StatCollector.translateToLocal("GT5U.LHE.threshold") + ": " + EnumChatFormatting.GREEN + superheated_threshold + EnumChatFormatting.RESET - }; - } - - @Override - public void construct(ItemStack itemStack, boolean b) { - this.structureBuild_EM("main", 1,3,0, b, itemStack); - } - - private static final String[] sfStructureDescription = new String[] { - "1 - Cold Fluid Output", - "2 - Hot Fluid Input", - "Needs an additional Output Hatch", - "Needs an additional Input Hatch", - "20 Casings at least!" - }; - - @Override - public String[] getStructureDescription(ItemStack itemStack) { - return sfStructureDescription; - } -} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_Abstract_GT_Replacement.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_Abstract_GT_Replacement.java deleted file mode 100644 index ad7915aff0..0000000000 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_Abstract_GT_Replacement.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.github.bartimaeusnek.crossmod.tectech.tileentites.multi.GT_Replacement; - -import com.github.technus.tectech.mechanics.constructable.IConstructable; -import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti; -import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_Container_MultiMachineEM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_GUIContainer_MultiMachineEM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import gregtech.api.GregTech_API; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.*; -import gregtech.api.util.GT_Recipe; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; - -public abstract class TT_Abstract_GT_Replacement extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { - - protected TT_Abstract_GT_Replacement(int newId, String aName, String aNameRegional) { - super(32765, aName, aNameRegional); - GregTech_API.METATILEENTITIES[32765] = null; - GregTech_API.METATILEENTITIES[newId] = this; - } - - protected TT_Abstract_GT_Replacement(String aName) { - super(aName); - } - - protected void setInputFilters() { - this.mInputBusses.forEach(x -> x.mRecipeMap = this.getRecipeMap()); - this.mInputHatches.forEach(x -> x.mRecipeMap = this.getRecipeMap()); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "EMDisplay.png", this.ePowerPassCover, false, true); - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, this.ePowerPassCover, false, true); - } - - @Override - protected boolean cyclicUpdate_EM() { - return false; - } - - @Override - public boolean isMachineBlockUpdateRecursive() { - return true; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - protected void setEfficiencyAndOc(GT_Recipe gtRecipe) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - calculateOverclockedNessMulti(gtRecipe.mEUt, gtRecipe.mDuration, 1, getMaxInputVoltage()); - } - - public final boolean addEBFInputsBottom(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) - return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - else - return false; - - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) - return this.mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) - return this.mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) - return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) - return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) - return this.mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) - return this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) - return this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) - return this.eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) - return this.eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity); - return false; - } -} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_Abstract_GT_Replacement_Coils.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_Abstract_GT_Replacement_Coils.java deleted file mode 100644 index 05f573b690..0000000000 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_Abstract_GT_Replacement_Coils.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.github.bartimaeusnek.crossmod.tectech.tileentites.multi.GT_Replacement; - -import com.github.bartimaeusnek.crossmod.tectech.helper.IHasCoils; -import gregtech.api.enums.HeatingCoilLevel; - -public abstract class TT_Abstract_GT_Replacement_Coils extends TT_Abstract_GT_Replacement implements IHasCoils { - - protected TT_Abstract_GT_Replacement_Coils(int newId, String aName, String aNameRegional) { - super(newId, aName, aNameRegional); - } - - protected TT_Abstract_GT_Replacement_Coils(String aName) { - super(aName); - } - - protected HeatingCoilLevel heatingCoilLevel = HeatingCoilLevel.None; - - @Override - public void setCoilHeat(HeatingCoilLevel coilMeta) { - heatingCoilLevel = coilMeta; - } - - @Override - public HeatingCoilLevel getCoilHeat() { - return heatingCoilLevel; - } -} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_ElectronicBlastFurnace.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_ElectronicBlastFurnace.java deleted file mode 100644 index e4a2b0b300..0000000000 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_ElectronicBlastFurnace.java +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.github.bartimaeusnek.crossmod.tectech.tileentites.multi.GT_Replacement; - -import com.github.bartimaeusnek.crossmod.tectech.helper.CoilAdder; -import com.github.technus.tectech.mechanics.structure.IStructureDefinition; -import com.github.technus.tectech.mechanics.structure.StructureDefinition; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; -import com.google.common.collect.ImmutableSet; -import gregtech.api.GregTech_API; -import gregtech.api.enums.HeatingCoilLevel; -import gregtech.api.enums.Materials; -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.interfaces.tileentity.ITurnable; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.*; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.StatCollector; -import net.minecraftforge.fluids.FluidStack; - -import java.util.Set; - -import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.ADV_STR_CHECK; -import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.TT_BLUEPRINT; -import static com.github.technus.tectech.mechanics.structure.StructureUtility.*; -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.enums.GT_Values.VN; - -public class TT_ElectronicBlastFurnace extends TT_Abstract_GT_Replacement_Coils { - - public TT_ElectronicBlastFurnace(Object unused, Object unused2) { - super(1000, "multimachine.blastfurnace", "Electric Blast Furnace"); - } - - private TT_ElectronicBlastFurnace(String aName) { - super(aName); - } - - private int mHeatingCapacity = 0; - - private static final byte TEXTURE_INDEX = 11; - private static final IStructureDefinition<TT_ElectronicBlastFurnace> STRUCTURE_DEFINITION = StructureDefinition - .<TT_ElectronicBlastFurnace>builder() - .addShape("main", - transpose(new String[][]{ - {"AAA", "AMA", "AAA"}, - {"CCC", "C-C", "CCC"}, - {"CCC", "C-C", "CCC"}, - {"B~B", "BBB", "BBB"} - }) - ).addElement( - 'C', - CoilAdder.getINSTANCE() - ).addElement( - 'M', - ofHatchAdder( - GT_MetaTileEntity_MultiblockBase_EM::addClassicMufflerToMachineList, TEXTURE_INDEX, - 1 - ) - ).addElement( - 'A', - ofHatchAdderOptional( - TT_ElectronicBlastFurnace::addEBFInputsTop, TEXTURE_INDEX, - GregTech_API.sBlockCasings1, TEXTURE_INDEX, - GregTech_API.sBlockCasings1, TEXTURE_INDEX - ) - ).addElement( - 'B', - ofHatchAdderOptional( - TT_ElectronicBlastFurnace::addEBFInputsBottom, TEXTURE_INDEX, - GregTech_API.sBlockCasings1, TEXTURE_INDEX, - GregTech_API.sBlockCasings1, TEXTURE_INDEX - ) - ) - .build(); - - @Override - public IStructureDefinition<TT_ElectronicBlastFurnace> getStructure_EM() { - return STRUCTURE_DEFINITION; - } - - @Override - protected boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - this.mHeatingCapacity = 0; - this.setCoilHeat(HeatingCoilLevel.None); - boolean ret = this.structureCheck_EM("main", 1, 3, 0) && this.getCoilHeat() != HeatingCoilLevel.None; - this.mMufflerHatches.forEach(x -> x.setInValidFacings(this.getExtendedFacing().getRelativeUpInWorld().getOpposite())); - - if (this.mMufflerHatches.stream() - .map(MetaTileEntity::getBaseMetaTileEntity) - .mapToInt(ITurnable::getFrontFacing) - .noneMatch(x -> x == this.getExtendedFacing().getRelativeUpInWorld().ordinal())) - return false; - - this.mHeatingCapacity = (int) this.getCoilHeat().getHeat(); - this.mHeatingCapacity += 100 * (GT_Utility.getTier(getMaxInputVoltage()) - 2); - setInputFilters(); - return ret; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sBlastRecipes; - } - - @Override - public void construct(ItemStack itemStack, boolean b) { - this.structureBuild_EM("main", 1,3,0, b, itemStack); - } - - public final boolean addEBFInputsTop(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) - return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - else - return false; - - return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); - } - - private static final Set<FluidStack> POLLUTION_FLUID_STACKS = ImmutableSet.of( - Materials.CarbonDioxide.getGas(1000), - Materials.CarbonMonoxide.getGas(1000), - Materials.SulfurDioxide.getGas(1000) - ); - - @Override - public boolean addOutput(FluidStack aLiquid) { - if (aLiquid == null) - return false; - FluidStack tLiquid = aLiquid.copy(); - - if (POLLUTION_FLUID_STACKS.stream().anyMatch(tLiquid::isFluidEqual)) { - tLiquid.amount = tLiquid.amount * (mMufflerHatches.stream() - .filter(GT_MetaTileEntity_MultiBlockBase::isValidMetaTileEntity) - .findFirst() - .map(tHatch -> 100 - tHatch.calculatePollutionReduction(100)) - .orElse(0) + 5) / 100; - for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { - if ((isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid) - ? !tHatch.outputsSteam() - : !tHatch.outputsLiquids()) - || tHatch.getBaseMetaTileEntity().getYCoord() <= this.getBaseMetaTileEntity().getYCoord() - || canNotFillOutput(tHatch, tLiquid)) - continue; - return true; - } - } else { - for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { - if ((isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid) - ? !tHatch.outputsSteam() - : !tHatch.outputsLiquids()) - || tHatch.getBaseMetaTileEntity().getYCoord() > this.getBaseMetaTileEntity().getYCoord() - || canNotFillOutput(tHatch, tLiquid)) - continue; - return true; - } - } - return false; - } - - private boolean canNotFillOutput(GT_MetaTileEntity_Hatch_Output tHatch, FluidStack tLiquid){ - int tAmount = tHatch.fill(tLiquid, false); - if (tAmount >= tLiquid.amount) - return tHatch.fill(tLiquid, true) < tLiquid.amount; - else if (tAmount > 0) - tLiquid.amount = tLiquid.amount - tHatch.fill(tLiquid, true); - return true; - } - - private static final int pollutionPerTick = 20; - - private final static String[] desc = new String[]{ - "Blast Furnace", - "Controller block for the Electric Blast Furnace", - "You can use some fluids to reduce recipe time. Place the circuit in the Input Bus", - "Each 900K over the min. Heat required multiplies EU/t by 0.95", - "Each 1800K over the min. Heat required allows for one upgraded overclock instead of normal", - "Upgraded overclocks reduce recipe time to 25% (instead of 50%) and increase EU/t to 400%", - "Additionally gives +100K for every tier past MV", - "Creates up to: " + 20 * pollutionPerTick + " Pollution per Second", - ADV_STR_CHECK, - TT_BLUEPRINT - }; - - @Override - public String[] getDescription() { - return desc; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][11], new TT_RenderedExtendedFacingTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE)}; - } - return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][11]}; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { - return new TT_ElectronicBlastFurnace(this.mName); - } - - @Override - public boolean checkRecipe_EM(ItemStack aStack) { - ItemStack[] tInputs = this.getCompactedInputs(); - FluidStack[] tFluids = this.getCompactedFluids(); - - if (tInputs.length <= 0) { - return false; - } - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBlastRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - if (tRecipe == null - || (this.mHeatingCapacity < tRecipe.mSpecialValue) - || (!tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { - return false; - } - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - int tHeatCapacityDivTiers = ((this.mHeatingCapacity - tRecipe.mSpecialValue) / 900); - byte overclockCount = calculateOverclockednessEBF(tRecipe.mEUt, tRecipe.mDuration, tVoltage); - //In case recipe is too OP for that machine - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) - return false; - if (this.mEUt > 0) - this.mEUt = (-this.mEUt); - - if (tHeatCapacityDivTiers > 0) { - this.mEUt = (int) (this.mEUt * (Math.pow(0.95, tHeatCapacityDivTiers))); - this.mMaxProgresstime >>= Math.min(tHeatCapacityDivTiers / 2, overclockCount);//extra free overclocking if possible - if (this.mMaxProgresstime < 1) - this.mMaxProgresstime = 1;//no eu efficiency correction - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; - this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)}; - updateSlots(); - return true; - } - - /** - * Calcualtes overclocked ness using long integers - * - * @param aEUt - recipe EUt - * @param aDuration - recipe Duration - */ - protected byte calculateOverclockednessEBF(int aEUt, int aDuration, long maxInputVoltage) { - byte mTier = (byte) Math.max(0, GT_Utility.getTier(maxInputVoltage)), timesOverclocked = 0; - if (mTier == 0) { - //Long time calculation - long xMaxProgresstime = ((long) aDuration) << 1; - if (xMaxProgresstime > Integer.MAX_VALUE - 1) { - //make impossible if too long - mEUt = Integer.MAX_VALUE - 1; - mMaxProgresstime = Integer.MAX_VALUE - 1; - } else { - mEUt = aEUt >> 2; - mMaxProgresstime = (int) xMaxProgresstime; - } - //return 0; - } else { - //Long EUt calculation - long xEUt = aEUt; - //Isnt too low EUt check? - long tempEUt = Math.max(xEUt, V[1]); - - mMaxProgresstime = aDuration; - - while (tempEUt <= V[mTier - 1]) { - tempEUt <<= 2;//this actually controls overclocking - //xEUt *= 4;//this is effect of everclocking - mMaxProgresstime >>= 1;//this is effect of overclocking - xEUt = mMaxProgresstime == 0 ? xEUt >> 1 : xEUt << 2;//U know, if the time is less than 1 tick make the machine use less power - timesOverclocked++; - } - if (xEUt > Integer.MAX_VALUE - 1) { - mEUt = Integer.MAX_VALUE - 1; - mMaxProgresstime = Integer.MAX_VALUE - 1; - } else { - mEUt = (int) xEUt; - if (mEUt == 0) - mEUt = 1; - if (mMaxProgresstime == 0) - mMaxProgresstime = 1;//set time to 1 tick - } - } - return timesOverclocked; - } - - @Override - public String[] getInfoData() { - int mPollutionReduction = 0; - for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { - if (isValidMetaTileEntity(tHatch)) { - mPollutionReduction = Math.max(tHatch.calculatePollutionReduction(100), mPollutionReduction); - } - } - - long storedEnergy = 0; - long maxEnergy = 0; - for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { - if (isValidMetaTileEntity(tHatch)) { - storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); - maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); - } - } - - return new String[]{ - StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + EnumChatFormatting.GREEN + mProgresstime / 20 + EnumChatFormatting.RESET + " s / " + - EnumChatFormatting.YELLOW + mMaxProgresstime / 20 + EnumChatFormatting.RESET + " s", - StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + EnumChatFormatting.GREEN + storedEnergy + EnumChatFormatting.RESET + " EU / " + - EnumChatFormatting.YELLOW + maxEnergy + EnumChatFormatting.RESET + " EU", - StatCollector.translateToLocal("GT5U.multiblock.usage") + ": " + EnumChatFormatting.RED + -mEUt + EnumChatFormatting.RESET + " EU/t", - StatCollector.translateToLocal("GT5U.multiblock.mei") + ": " + EnumChatFormatting.YELLOW + getMaxInputVoltage() + EnumChatFormatting.RESET + " EU/t(*2A) " + StatCollector.translateToLocal("GT5U.machines.tier") + ": " + - EnumChatFormatting.YELLOW + VN[GT_Utility.getTier(getMaxInputVoltage())] + EnumChatFormatting.RESET, - StatCollector.translateToLocal("GT5U.multiblock.problems") + ": " + - EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + - " " + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + ": " + - EnumChatFormatting.YELLOW + mEfficiency / 100.0F + EnumChatFormatting.RESET + " %", - StatCollector.translateToLocal("GT5U.EBF.heat") + ": " + - EnumChatFormatting.GREEN + mHeatingCapacity + EnumChatFormatting.RESET + " K", - StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + EnumChatFormatting.GREEN + mPollutionReduction + EnumChatFormatting.RESET + " %" - }; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return pollutionPerTick; - } - - private static final String[] sfStructureDescription = new String[] { - "0 - Air", - "1 - Muffler", - "Required: Output Bus, Input Bus, Energy Hatch, Maintenance Hatch", - "Optional: Input Hatch, Output Hatch at Bottom, Output Hatch at top to regain CO/CO2/SO2" - }; - - @Override - public String[] getStructureDescription(ItemStack itemStack) { - return sfStructureDescription; - } - -} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_ImplosionCompressor.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_ImplosionCompressor.java deleted file mode 100644 index aec51a8d70..0000000000 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_ImplosionCompressor.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.github.bartimaeusnek.crossmod.tectech.tileentites.multi.GT_Replacement; - -import com.github.bartimaeusnek.crossmod.tectech.helper.StructureDefinitions; -import com.github.technus.tectech.mechanics.structure.IStructureDefinition; -import com.github.technus.tectech.mechanics.structure.StructureDefinition; -import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti; -import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; -import com.google.common.collect.ArrayListMultimap; -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.interfaces.tileentity.ITurnable; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.*; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; - -import java.util.List; - -import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.ADV_STR_CHECK; -import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.TT_BLUEPRINT; -import static com.github.technus.tectech.mechanics.structure.StructureUtility.*; - -public class TT_ImplosionCompressor extends TT_Abstract_GT_Replacement { - - public TT_ImplosionCompressor(Object unused, Object unused2) { - super(1001, "multimachine.implosioncompressor", "Implosion Compressor"); - } - - private TT_ImplosionCompressor(String aName) { - super(aName); - } - - private byte blocks = 0; - - private static final byte TEXTURE_INDEX = 16; - private static final byte SOUND_INDEX = 20; - - private static final ArrayListMultimap<Block, Integer> BLOCKS = ArrayListMultimap.create(); - - static { - BLOCKS.put(GregTech_API.sBlockCasings2,0); - BLOCKS.put(GregTech_API.sBlockCasings3,4); - } - - private static final IStructureDefinition<TT_ImplosionCompressor> STRUCTURE_DEFINITION = - StructureDefinition.<TT_ImplosionCompressor>builder().addShape("main", - StructureDefinitions.CUBE_NO_MUFFLER.getDefinition() - ).addElement( - 'V', - ofChain( - onElementPass( - x -> ++x.blocks, - ofBlocksMap( - BLOCKS.asMap(),GregTech_API.sBlockCasings2, - 0 - ) - ), - ofHatchAdder( - TT_ImplosionCompressor::addImplosionHatches, - TEXTURE_INDEX, - 1 - ) - ) - ).build(); - - public final boolean addImplosionHatches(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - else - return false; - - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) - return this.mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) - return this.mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) - return this.mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) - return this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) - return this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) - return this.eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) - return this.eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) - return this.mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); - return false; - } - - @Override - protected boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - this.blocks = 0; - boolean ret = this.structureCheck_EM("main", 1,1,0) - && this.blocks >= 16; - this.mMufflerHatches.forEach(x -> x.setInValidFacings(this.getExtendedFacing().getRelativeUpInWorld().getOpposite())); - - if (this.mMufflerHatches.stream() - .map(MetaTileEntity::getBaseMetaTileEntity) - .mapToInt(ITurnable::getFrontFacing) - .noneMatch(x -> x == this.getExtendedFacing().getRelativeUpInWorld().ordinal())) - return false; - - setInputFilters(); - return ret; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sImplosionRecipes; - } - - @Override - public void construct(ItemStack itemStack, boolean b) { - this.structureBuild_EM("main", 1,1,0, b, itemStack); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { - return new TT_ImplosionCompressor(this.mName); - } - - private static final int pollutionPerTick = 500; - - private final static String[] desc = new String[]{ - "Implosion Compressor", - "Explosions are fun", - "Controller block for the Implosion Compressor", - "Creates up to: " + 20 * pollutionPerTick + " Pollution per Second", - ADV_STR_CHECK, - TT_BLUEPRINT - }; - - @Override - public String[] getDescription() { - return desc; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][TEXTURE_INDEX], new TT_RenderedExtendedFacingTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_IMPLOSION_COMPRESSOR_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_IMPLOSION_COMPRESSOR)}; - } - return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][TEXTURE_INDEX]}; - } - - @Override - public IStructureDefinition<TT_ImplosionCompressor> getStructure_EM() { - return STRUCTURE_DEFINITION; - } - - @Override - public boolean checkRecipe_EM(ItemStack aStack) { - List<ItemStack> tInputList = getStoredInputs(); - int tInputList_sS=tInputList.size(); - for (int i = 0; i < tInputList_sS - 1; i++) { - for (int j = i + 1; j < tInputList_sS; j++) { - if (!GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - continue; - } - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { - tInputList.remove(j--); - tInputList_sS=tInputList.size(); - } else { - tInputList.remove(i--); - tInputList_sS=tInputList.size(); - break; - } - } - } - ItemStack[] tInputs = tInputList.toArray(new ItemStack[0]); - if (tInputList.size() <= 0) { - return false; - } - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sImplosionRecipes.findRecipe(getBaseMetaTileEntity(), false, 9223372036854775807L, null, tInputs); - if ((tRecipe == null) || (!tRecipe.isRecipeInputEqual(true, null, tInputs))) { - return false; - } - setEfficiencyAndOc(tRecipe); - //In case recipe is too OP for that machine - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) - return false; - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; - sendLoopStart(SOUND_INDEX); - updateSlots(); - return true; - } - - @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == SOUND_INDEX) { - GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(5), 10, 1.0F, aX, aY, aZ); - } - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return pollutionPerTick; - } - - private static final String[] sfStructureDescription = new String[] { - "0 - Air", - "Required: Muffler Hatch, Output Bus, Input Bus, Energy Hatch, Maintenance Hatch", - "16 Casings at least!" - }; - - @Override - public String[] getStructureDescription(ItemStack itemStack) { - return sfStructureDescription; - } - -} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_MultiSmelter.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_MultiSmelter.java deleted file mode 100644 index d38f1800ba..0000000000 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_MultiSmelter.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.github.bartimaeusnek.crossmod.tectech.tileentites.multi.GT_Replacement; - -import com.github.bartimaeusnek.crossmod.tectech.helper.CoilAdder; -import com.github.technus.tectech.mechanics.structure.IStructureDefinition; -import com.github.technus.tectech.mechanics.structure.StructureDefinition; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; -import gregtech.api.GregTech_API; -import gregtech.api.enums.HeatingCoilLevel; -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.interfaces.tileentity.ITurnable; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.StatCollector; - -import java.util.ArrayList; - -import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.ADV_STR_CHECK; -import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.TT_BLUEPRINT; -import static com.github.technus.tectech.mechanics.structure.StructureUtility.*; -import static gregtech.api.enums.GT_Values.VN; - -public class TT_MultiSmelter extends TT_Abstract_GT_Replacement_Coils { - - private int mLevel; - private int mCostDiscount; - - public TT_MultiSmelter(Object unused, Object unused2) { - super(1003, "multimachine.multifurnace", "Multi Smelter"); - } - - private TT_MultiSmelter(String aName) { - super(aName); - } - - private static final byte TEXTURE_INDEX = 11; - private static final IStructureDefinition<TT_MultiSmelter> STRUCTURE_DEFINITION = StructureDefinition - .<TT_MultiSmelter>builder() - .addShape("main", - transpose(new String[][]{ - {"AAA", "AMA", "AAA"}, - {"CCC", "C-C", "CCC"}, - {"A~A", "AAA", "AAA"} - }) - ).addElement( - 'C', - CoilAdder.getINSTANCE() - ).addElement( - 'M', - ofHatchAdder( - GT_MetaTileEntity_MultiblockBase_EM::addClassicMufflerToMachineList, TEXTURE_INDEX, - 1 - ) - ).addElement( - 'A', - ofHatchAdderOptional( - TT_MultiSmelter::addEBFInputsBottom, TEXTURE_INDEX, - GregTech_API.sBlockCasings1, TEXTURE_INDEX, - GregTech_API.sBlockCasings1, TEXTURE_INDEX - ) - ) - .build(); - - - private static final String[] sfStructureDescription = new String[] { - "0 - Air", - "1 - Muffler", - "Required: Output Bus, Input Bus, Energy Hatch, Maintenance Hatch", - }; - - @Override - public String[] getStructureDescription(ItemStack itemStack) { - return sfStructureDescription; - } - - @Override - public IStructureDefinition<TT_MultiSmelter> getStructure_EM() { - return STRUCTURE_DEFINITION; - } - - @Override - protected boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - this.mLevel = 0; - this.mCostDiscount = 1; - this.setCoilHeat(HeatingCoilLevel.None); - boolean ret = this.structureCheck_EM("main", 1, 2, 0) && this.getCoilHeat() != HeatingCoilLevel.None; - - this.mMufflerHatches.forEach(x -> x.setInValidFacings(this.getExtendedFacing().getRelativeUpInWorld().getOpposite())); - - if (this.mMufflerHatches.stream() - .map(MetaTileEntity::getBaseMetaTileEntity) - .mapToInt(ITurnable::getFrontFacing) - .noneMatch(x -> x == this.getExtendedFacing().getRelativeUpInWorld().ordinal())) - return false; - - this.mLevel = this.getCoilHeat().getLevel(); - this.mCostDiscount = this.getCoilHeat().getCostDiscount(); - setInputFilters(); - return ret; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sFurnaceRecipes; - } - - @Override - public void construct(ItemStack itemStack, boolean b) { - this.structureBuild_EM("main", 1,2,0, b, itemStack); - } - - private static final int pollutionPerTick = 20; - - private final static String[] desc = new String[]{ - "Furnace", - "Controller Block for the Multi Smelter", - "Smelts up to 8-128 items at once", - "Items smelted increases with coil tier", - "Creates up to: " + 20 * pollutionPerTick + " Pollution per Second", - ADV_STR_CHECK, - TT_BLUEPRINT - }; - - @Override - public String[] getDescription() { - return desc; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][11], new TT_RenderedExtendedFacingTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER)}; - } - return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][11]}; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { - return new TT_MultiSmelter(this.mName); - } - - @Override - public boolean checkRecipe_EM(ItemStack aStack) { - ArrayList<ItemStack> tInputList = getStoredInputs(); - if (tInputList.isEmpty()) - return false; - - int mVolatage = GT_Utility.safeInt(getMaxInputVoltage()); - int tMaxParrallel = 8 * this.mLevel; - int tCurrenParrallel = 0; - ItemStack tSmeltStack = tInputList.get(0); - ItemStack tOutputStack = GT_ModHandler.getSmeltingOutput(tSmeltStack,false,null); - if (tOutputStack == null) - return false; - for (ItemStack item : tInputList) { - if (!tSmeltStack.isItemEqual(item)) { - continue; - } - if (item.stackSize < (tMaxParrallel - tCurrenParrallel)) { - tCurrenParrallel += item.stackSize; - item.stackSize = 0; - } else { - item.stackSize = (tCurrenParrallel + item.stackSize) - tMaxParrallel; - tCurrenParrallel = tMaxParrallel; - break; - } - } - tCurrenParrallel *= tOutputStack.stackSize; - this.mOutputItems = new ItemStack[(tCurrenParrallel/64)+1]; - for (int i = 0; i < this.mOutputItems.length; i++) { - ItemStack tNewStack = tOutputStack.copy(); - int size = Math.min(tCurrenParrallel, 64); - tNewStack.stackSize = size; - tCurrenParrallel -= size; - this.mOutputItems[i] = tNewStack; - } - - if (this.mOutputItems.length > 0) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - calculateOverclockedNessMulti(4, 512, 1, mVolatage); - //In case recipe is too OP for that machine - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) - return false; - - this.mEUt = GT_Utility.safeInt(((long)mEUt) * this.mLevel / (long)this.mCostDiscount,1); - if (mEUt == Integer.MAX_VALUE - 1) - return false; - - if (this.mEUt > 0) - this.mEUt = (-this.mEUt); - } - updateSlots(); - return true; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return pollutionPerTick; - } - - @Override - public String[] getInfoData() { - int mPollutionReduction=0; - for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) - if (isValidMetaTileEntity(tHatch)) - mPollutionReduction = Math.max(tHatch.calculatePollutionReduction(100), mPollutionReduction); - - long storedEnergy=0; - long maxEnergy=0; - for(GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) - if (isValidMetaTileEntity(tHatch)) { - storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); - maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); - } - - return new String[]{ - StatCollector.translateToLocal("GT5U.multiblock.Progress")+": "+ - EnumChatFormatting.GREEN + mProgresstime / 20 + EnumChatFormatting.RESET +" s / "+ - EnumChatFormatting.YELLOW + mMaxProgresstime / 20 + EnumChatFormatting.RESET +" s", - StatCollector.translateToLocal("GT5U.multiblock.energy")+": "+ - EnumChatFormatting.GREEN + storedEnergy + EnumChatFormatting.RESET +" EU / "+ - EnumChatFormatting.YELLOW + maxEnergy + EnumChatFormatting.RESET +" EU", - StatCollector.translateToLocal("GT5U.multiblock.usage")+": "+ - EnumChatFormatting.RED + -mEUt + EnumChatFormatting.RESET + " EU/t", - StatCollector.translateToLocal("GT5U.multiblock.mei")+": "+ - EnumChatFormatting.YELLOW+ getMaxInputVoltage() +EnumChatFormatting.RESET+" EU/t(*2A) "+StatCollector.translateToLocal("GT5U.machines.tier")+": "+ - EnumChatFormatting.YELLOW+VN[GT_Utility.getTier(getMaxInputVoltage())]+ EnumChatFormatting.RESET, - StatCollector.translateToLocal("GT5U.multiblock.problems")+": "+ - EnumChatFormatting.RED+ (getIdealStatus() - getRepairStatus())+EnumChatFormatting.RESET+ - " "+StatCollector.translateToLocal("GT5U.multiblock.efficiency")+": "+ - EnumChatFormatting.YELLOW+ mEfficiency / 100.0F +EnumChatFormatting.RESET + " %", - StatCollector.translateToLocal("GT5U.MS.multismelting")+": "+ - EnumChatFormatting.GREEN+mLevel*8+EnumChatFormatting.RESET+" Discount: (EU/t) / "+EnumChatFormatting.GREEN+mCostDiscount+EnumChatFormatting.RESET, - StatCollector.translateToLocal("GT5U.multiblock.pollution")+": "+ EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %" - }; - } -}
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_OilCrackingUnit.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_OilCrackingUnit.java deleted file mode 100644 index 29cd0b5b0f..0000000000 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_OilCrackingUnit.java +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.github.bartimaeusnek.crossmod.tectech.tileentites.multi.GT_Replacement; - -import com.github.bartimaeusnek.crossmod.tectech.helper.CoilAdder; -import com.github.technus.tectech.mechanics.structure.IStructureDefinition; -import com.github.technus.tectech.mechanics.structure.StructureDefinition; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; -import gregtech.api.GregTech_API; -import gregtech.api.enums.HeatingCoilLevel; -import gregtech.api.enums.Materials; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -import java.util.ArrayList; - -import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.ADV_STR_CHECK; -import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.TT_BLUEPRINT; -import static com.github.technus.tectech.mechanics.structure.StructureUtility.*; - -public class TT_OilCrackingUnit extends TT_Abstract_GT_Replacement_Coils { - - public TT_OilCrackingUnit(Object unused, Object unused2) { - super(1160, "multimachine.cracker", "Oil Cracking Unit"); - } - - private TT_OilCrackingUnit(String aName) { - super(aName); - } - - private byte blocks = 0; - - private static final byte TEXTURE_INDEX = 49; - - private static final IStructureDefinition<TT_OilCrackingUnit> STRUCTURE_DEFINITION = StructureDefinition.<TT_OilCrackingUnit>builder().addShape("main", - transpose(new String[][]{ - {"EBGBF","EBGBF","EBGBF"}, - {"EB~BF","E---F","EBGBF"}, - {"EBGBF","EBGBF","EBGBF"} - }) - ).addElement( - 'B', - CoilAdder.getINSTANCE() - ).addElement( - 'E', - ofChain( - ofHatchAdder( - TT_OilCrackingUnit::addInputFluidHatch, - TEXTURE_INDEX, - 1), - onElementPass( - x -> ++x.blocks, - ofBlock( - GregTech_API.sBlockCasings4, - 1 - ) - ), - ofHatchAdder( - TT_OilCrackingUnit::addClassicMaintenanceToMachineList, - TEXTURE_INDEX, - 1 - ), - ofHatchAdder( - TT_OilCrackingUnit::addEnergyIOToMachineList, - TEXTURE_INDEX, - 1 - ) - ) - ).addElement( - 'F', - ofChain( - ofHatchAdder( - TT_OilCrackingUnit::addOutputFluidHatch, - TEXTURE_INDEX, - 2), - onElementPass( - x -> ++x.blocks, - ofBlock( - GregTech_API.sBlockCasings4, - 1 - ) - ), - ofHatchAdder( - TT_OilCrackingUnit::addClassicMaintenanceToMachineList, - TEXTURE_INDEX, - 1 - ), - ofHatchAdder( - TT_OilCrackingUnit::addEnergyIOToMachineList, - TEXTURE_INDEX, - 1 - ) - - ) - ).addElement( - 'G', - ofChain( - ofHatchAdder( - TT_OilCrackingUnit::addMiddleFluidHatch, - TEXTURE_INDEX, - 3), - onElementPass( - x -> ++x.blocks, - ofBlock( - GregTech_API.sBlockCasings4, - 1 - ) - ), - ofHatchAdder( - TT_OilCrackingUnit::addClassicMaintenanceToMachineList, - TEXTURE_INDEX, - 1 - ), - ofHatchAdder( - TT_OilCrackingUnit::addEnergyIOToMachineList, - TEXTURE_INDEX, - 1 - ) - - ) - ).build(); - - private static final String[] sfStructureDescription = new String[] { - "0 - Air", - "1 - Input Hatch", - "2 - Output Hatch", - "3 - 1x Input Hatch, rest Casings, Maintenance Hatch or Energy Hatch", - "Required: Maintenance Hatch, Energy Hatch, at Position 3 or instead of Casings", - "18 Casings at least!" - }; - - @Override - public String[] getStructureDescription(ItemStack itemStack) { - return sfStructureDescription; - } - - private GT_MetaTileEntity_Hatch_Input middleFluidHatch; - - public final boolean addMiddleFluidHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) - return false; - else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); - ((GT_MetaTileEntity_Hatch_Input)aMetaTileEntity).mRecipeMap = this.getRecipeMap(); - this.middleFluidHatch = (GT_MetaTileEntity_Hatch_Input)aMetaTileEntity; - return true; - } else - return false; - } - } - - @Override - protected boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - this.setCoilHeat(HeatingCoilLevel.None); - this.blocks = 0; - boolean ret = this.structureCheck_EM("main", 2,1,0); - setInputFilters(); - return ret && this.blocks >= 18; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sCrakingRecipes; - } - - public final boolean addOutputFluidHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) - return false; - else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { - ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); - return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output)aMetaTileEntity); - } else - return false; - } - } - - public final boolean addInputFluidHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) - return false; - else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); - ((GT_MetaTileEntity_Hatch_Input)aMetaTileEntity).mRecipeMap = this.getRecipeMap(); - return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input)aMetaTileEntity); - } else - return false; - } - } - - @Override - public IStructureDefinition<TT_OilCrackingUnit> getStructure_EM() { - return STRUCTURE_DEFINITION; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { - return new TT_OilCrackingUnit(this.mName); - } - - private final static String[] desc = new String[]{ - "Cracker", - "Controller block for the Oil Cracking Unit", - "Thermally cracks heavy hydrocarbons into lighter fractions", - "More efficient than the Chemical Reactor", - "Place the appropriate circuit in the controller", - "Gets 5% energy cost reduction per coil tier", - ADV_STR_CHECK, - TT_BLUEPRINT - }; - - @Override - public String[] getDescription() { - return desc; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][TEXTURE_INDEX], - new TT_RenderedExtendedFacingTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER)}; - } - return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][TEXTURE_INDEX]}; - } - - @Override - public boolean checkRecipe_EM(ItemStack aStack) { - ArrayList<FluidStack> tInputList = getStoredFluids(); - FluidStack[] tFluidInputs = tInputList.toArray(new FluidStack[0]); - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sCrakingRecipes.findRecipe( - getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluidInputs , mInventory[1]); - if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, tFluidInputs, mInventory[1])) { - return false; - } - setEfficiencyAndOc(tRecipe); - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) - return false; - this.mEUt *= Math.pow(0.95D, this.getCoilHeat().getTier()); - - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)}; - return true; - } - - @Override - public ArrayList<FluidStack> getStoredFluids() { - ArrayList<FluidStack> rList = new ArrayList<>(); - - for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { - tHatch.mRecipeMap = getRecipeMap(); - if (!isValidMetaTileEntity(tHatch) || tHatch.getFillableStack() == null) { - continue; - } - FluidStack tStack = tHatch.getFillableStack(); - if (!tStack.isFluidEqual(GT_ModHandler.getSteam(1000)) && !tStack.isFluidEqual(Materials.Hydrogen.getGas(1000))) - rList.add(tStack); - } - - if (this.middleFluidHatch == null || !isValidMetaTileEntity(this.middleFluidHatch) || this.middleFluidHatch.getFillableStack() == null) { - return rList; - } - this.middleFluidHatch.mRecipeMap = getRecipeMap(); - FluidStack tStack = this.middleFluidHatch.getFillableStack(); - rList.add(tStack); - - return rList; - } - - @Override - public void construct(ItemStack itemStack, boolean b) { - this.structureBuild_EM("main", 2,1,0, b, itemStack); - } -} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_PyrolyseOven.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_PyrolyseOven.java deleted file mode 100644 index 0c1182189c..0000000000 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_PyrolyseOven.java +++ /dev/null @@ -1,231 +0,0 @@ -package com.github.bartimaeusnek.crossmod.tectech.tileentites.multi.GT_Replacement; - -import com.github.bartimaeusnek.crossmod.tectech.helper.CoilAdder; -import com.github.technus.tectech.mechanics.structure.IStructureDefinition; -import com.github.technus.tectech.mechanics.structure.StructureDefinition; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.api.GregTech_API; -import gregtech.api.enums.HeatingCoilLevel; -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.render.TextureFactory; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gregtech.loaders.oreprocessing.ProcessingLog; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.oredict.OreDictionary; - -import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.ADV_STR_CHECK; -import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.TT_BLUEPRINT; -import static com.github.technus.tectech.mechanics.structure.StructureUtility.*; - -public class TT_PyrolyseOven extends TT_Abstract_GT_Replacement_Coils { - private static final int TEXTURE_INDEX = 1090; - private static final int pollutionPerTick = 30; - - public TT_PyrolyseOven(Object unused, Object unused2) { - super(1159, "multimachine.pyro", "Pyrolyse Oven"); - } - - public TT_PyrolyseOven(String aName) { - super(aName); - } - - private static final Block casingBlock; - private static final int casingMeta; - - private int blocks = 0; - - static { - if (Loader.isModLoaded("dreamcraft")) { - casingBlock = GameRegistry.findBlock("dreamcraft", "gt.blockcasingsNH"); - casingMeta = 2; - } else { - casingBlock = GregTech_API.sBlockCasings1; - casingMeta = 0; - } - } - - private static final IStructureDefinition<TT_PyrolyseOven> STRUCTURE_DEFINITION = StructureDefinition - .<TT_PyrolyseOven>builder() - .addShape("main", - transpose(new String[][]{ - {"AAAAA", "ACCCA", "ACCCA", "ACCCA", "AAAAA"}, - {"AAAAA", "A---A", "A---A", "A---A", "AAAAA"}, - {"AAAAA", "A---A", "A---A", "A---A", "AAAAA"}, - {"BB~BB", "BDDDB", "BDDDB", "BDDDB", "BBBBB"} - }) - ).addElement( - 'D', - CoilAdder.getINSTANCE() - ).addElement( - 'A', - onElementPass(x -> x.blocks++, - ofBlock( - casingBlock, - casingMeta - ) - ) - ).addElement( - 'B', - ofChain( - ofHatchAdder( - TT_PyrolyseOven::addClassicOutputToMachineList, TEXTURE_INDEX, - 1 - ), - ofHatchAdder( - TT_PyrolyseOven::addEnergyIOToMachineList, TEXTURE_INDEX, - 1 - ), - ofHatchAdder( - TT_PyrolyseOven::addClassicMaintenanceToMachineList, TEXTURE_INDEX, - 1 - ), - onElementPass(x -> x.blocks++, - ofBlock( - casingBlock, - casingMeta - ) - ) - ) - - ).addElement( - 'C', - ofChain( - ofHatchAdder( - TT_PyrolyseOven::addClassicInputToMachineList, TEXTURE_INDEX, - 2 - ), - ofHatchAdder( - TT_PyrolyseOven::addClassicMufflerToMachineList, TEXTURE_INDEX, - 2 - ), - onElementPass(x -> x.blocks++, - ofBlock( - casingBlock, - casingMeta - ) - ) - ) - - ) - .build(); - - @Override - public IStructureDefinition<TT_PyrolyseOven> getStructure_EM() { - return STRUCTURE_DEFINITION; - } - - @Override - protected boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - this.setCoilHeat(HeatingCoilLevel.None); - this.blocks = 0; - return this.structureCheck_EM("main", 2,3,0) && this.blocks >= 60; - } - - private static final String[] desc = new String[]{ - "Coke Oven", - "Controller block for the Pyrolyse Oven", - "Industrial Charcoal producer", - "Processing speed scales linearly with Coil tier:", - "CuNi: 50%, FeAlCr: 100%, Ni4Cr: 150%, Fe50CW: 200%, etc.", - "EU/t is not affected by Coil tier", - "Creates up to: " + 20 * pollutionPerTick + " Pollution per Second", - ADV_STR_CHECK, - TT_BLUEPRINT - }; - - @Override - public String[] getDescription() { - return desc; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.casingTexturePages[8][66], TextureFactory.of(aActive ? TextureFactory.of(TextureFactory.of(Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE), TextureFactory.builder().addIcon(Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE_GLOW).glow().build()) : TextureFactory.of(TextureFactory.of(Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN), TextureFactory.builder().addIcon(Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_GLOW).glow().build()))}; - } - return new ITexture[]{Textures.BlockIcons.casingTexturePages[8][66]}; - } - - @Override - public boolean checkRecipe_EM(ItemStack aStack) { - ItemStack[] tInputs = getCompactedInputs(); - FluidStack[] tFluids = getCompactedFluids(); - - if (tInputs.length <= 0) - return false; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - - //Dynamic recipe adding for newly found logWoods - wont be visible in nei most probably - if (tRecipe == null) - tRecipe = addRecipesDynamically(tInputs, tFluids, tTier); - - if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) - return false; - setEfficiencyAndOc(tRecipe); - //In case recipe is too OP for that machine - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) - return false; - if (this.mEUt > 0) - this.mEUt = (-this.mEUt); - this.mMaxProgresstime = Math.max(mMaxProgresstime * 2 / (1 + this.heatingCoilLevel.getTier()), 1); - if (tRecipe.mOutputs.length > 0) - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; - if (tRecipe.mFluidOutputs.length > 0) - this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)}; - updateSlots(); - return true; - } - - private GT_Recipe addRecipesDynamically(ItemStack[] tInputs, FluidStack[] tFluids, int tTier) { - if (tInputs.length <= 1 && (tInputs[0] == null || tInputs[0].getItem() == GT_Utility.getIntegratedCircuit(0).getItem())) { - return null; - } - int oreId = OreDictionary.getOreID("logWood"); - for (ItemStack is : tInputs) { - for (int id : OreDictionary.getOreIDs(is)) { - if (oreId == id) { - ProcessingLog.addPyrolyeOvenRecipes(is); - return GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - } - } - } - return null; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new TT_PyrolyseOven(this.mName); - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return pollutionPerTick; - } - - private static final String[] sfStructureDescription = new String[] { - "0 - Air", - "1 - Output Hatch, Output Bus, Energy Hatch, Maintenance Hatch, Casing", - "2 - Input Hatch, Input Bus, Muffler Hatch, Casing", - "60 Casings at least!" - }; - - @Override - public String[] getStructureDescription(ItemStack itemStack) { - return sfStructureDescription; - } - - @Override - public void construct(ItemStack itemStack, boolean b) { - this.structureBuild_EM("main", 2,3,0, b, itemStack); - } -} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_VacuumFreezer.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_VacuumFreezer.java deleted file mode 100644 index 0b415a0d4c..0000000000 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_VacuumFreezer.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.github.bartimaeusnek.crossmod.tectech.tileentites.multi.GT_Replacement; - -import com.github.bartimaeusnek.crossmod.tectech.helper.StructureDefinitions; -import com.github.technus.tectech.mechanics.structure.IStructureDefinition; -import com.github.technus.tectech.mechanics.structure.StructureDefinition; -import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti; -import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -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.implementations.*; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import net.minecraft.item.ItemStack; - -import java.util.ArrayList; - -import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.ADV_STR_CHECK; -import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.TT_BLUEPRINT; -import static com.github.technus.tectech.mechanics.structure.StructureUtility.*; - -public class TT_VacuumFreezer extends TT_Abstract_GT_Replacement { - public TT_VacuumFreezer(Object unused, Object unused2) { - super(1002, "multimachine.vacuumfreezer", "Vacuum Freezer"); - } - - private TT_VacuumFreezer(String aName) { - super(aName); - } - - private static final byte TEXTURE_INDEX = 17; - - private byte blocks = 0; - - private static final IStructureDefinition<TT_VacuumFreezer> STRUCTURE_DEFINITION = - StructureDefinition.<TT_VacuumFreezer>builder().addShape("main", - StructureDefinitions.CUBE_NO_MUFFLER.getDefinition() - ).addElement( - 'V', - ofChain( - onElementPass( - x -> ++x.blocks, - ofBlock( - GregTech_API.sBlockCasings2, - 1 - ) - ), - ofHatchAdder( - TT_VacuumFreezer::addVacuumFreezerHatches, - TEXTURE_INDEX, - 1 - ) - ) - ).build(); - - @Override - public IStructureDefinition<TT_VacuumFreezer> getStructure_EM() { - return STRUCTURE_DEFINITION; - } - - private final static String[] desc = new String[]{ - "Vacuum Freezer", - "Controller Block for the Vacuum Freezer", - "Cools hot ingots and cells", - ADV_STR_CHECK, - TT_BLUEPRINT - }; - - private static final String[] sfStructureDescription = new String[] { - "0 - Air", - "Required: Output Bus, Input Bus, Energy Hatch, Maintenance Hatch" - }; - - @Override - public String[] getStructureDescription(ItemStack itemStack) { - return sfStructureDescription; - } - - public String[] getDescription() { - return desc; - } - - @Override - protected boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - this.blocks = 0; - boolean ret = this.structureCheck_EM("main", 1,1,0) - && this.blocks >= 16; - setInputFilters(); - return ret; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sVacuumRecipes; - } - - @SideOnly(Side.CLIENT) - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][TEXTURE_INDEX], new TT_RenderedExtendedFacingTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; - } - return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][TEXTURE_INDEX]}; - } - - @Override - public boolean checkRecipe_EM(ItemStack itemStack) { - ArrayList<ItemStack> tInputList = getStoredInputs(); - for (ItemStack tInput : tInputList) { - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sVacuumRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, tInput); - if (tRecipe == null) { - continue; - } - if (!tRecipe.isRecipeInputEqual(true, null, tInput)) { - continue; - } - setEfficiencyAndOc(tRecipe); - //In case recipe is too OP for that machine - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) - return false; - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; - updateSlots(); - return true; - } - return false; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { - return new TT_VacuumFreezer(this.mName); - } - - @Override - public void construct(ItemStack itemStack, boolean b) { - this.structureBuild_EM("main", 1,1,0, b, itemStack); - } - - public final boolean addVacuumFreezerHatches(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - else - return false; - - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) - return this.mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) - return this.mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) - return this.mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) - return this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) - return this.eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); - else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) - return this.eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity); - return false; - } -} |