diff options
| author | miozune <miozune@gmail.com> | 2022-07-15 14:34:19 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-15 06:34:19 +0100 |
| commit | c0eb617fa5c146b7a222c5461faf14394508cf4b (patch) | |
| tree | e25d23490122b5c663fd4e2791a81704c0183b00 /src/main/java/goodgenerator/blocks/tileEntity/base | |
| parent | 36301feacf5a33ded24d338ae39985da6080d2bb (diff) | |
| download | GT5-Unofficial-c0eb617fa5c146b7a222c5461faf14394508cf4b.tar.gz GT5-Unofficial-c0eb617fa5c146b7a222c5461faf14394508cf4b.tar.bz2 GT5-Unofficial-c0eb617fa5c146b7a222c5461faf14394508cf4b.zip | |
Expand item limit for Neutron Activator & Add back Low Quality Naquadria Sulphate to the outputs from Concentrated Enriched-Naquadah Sludge (#53)
* Expand item limit for Neutron Activator & Add back Low Quality Naquadria Sulphate to the outputs from Concentrated Enriched-Naquadah Sludge
* updateBuildScript & spotlessApply
Diffstat (limited to 'src/main/java/goodgenerator/blocks/tileEntity/base')
4 files changed, 905 insertions, 680 deletions
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/base/GT_MetaTileEntity_LargeTurbineBase.java b/src/main/java/goodgenerator/blocks/tileEntity/base/GT_MetaTileEntity_LargeTurbineBase.java index 5b9bfaaf79..75d2b201e0 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/base/GT_MetaTileEntity_LargeTurbineBase.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/base/GT_MetaTileEntity_LargeTurbineBase.java @@ -1,7 +1,13 @@ -//copied from gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbine -//The origin one in gt made the abstract method private so i can't imp it. +// copied from gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbine +// The origin one in gt made the abstract method private so i can't imp it. package goodgenerator.blocks.tileEntity.base; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; + import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.IStructureElementCheckOnly; import com.gtnewhorizon.structurelib.structure.StructureDefinition; @@ -13,6 +19,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynam import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; import gregtech.api.util.GT_Utility; import gregtech.common.items.GT_MetaGenerated_Tool_01; +import java.util.ArrayList; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -22,37 +29,56 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidStack; -import java.util.ArrayList; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; -import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; - -public abstract class GT_MetaTileEntity_LargeTurbineBase extends GT_MetaTileEntity_EnhancedMultiBlockBase<GT_MetaTileEntity_LargeTurbineBase> { +public abstract class GT_MetaTileEntity_LargeTurbineBase + extends GT_MetaTileEntity_EnhancedMultiBlockBase<GT_MetaTileEntity_LargeTurbineBase> { private static final String STRUCTURE_PIECE_MAIN = "main"; - private static final ClassValue<IStructureDefinition<GT_MetaTileEntity_LargeTurbineBase>> STRUCTURE_DEFINITION = new ClassValue<IStructureDefinition<GT_MetaTileEntity_LargeTurbineBase>>() { - @Override - protected IStructureDefinition<GT_MetaTileEntity_LargeTurbineBase> computeValue(Class<?> type) { - return StructureDefinition.<GT_MetaTileEntity_LargeTurbineBase>builder() - .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ - {" ", "xxxxx", "xxxxx", "xxxxx", "xxxxx",}, - {" --- ", "xcccx", "xchcx", "xchcx", "xcccx",}, - {" --- ", "xc~cx", "xh-hx", "xh-hx", "xcdcx",}, - {" --- ", "xcccx", "xchcx", "xchcx", "xcccx",}, - {" ", "xxxxx", "xxxxx", "xxxxx", "xxxxx",}, - })) - .addElement('c', lazy(t -> ofBlock(t.getCasingBlock(), t.getCasingMeta()))) - .addElement('d', lazy(t -> ofHatchAdder(GT_MetaTileEntity_LargeTurbineBase::addDynamoToMachineList, t.getCasingTextureIndex(), 1))) - .addElement('h', lazy(t -> ofHatchAdderOptional(GT_MetaTileEntity_LargeTurbineBase::addToMachineList, t.getCasingTextureIndex(), 2, t.getCasingBlock(), t.getCasingMeta()))) - .addElement('x', (IStructureElementCheckOnly<GT_MetaTileEntity_LargeTurbineBase>) (aContext, aWorld, aX, aY, aZ) -> { - TileEntity tTile = aWorld.getTileEntity(aX, aY, aZ); - return !(tTile instanceof IGregTechTileEntity) || !(((IGregTechTileEntity) tTile).getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbineBase); - }) - .build(); - } - }; + private static final ClassValue<IStructureDefinition<GT_MetaTileEntity_LargeTurbineBase>> STRUCTURE_DEFINITION = + new ClassValue<IStructureDefinition<GT_MetaTileEntity_LargeTurbineBase>>() { + @Override + protected IStructureDefinition<GT_MetaTileEntity_LargeTurbineBase> computeValue(Class<?> type) { + return StructureDefinition.<GT_MetaTileEntity_LargeTurbineBase>builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][] { + { + " ", "xxxxx", "xxxxx", "xxxxx", "xxxxx", + }, + { + " --- ", "xcccx", "xchcx", "xchcx", "xcccx", + }, + { + " --- ", "xc~cx", "xh-hx", "xh-hx", "xcdcx", + }, + { + " --- ", "xcccx", "xchcx", "xchcx", "xcccx", + }, + { + " ", "xxxxx", "xxxxx", "xxxxx", "xxxxx", + }, + })) + .addElement('c', lazy(t -> ofBlock(t.getCasingBlock(), t.getCasingMeta()))) + .addElement( + 'd', + lazy(t -> ofHatchAdder( + GT_MetaTileEntity_LargeTurbineBase::addDynamoToMachineList, + t.getCasingTextureIndex(), + 1))) + .addElement( + 'h', + lazy(t -> ofHatchAdderOptional( + GT_MetaTileEntity_LargeTurbineBase::addToMachineList, + t.getCasingTextureIndex(), + 2, + t.getCasingBlock(), + t.getCasingMeta()))) + .addElement('x', (IStructureElementCheckOnly<GT_MetaTileEntity_LargeTurbineBase>) + (aContext, aWorld, aX, aY, aZ) -> { + TileEntity tTile = aWorld.getTileEntity(aX, aY, aZ); + return !(tTile instanceof IGregTechTileEntity) + || !(((IGregTechTileEntity) tTile).getMetaTileEntity() + instanceof GT_MetaTileEntity_LargeTurbineBase); + }) + .build(); + } + }; protected int baseEff = 0; protected int optFlow = 0; @@ -76,7 +102,8 @@ public abstract class GT_MetaTileEntity_LargeTurbineBase extends GT_MetaTileEnti @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeTurbine.png"); + return new GT_GUIContainer_MultiMachine( + aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeTurbine.png"); } @Override @@ -86,7 +113,9 @@ public abstract class GT_MetaTileEntity_LargeTurbineBase extends GT_MetaTileEnti @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - return checkPiece(STRUCTURE_PIECE_MAIN, 2, 2, 1) && mMaintenanceHatches.size() == 1 && mMufflerHatches.isEmpty() == (getPollutionPerTick(null) == 0); + return checkPiece(STRUCTURE_PIECE_MAIN, 2, 2, 1) + && mMaintenanceHatches.size() == 1 + && mMufflerHatches.isEmpty() == (getPollutionPerTick(null) == 0); } public abstract Block getCasingBlock(); @@ -97,7 +126,10 @@ public abstract class GT_MetaTileEntity_LargeTurbineBase extends GT_MetaTileEnti @Override public boolean addToMachineList(IGregTechTileEntity tTileEntity, int aBaseCasingIndex) { - return addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex()) || addInputToMachineList(tTileEntity, getCasingTextureIndex()) || addOutputToMachineList(tTileEntity, getCasingTextureIndex()) || addMufflerToMachineList(tTileEntity, getCasingTextureIndex()); + return addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex()) + || addInputToMachineList(tTileEntity, getCasingTextureIndex()) + || addOutputToMachineList(tTileEntity, getCasingTextureIndex()) + || addMufflerToMachineList(tTileEntity, getCasingTextureIndex()); } @Override @@ -112,22 +144,33 @@ public abstract class GT_MetaTileEntity_LargeTurbineBase extends GT_MetaTileEnti @Override public boolean checkRecipe(ItemStack aStack) { - if ((counter & 7) == 0 && (aStack == null || !(aStack.getItem() instanceof GT_MetaGenerated_Tool) || aStack.getItemDamage() < 170 || aStack.getItemDamage() > 179)) { + if ((counter & 7) == 0 + && (aStack == null + || !(aStack.getItem() instanceof GT_MetaGenerated_Tool) + || aStack.getItemDamage() < 170 + || aStack.getItemDamage() > 179)) { stopMachine(); return false; } ArrayList<FluidStack> tFluids = getStoredFluids(); if (tFluids.size() > 0) { - if (baseEff == 0 || optFlow == 0 || counter >= 512 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled() + if (baseEff == 0 + || optFlow == 0 + || counter >= 512 + || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled() || this.getBaseMetaTileEntity().hasInventoryBeenModified()) { counter = 0; - baseEff = GT_Utility.safeInt((long) ((5F + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack)) * 1000F)); - optFlow = GT_Utility.safeInt((long) Math.max(Float.MIN_NORMAL, - ((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack).getSpeedMultiplier() + baseEff = GT_Utility.safeInt( + (long) ((5F + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack)) * 1000F)); + optFlow = GT_Utility.safeInt((long) Math.max( + Float.MIN_NORMAL, + ((GT_MetaGenerated_Tool) aStack.getItem()) + .getToolStats(aStack) + .getSpeedMultiplier() * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolSpeed * 50)); - if(optFlow<=0 || baseEff<=0){ - stopMachine();//in case the turbine got removed + if (optFlow <= 0 || baseEff <= 0) { + stopMachine(); // in case the turbine got removed return false; } } else { @@ -135,23 +178,24 @@ public abstract class GT_MetaTileEntity_LargeTurbineBase extends GT_MetaTileEnti } } - int newPower = fluidIntoPower(tFluids, optFlow, baseEff); // How much the turbine should be producing with this flow + int newPower = + fluidIntoPower(tFluids, optFlow, baseEff); // How much the turbine should be producing with this flow int difference = newPower - this.mEUt; // difference between current output and new output - // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the difference in power level (per tick) + // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the difference in + // power level (per tick) // This is how much the turbine can actually change during this tick - int maxChangeAllowed = Math.max(10, GT_Utility.safeInt((long)Math.abs(difference)/100)); + int maxChangeAllowed = Math.max(10, GT_Utility.safeInt((long) Math.abs(difference) / 100)); if (Math.abs(difference) > maxChangeAllowed) { // If this difference is too big, use the maximum allowed change int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative. this.mEUt += change; // Apply the change - } else - this.mEUt = newPower; + } else this.mEUt = newPower; if (this.mEUt <= 0) { - //stopMachine(); - this.mEUt=0; - this.mEfficiency=0; + // stopMachine(); + this.mEUt = 0; + this.mEfficiency = 0; return false; } else { this.mMaxProgresstime = 1; @@ -186,58 +230,74 @@ public abstract class GT_MetaTileEntity_LargeTurbineBase extends GT_MetaTileEnti @Override public String[] getInfoData() { - int mPollutionReduction=0; + int mPollutionReduction = 0; for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { if (isValidMetaTileEntity(tHatch)) { - mPollutionReduction=Math.max(tHatch.calculatePollutionReduction(100),mPollutionReduction); + mPollutionReduction = Math.max(tHatch.calculatePollutionReduction(100), mPollutionReduction); } } - String tRunning = mMaxProgresstime>0 ? - - EnumChatFormatting.GREEN+StatCollector.translateToLocal("GT5U.turbine.running.true")+EnumChatFormatting.RESET : - EnumChatFormatting.RED+StatCollector.translateToLocal("GT5U.turbine.running.false")+EnumChatFormatting.RESET; - String tMaintainance = getIdealStatus() == getRepairStatus() ? - EnumChatFormatting.GREEN+StatCollector.translateToLocal("GT5U.turbine.maintenance.false")+EnumChatFormatting.RESET : - EnumChatFormatting.RED+StatCollector.translateToLocal("GT5U.turbine.maintenance.true")+EnumChatFormatting.RESET ; + String tRunning = mMaxProgresstime > 0 + ? EnumChatFormatting.GREEN + + StatCollector.translateToLocal("GT5U.turbine.running.true") + + EnumChatFormatting.RESET + : EnumChatFormatting.RED + + StatCollector.translateToLocal("GT5U.turbine.running.false") + + EnumChatFormatting.RESET; + String tMaintainance = getIdealStatus() == getRepairStatus() + ? EnumChatFormatting.GREEN + + StatCollector.translateToLocal("GT5U.turbine.maintenance.false") + + EnumChatFormatting.RESET + : EnumChatFormatting.RED + + StatCollector.translateToLocal("GT5U.turbine.maintenance.true") + + EnumChatFormatting.RESET; int tDura = 0; if (mInventory[1] != null && mInventory[1].getItem() instanceof GT_MetaGenerated_Tool_01) { - tDura = GT_Utility.safeInt((long)(100.0f / GT_MetaGenerated_Tool.getToolMaxDamage(mInventory[1]) * (GT_MetaGenerated_Tool.getToolDamage(mInventory[1]))+1)); + tDura = GT_Utility.safeInt((long) (100.0f + / GT_MetaGenerated_Tool.getToolMaxDamage(mInventory[1]) + * (GT_MetaGenerated_Tool.getToolDamage(mInventory[1])) + + 1)); } - long storedEnergy=0; - long maxEnergy=0; - for(GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) { + long storedEnergy = 0; + long maxEnergy = 0; + for (GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) { if (isValidMetaTileEntity(tHatch)) { - storedEnergy+=tHatch.getBaseMetaTileEntity().getStoredEU(); - maxEnergy+=tHatch.getBaseMetaTileEntity().getEUCapacity(); + storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); + maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); } } - String[] ret = new String[]{ - // 8 Lines available for information panels - tRunning + ": " + EnumChatFormatting.RED + GT_Utility.formatNumbers(mEUt) + EnumChatFormatting.RESET + " EU/t", /* 1 */ - tMaintainance, /* 2 */ - StatCollector.translateToLocal("GT5U.turbine.efficiency") + ": " + - EnumChatFormatting.YELLOW + (mEfficiency / 100F) + EnumChatFormatting.RESET + "%", /* 2 */ - StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + - EnumChatFormatting.GREEN + GT_Utility.formatNumbers(storedEnergy) + EnumChatFormatting.RESET + " EU / " + /* 3 */ - EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(maxEnergy) + EnumChatFormatting.RESET + " EU", - StatCollector.translateToLocal("GT5U.turbine.flow") + ": " + - EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(GT_Utility.safeInt((long) realOptFlow)) + EnumChatFormatting.RESET + " L/t" + /* 4 */ - EnumChatFormatting.YELLOW + " (" + (looseFit ? StatCollector.translateToLocal("GT5U.turbine.loose") : StatCollector.translateToLocal("GT5U.turbine.tight")) + ")", /* 5 */ - StatCollector.translateToLocal("GT5U.turbine.fuel") + ": " + - EnumChatFormatting.GOLD + GT_Utility.formatNumbers(storedFluid) + EnumChatFormatting.RESET + "L", /* 6 */ - StatCollector.translateToLocal("GT5U.turbine.dmg") + ": " + - EnumChatFormatting.RED + tDura + EnumChatFormatting.RESET + "%", /* 7 */ - StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + - EnumChatFormatting.GREEN + mPollutionReduction + EnumChatFormatting.RESET + " %" /* 8 */ + String[] ret = new String[] { + // 8 Lines available for information panels + tRunning + ": " + EnumChatFormatting.RED + GT_Utility.formatNumbers(mEUt) + EnumChatFormatting.RESET + + " EU/t", /* 1 */ + tMaintainance, /* 2 */ + StatCollector.translateToLocal("GT5U.turbine.efficiency") + ": " + EnumChatFormatting.YELLOW + + (mEfficiency / 100F) + EnumChatFormatting.RESET + "%", /* 2 */ + StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + EnumChatFormatting.GREEN + + GT_Utility.formatNumbers(storedEnergy) + EnumChatFormatting.RESET + " EU / " + + /* 3 */ EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(maxEnergy) + EnumChatFormatting.RESET + " EU", + StatCollector.translateToLocal("GT5U.turbine.flow") + ": " + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(GT_Utility.safeInt((long) realOptFlow)) + EnumChatFormatting.RESET + + " L/t" + /* 4 */ EnumChatFormatting.YELLOW + + " (" + + (looseFit + ? StatCollector.translateToLocal("GT5U.turbine.loose") + : StatCollector.translateToLocal("GT5U.turbine.tight")) + + ")", /* 5 */ + StatCollector.translateToLocal("GT5U.turbine.fuel") + ": " + EnumChatFormatting.GOLD + + GT_Utility.formatNumbers(storedFluid) + EnumChatFormatting.RESET + "L", /* 6 */ + StatCollector.translateToLocal("GT5U.turbine.dmg") + ": " + EnumChatFormatting.RED + tDura + + EnumChatFormatting.RESET + "%", /* 7 */ + StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + EnumChatFormatting.GREEN + + mPollutionReduction + EnumChatFormatting.RESET + " %" /* 8 */ }; if (!this.getClass().getName().contains("Steam")) - ret[4] = StatCollector.translateToLocal("GT5U.turbine.flow") + ": " + EnumChatFormatting.YELLOW + GT_Utility.safeInt((long) realOptFlow) + EnumChatFormatting.RESET + " L/t"; + ret[4] = StatCollector.translateToLocal("GT5U.turbine.flow") + ": " + EnumChatFormatting.YELLOW + + GT_Utility.safeInt((long) realOptFlow) + EnumChatFormatting.RESET + " L/t"; return ret; - - } public boolean hasTurbine() { diff --git a/src/main/java/goodgenerator/blocks/tileEntity/base/GT_MetaTileEntity_TooltipMultiBlockBase_EM.java b/src/main/java/goodgenerator/blocks/tileEntity/base/GT_MetaTileEntity_TooltipMultiBlockBase_EM.java index 896d341ddf..7a09f4eb95 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/base/GT_MetaTileEntity_TooltipMultiBlockBase_EM.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/base/GT_MetaTileEntity_TooltipMultiBlockBase_EM.java @@ -3,12 +3,12 @@ package goodgenerator.blocks.tileEntity.base; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import gregtech.api.interfaces.ISecondaryDescribable; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import org.lwjgl.input.Keyboard; - import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import org.lwjgl.input.Keyboard; -public abstract class GT_MetaTileEntity_TooltipMultiBlockBase_EM extends GT_MetaTileEntity_MultiblockBase_EM implements ISecondaryDescribable { +public abstract class GT_MetaTileEntity_TooltipMultiBlockBase_EM extends GT_MetaTileEntity_MultiblockBase_EM + implements ISecondaryDescribable { private static final Map<Integer, GT_Multiblock_Tooltip_Builder> tooltips = new ConcurrentHashMap<>(); protected GT_MetaTileEntity_TooltipMultiBlockBase_EM(int aID, String aName, String aNameRegional) { @@ -48,5 +48,4 @@ public abstract class GT_MetaTileEntity_TooltipMultiBlockBase_EM extends GT_Meta public String[] getSecondaryDescription() { return getTooltip().getStructureInformation(); } - } diff --git a/src/main/java/goodgenerator/blocks/tileEntity/base/LargeFusionComputer.java b/src/main/java/goodgenerator/blocks/tileEntity/base/LargeFusionComputer.java index e563596813..303fc3947d 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/base/LargeFusionComputer.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/base/LargeFusionComputer.java @@ -1,5 +1,12 @@ package goodgenerator.blocks.tileEntity.base; +import static com.github.bartimaeusnek.bartworks.util.RecipeFinderForParallel.getMultiOutput; +import static com.github.bartimaeusnek.bartworks.util.RecipeFinderForParallel.handleParallelRecipe; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.enums.Textures.BlockIcons.*; +import static gregtech.api.util.GT_StructureUtility.ofFrame; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; + import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -18,6 +25,7 @@ import gregtech.api.objects.GT_ItemStack; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; +import java.util.ArrayList; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -28,15 +36,6 @@ import net.minecraft.world.ChunkCoordIntPair; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import java.util.ArrayList; - -import static com.github.bartimaeusnek.bartworks.util.RecipeFinderForParallel.getMultiOutput; -import static com.github.bartimaeusnek.bartworks.util.RecipeFinderForParallel.handleParallelRecipe; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; -import static gregtech.api.enums.Textures.BlockIcons.*; -import static gregtech.api.util.GT_StructureUtility.ofFrame; -import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; - public abstract class LargeFusionComputer extends GT_MetaTileEntity_TooltipMultiBlockBase_EM implements IConstructable { public static final String MAIN_NAME = "largeFusion"; @@ -44,44 +43,57 @@ public abstract class LargeFusionComputer extends GT_MetaTileEntity_TooltipMulti public GT_Recipe mLastRecipe; public int para; public int mEUStore; - private static final ClassValue<IStructureDefinition<LargeFusionComputer>> STRUCTURE_DEFINITION = new ClassValue<IStructureDefinition<LargeFusionComputer>>() { - @Override - protected IStructureDefinition<LargeFusionComputer> computeValue(Class<?> type) { - return StructureDefinition.<LargeFusionComputer>builder() - .addShape(MAIN_NAME, transpose(new String[][]{ - L0, L1, L2, L3, L2, L1, L0 - })) - .addElement( - 'H', lazy(x -> ofBlock(x.getCoilBlock(), x.getCoilMeta())) - ) - .addElement( - 'C', lazy(x -> ofBlock(x.getCasingBlock(), x.getCasingMeta())) - ) - .addElement( - 'B', lazy(x -> ofBlock(x.getGlassBlock(), x.getGlassMeta())) - ) - .addElement( - 'I', lazy(x -> ofHatchAdderOptional(LargeFusionComputer::addInjector, x.textureIndex(), 1, x.getGlassBlock(), x.getGlassMeta())) - ) - .addElement( - 'O', lazy(x -> ofHatchAdderOptional(LargeFusionComputer::addExtractor, x.textureIndex(), 2, x.getGlassBlock(), x.getGlassMeta())) - ) - .addElement( - 'E', lazy(x -> ofHatchAdderOptional(LargeFusionComputer::addEnergyInjector, x.textureIndex(), 3, x.getCasingBlock(), x.getCasingMeta())) - ) - .addElement( - 'F', lazy(x -> ofFrame(x.getFrameBox())) - ) - .build(); - } - }; + private static final ClassValue<IStructureDefinition<LargeFusionComputer>> STRUCTURE_DEFINITION = + new ClassValue<IStructureDefinition<LargeFusionComputer>>() { + @Override + protected IStructureDefinition<LargeFusionComputer> computeValue(Class<?> type) { + return StructureDefinition.<LargeFusionComputer>builder() + .addShape(MAIN_NAME, transpose(new String[][] {L0, L1, L2, L3, L2, L1, L0})) + .addElement('H', lazy(x -> ofBlock(x.getCoilBlock(), x.getCoilMeta()))) + .addElement('C', lazy(x -> ofBlock(x.getCasingBlock(), x.getCasingMeta()))) + .addElement('B', lazy(x -> ofBlock(x.getGlassBlock(), x.getGlassMeta()))) + .addElement( + 'I', + lazy(x -> ofHatchAdderOptional( + LargeFusionComputer::addInjector, + x.textureIndex(), + 1, + x.getGlassBlock(), + x.getGlassMeta()))) + .addElement( + 'O', + lazy(x -> ofHatchAdderOptional( + LargeFusionComputer::addExtractor, + x.textureIndex(), + 2, + x.getGlassBlock(), + x.getGlassMeta()))) + .addElement( + 'E', + lazy(x -> ofHatchAdderOptional( + LargeFusionComputer::addEnergyInjector, + x.textureIndex(), + 3, + x.getCasingBlock(), + x.getCasingMeta()))) + .addElement('F', lazy(x -> ofFrame(x.getFrameBox()))) + .build(); + } + }; static { - Textures.BlockIcons.setCasingTextureForId(52, + Textures.BlockIcons.setCasingTextureForId( + 52, TextureFactory.of( - TextureFactory.builder().addIcon(MACHINE_CASING_FUSION_GLASS_YELLOW).extFacing().build(), - TextureFactory.builder().addIcon(MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW).extFacing().glow().build() - )); + TextureFactory.builder() + .addIcon(MACHINE_CASING_FUSION_GLASS_YELLOW) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW) + .extFacing() + .glow() + .build())); } public LargeFusionComputer(String name) { @@ -89,7 +101,7 @@ public abstract class LargeFusionComputer extends GT_MetaTileEntity_TooltipMulti } public LargeFusionComputer(int id, String name, String nameRegional) { - super(id,name,nameRegional); + super(id, name, nameRegional); } @Override @@ -122,7 +134,8 @@ public abstract class LargeFusionComputer extends GT_MetaTileEntity_TooltipMulti public int textureIndex() { return 53; - }; + } + ; public abstract ITexture getTextureOverlay(); @@ -134,7 +147,10 @@ public abstract class LargeFusionComputer extends GT_MetaTileEntity_TooltipMulti @Override public boolean checkMachine_EM(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { this.eEnergyMulti.clear(); - if (structureCheck_EM(MAIN_NAME, 23, 3, 40) && mInputHatches.size() > 1 && !mOutputHatches.isEmpty() && (mEnergyHatches.size() + eEnergyMulti.size()) != 0) { + if (structureCheck_EM(MAIN_NAME, 23, 3, 40) + && mInputHatches.size() > 1 + && !mOutputHatches.isEmpty() + && (mEnergyHatches.size() + eEnergyMulti.size()) != 0) { fixAllIssue(); return true; } @@ -159,30 +175,45 @@ public abstract class LargeFusionComputer extends GT_MetaTileEntity_TooltipMulti public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide() && !aBaseMetaTileEntity.isAllowedToWork()) { // if machine has stopped, stop chunkloading - GT_ChunkManager.releaseTicket((TileEntity)aBaseMetaTileEntity); + GT_ChunkManager.releaseTicket((TileEntity) aBaseMetaTileEntity); this.isLoadedChunk = false; - } - else if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && !this.isLoadedChunk) { - //load a 3x3 area when machine is running - GT_ChunkManager.releaseTicket((TileEntity)aBaseMetaTileEntity); + } else if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && !this.isLoadedChunk) { + // load a 3x3 area when machine is running + GT_ChunkManager.releaseTicket((TileEntity) aBaseMetaTileEntity); int offX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()).offsetX; int offZ = ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()).offsetZ; - GT_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity, new ChunkCoordIntPair(getChunkX() + offX, getChunkZ() + offZ)); - GT_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity, new ChunkCoordIntPair(getChunkX() + 1 + offX, getChunkZ() + 1 + offZ)); - GT_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity, new ChunkCoordIntPair(getChunkX() + 1 + offX, getChunkZ() + offZ)); - GT_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity, new ChunkCoordIntPair(getChunkX() + 1 + offX, getChunkZ() - 1 + offZ)); - GT_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity, new ChunkCoordIntPair(getChunkX() - 1 + offX, getChunkZ() + 1 + offZ)); - GT_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity, new ChunkCoordIntPair(getChunkX() - 1 + offX, getChunkZ() + offZ)); - GT_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity, new ChunkCoordIntPair(getChunkX() - 1 + offX, getChunkZ() - 1 + offZ)); - GT_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity, new ChunkCoordIntPair(getChunkX() + offX, getChunkZ() + 1 + offZ)); - GT_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity, new ChunkCoordIntPair(getChunkX() + offX, getChunkZ() - 1 + offZ)); + GT_ChunkManager.requestChunkLoad( + (TileEntity) aBaseMetaTileEntity, new ChunkCoordIntPair(getChunkX() + offX, getChunkZ() + offZ)); + GT_ChunkManager.requestChunkLoad( + (TileEntity) aBaseMetaTileEntity, + new ChunkCoordIntPair(getChunkX() + 1 + offX, getChunkZ() + 1 + offZ)); + GT_ChunkManager.requestChunkLoad( + (TileEntity) aBaseMetaTileEntity, + new ChunkCoordIntPair(getChunkX() + 1 + offX, getChunkZ() + offZ)); + GT_ChunkManager.requestChunkLoad( + (TileEntity) aBaseMetaTileEntity, + new ChunkCoordIntPair(getChunkX() + 1 + offX, getChunkZ() - 1 + offZ)); + GT_ChunkManager.requestChunkLoad( + (TileEntity) aBaseMetaTileEntity, + new ChunkCoordIntPair(getChunkX() - 1 + offX, getChunkZ() + 1 + offZ)); + GT_ChunkManager.requestChunkLoad( + (TileEntity) aBaseMetaTileEntity, + new ChunkCoordIntPair(getChunkX() - 1 + offX, getChunkZ() + offZ)); + GT_ChunkManager.requestChunkLoad( + (TileEntity) aBaseMetaTileEntity, + new ChunkCoordIntPair(getChunkX() - 1 + offX, getChunkZ() - 1 + offZ)); + GT_ChunkManager.requestChunkLoad( + (TileEntity) aBaseMetaTileEntity, + new ChunkCoordIntPair(getChunkX() + offX, getChunkZ() + 1 + offZ)); + GT_ChunkManager.requestChunkLoad( + (TileEntity) aBaseMetaTileEntity, + new ChunkCoordIntPair(getChunkX() + offX, getChunkZ() - 1 + offZ)); this.isLoadedChunk = true; } if (aBaseMetaTileEntity.isServerSide()) { if (aTick % 400 == 0) fixAllIssue(); - if (mEfficiency < 0) - mEfficiency = 0; + if (mEfficiency < 0) mEfficiency = 0; if (mRunningOnLoad && checkMachine(aBaseMetaTileEntity, mInventory[1])) { this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); checkRecipe(mInventory[1]); @@ -195,11 +226,18 @@ public abstract class LargeFusionComputer extends GT_MetaTileEntity_TooltipMulti if (this.mEnergyHatches != null) { for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) if (isValidMetaTileEntity(tHatch)) { - if (aBaseMetaTileEntity.getStoredEU() + (2048L * tierOverclock() * getMaxPara() * extraPara(100)) < maxEUStore() - && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(2048L * tierOverclock() * getMaxPara() * extraPara(100), false)) { - aBaseMetaTileEntity.increaseStoredEnergyUnits(2048L * tierOverclock() * getMaxPara() * extraPara(100), true); + if (aBaseMetaTileEntity.getStoredEU() + + (2048L * tierOverclock() * getMaxPara() * extraPara(100)) + < maxEUStore() + && tHatch.getBaseMetaTileEntity() + .decreaseStoredEnergyUnits( + 2048L * tierOverclock() * getMaxPara() * extraPara(100), + false)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits( + 2048L * tierOverclock() * getMaxPara() * extraPara(100), true); } else if (aBaseMetaTileEntity.getStoredEU() + (2048L * tierOverclock()) < maxEUStore() - && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(2048L * tierOverclock(), false)) { + && tHatch.getBaseMetaTileEntity() + .decreaseStoredEnergyUnits(2048L * tierOverclock(), false)) { aBaseMetaTileEntity.increaseStoredEnergyUnits(2048L * tierOverclock(), true); } } @@ -207,11 +245,18 @@ public abstract class LargeFusionComputer extends GT_MetaTileEntity_TooltipMulti if (this.eEnergyMulti != null) { for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) if (isValidMetaTileEntity(tHatch)) { - if (aBaseMetaTileEntity.getStoredEU() + (2048L * tierOverclock() * getMaxPara() * extraPara(100)) < maxEUStore() - && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(2048L * tierOverclock() * getMaxPara() * extraPara(100), false)) { - aBaseMetaTileEntity.increaseStoredEnergyUnits(2048L * tierOverclock() * getMaxPara() * extraPara(100), true); + if (aBaseMetaTileEntity.getStoredEU() + + (2048L * tierOverclock() * getMaxPara() * extraPara(100)) + < maxEUStore() + && tHatch.getBaseMetaTileEntity() + .decreaseS |
