diff options
author | boubou_19 <miisterunknown@gmail.com> | 2021-09-20 18:25:11 +0200 |
---|---|---|
committer | boubou_19 <miisterunknown@gmail.com> | 2021-09-20 18:25:11 +0200 |
commit | 4f4ba43fa4bda651c277c4bd3852d1c8d80c46ff (patch) | |
tree | 0fcbde81d45f3b3dc65eafd34b487c0ad25a349e /src/main/java/gregtech/common/tileentities | |
parent | 8f5dd5625e4632bbecda0771caad47bbbbd35d4c (diff) | |
parent | 4275142856117665d60a841710e8d9bd75d086ff (diff) | |
download | GT5-Unofficial-4f4ba43fa4bda651c277c4bd3852d1c8d80c46ff.tar.gz GT5-Unofficial-4f4ba43fa4bda651c277c4bd3852d1c8d80c46ff.tar.bz2 GT5-Unofficial-4f4ba43fa4bda651c277c4bd3852d1c8d80c46ff.zip |
Merge remote-tracking branch 'upstream/experimental' into experimental
Diffstat (limited to 'src/main/java/gregtech/common/tileentities')
7 files changed, 197 insertions, 119 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java index 2fa860bb20..64651a3fc4 100644 --- a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java @@ -105,6 +105,7 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta final IGregTechTileEntity gt_tile = getBaseMetaTileEntity(); if (gt_tile == null || !gt_tile.isAllowedToWork() || gt_tile.isClientSide()) return false; World world = gt_tile.getWorld(); + if (world == null) return false; if (mTargetPos == null) { // We don't have a target position, scan the pipes diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java index e9608fce29..0a19536bf1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java @@ -248,6 +248,8 @@ public class GT_MetaTileEntity_AssemblyLine extends GT_MetaTileEntity_EnhancedMu if (!tTag.hasKey("eu")) continue; + if (GT_Values.D1) GT_FML_LOGGER.info("Check overclock"); + calculateOverclockedNessMulti(tTag.getInteger("eu"), tMaxProgressTime, 1, getMaxInputVoltage()); //In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) { @@ -277,8 +279,9 @@ public class GT_MetaTileEntity_AssemblyLine extends GT_MetaTileEntity_EnhancedMu mInputHatches.get(i).mFluid = null; } } - if (GT_Values.D1) GT_FML_LOGGER.info("Check overclock"); + if (this.mEUt > 0) + this.mEUt = -this.mEUt; this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; updateSlots(); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java index e486596fe6..905cb7c2f1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java @@ -1,5 +1,8 @@ package gregtech.common.tileentities.machines.multi; +import java.util.HashMap; +import java.util.Map; + import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.gui.GT_GUIContainer_MultiMachine; @@ -17,15 +20,13 @@ import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.config.ConfigCategory; +import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.input.Keyboard; import static gregtech.api.enums.GT_Values.debugCleanroom; -import static gregtech.api.enums.Textures.BlockIcons.BLOCK_PLASCRETE; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_TOP_CLEANROOM; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_TOP_CLEANROOM_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_TOP_CLEANROOM_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_TOP_CLEANROOM_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.*; public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBase { private int mHeight = -1; @@ -48,10 +49,12 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBas final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Cleanroom") .addInfo("Controller block for the Cleanroom") - .addInfo("Consumes 40 EU/t when first turned on and 4 EU/t once at 100% efficiency when not overclocked")//? + .addInfo("Consumes 40 EU/t when first turned on") + .addInfo("and 4 EU/t once at 100% efficiency when not overclocked")//? .addInfo("An energy hatch accepts up to 2A, so you can use 2A LV or 1A MV") .addInfo("2 LV batteries + 1 LV generator or 1 MV generator")//? - .addInfo("Time required to reach full efficiency is propotional to the height of empty space within") + .addInfo("Time required to reach full efficiency is proportional to") + .addInfo("the height of empty space within") .addInfo("Make sure your Energy Hatch matches! ?") .addSeparator() .beginVariableStructureBlock(3, 15, 4, 15, 3, 15, true) @@ -91,7 +94,7 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBas int mDoorCount = 0; int mHullCount = 0; int mPlascreteCount = 0; - int mGlassCount = 0; + HashMap<String, Integer> otherBlocks = new HashMap<>(); boolean doorState = false; this.mUpdate = 100; @@ -186,8 +189,6 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBas } } else if (tBlock == GregTech_API.sBlockReinforced && tMeta == 2) { mPlascreteCount++; - } else if (tBlock != null && tBlock.getUnlocalizedName().equals("blockAlloyGlass")) { - ++mGlassCount; } else { IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(dX, dY, dZ); if ((!this.addMaintenanceToMachineList(tTileEntity, 210)) && (!this.addEnergyInputToMachineList(tTileEntity, 210))) { @@ -202,32 +203,44 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBas } mDoorCount++; } else { - if (tTileEntity == null) { - if (debugCleanroom) { - GT_Log.out.println( - "Cleanroom: Missing block? Not a tTileEntity" - ); - } - return false; - } - IMetaTileEntity aMetaTileEntity = tTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - if (debugCleanroom) { - GT_Log.out.println( + if (tTileEntity != null) { + IMetaTileEntity aMetaTileEntity = tTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + if (debugCleanroom) { + GT_Log.out.println( "Cleanroom: Missing block? Not a aMetaTileEntity" - ); + ); + } + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_BasicHull) { + mHullCount++; + } + else { + if (debugCleanroom) { + GT_Log.out.println( + "Cleanroom: Incorrect GT block? " + tBlock.getUnlocalizedName() + ); + } + return false; } - return false; } - if (aMetaTileEntity instanceof GT_MetaTileEntity_BasicHull) { - mHullCount++; - } else { - if (debugCleanroom) { - GT_Log.out.println( - "Cleanroom: Incorrect block?" - ); + else { + String key = tBlock.getUnlocalizedName() + ":"+ tMeta; + if (config.containsKey(key)) { // check with meta first + otherBlocks.compute(key, (k, v) -> v == null ? 1 : v + 1); + } + else { + key = tBlock.getUnlocalizedName(); + if (config.containsKey(key)) { + otherBlocks.compute(key, (k, v) -> v == null ? 1 : v + 1); + } + else { + if (debugCleanroom) + GT_Log.out.println("Cleanroom: not allowed block " + tBlock.getUnlocalizedName()); + return false; + } } - return false; } } } @@ -236,9 +249,20 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBas } } } - if (this.mMaintenanceHatches.size() != 1 || this.mEnergyHatches.size() != 1 || mDoorCount != 2 || mHullCount > 10) { + if (this.mMaintenanceHatches.size() != 1 || this.mEnergyHatches.size() != 1 || mDoorCount > 2 || mHullCount > 10) { return false; } + if (mPlascreteCount < 20) + return false; + float ratio = (((float) mPlascreteCount) / 100f); + for (Map.Entry<String, Integer> e : otherBlocks.entrySet()) { + ConfigEntry ce = config.get(e.getKey()); + if (ce.allowedCount > 0) { // count has priority + if (e.getValue() > ce.allowedCount) + return false; + } else if (e.getValue() > ratio * ce.percentage) + return false; + } setCallbacks(x, y, z, aBaseMetaTileEntity); @@ -249,12 +273,8 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBas byte t = (byte) Math.max(1, (byte) (15 / (10000f / this.mEfficiency))); aBaseMetaTileEntity.setInternalOutputRedstoneSignal(i, t); } - - float ratio = (((float) mPlascreteCount) / 100f) * GT_Values.cleanroomGlass; - this.mHeight = -y; - - return mPlascreteCount >= 20 && mGlassCount < (int) Math.floor(ratio); + return true; } private void setCallbacks(int x, int y, int z, IGregTechTileEntity aBaseMetaTileEntity) { @@ -344,4 +364,55 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBas public boolean explodesOnComponentBreak(ItemStack aStack) { return false; } + + private static class ConfigEntry { + int percentage; + int allowedCount; + int meta; + ConfigEntry(int percentage, int count, int meta) { + this.percentage = percentage; + this.allowedCount = count; + this.meta = meta; + } + } + private final static HashMap<String, ConfigEntry> config = new HashMap<>(); + + private static final String category = "cleanroom_allowed_blocks"; + private static final int wildcard_meta = Short.MAX_VALUE; + + private static void setDefaultConfigValues(Configuration cfg) { + cfg.get("cleanroom_allowed_blocks.reinforced_glass", "Name","blockAlloyGlass"); + cfg.get("cleanroom_allowed_blocks.reinforced_glass", "Percentage",5); + cfg.get("cleanroom_allowed_blocks.bw_reinforced_glass_0", "Name","BW_GlasBlocks"); + cfg.get("cleanroom_allowed_blocks.bw_reinforced_glass_0", "Percentage",50); + cfg.get("cleanroom_allowed_blocks.bw_reinforced_glass_0", "Meta",0); + cfg.get("cleanroom_allowed_blocks.bw_reinforced_glass", "Name","BW_GlasBlocks"); + cfg.get("cleanroom_allowed_blocks.bw_reinforced_glass", "Percentage",100); + cfg.get("cleanroom_allowed_blocks.elevator", "Name","tile.openblocks.elevator"); + cfg.get("cleanroom_allowed_blocks.elevator", "Count",1); + cfg.get("cleanroom_allowed_blocks.travel_anchor", "Name","tile.blockTravelAnchor"); + cfg.get("cleanroom_allowed_blocks.travel_anchor", "Count",1); + cfg.get("cleanroom_allowed_blocks.warded_glass", "Name","tile.blockCosmeticOpaque"); + cfg.get("cleanroom_allowed_blocks.warded_glass", "Meta",2); + cfg.get("cleanroom_allowed_blocks.warded_glass", "Percentage",50); + } + public static void loadConfig(Configuration cfg) { + if (!cfg.hasCategory(category)) + setDefaultConfigValues(cfg); + for (ConfigCategory cc : cfg.getCategory(category).getChildren()) { + String name = cc.get("Name").getString(); + if (cc.containsKey("Count")) { + if (cc.containsKey("Meta")) + config.put(name+":"+cc.get("Meta").getInt(), new ConfigEntry(0, cc.get("Count").getInt(), cc.get("Meta").getInt())); + else + config.put(name, new ConfigEntry(0, cc.get("Count").getInt(), wildcard_meta)); + } + else if (cc.containsKey("Percentage")) { + if (cc.containsKey("Meta")) + config.put(name+":"+cc.get("Meta").getInt(), new ConfigEntry(cc.get("Percentage").getInt(), 0, cc.get("Meta").getInt())); + else + config.put(name, new ConfigEntry(cc.get("Percentage").getInt(), 0, wildcard_meta)); + } + } + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java index ca6495ea65..3536030fe0 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java @@ -353,49 +353,44 @@ public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity if (this.mEUStore <= 0 && mMaxProgresstime > 0) { stopMachine(); } - if (getRepairStatus() > 0) { - if (mMaxProgresstime > 0 && doRandomMaintenanceDamage()) { - this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mEUt, true); - if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { - if (mOutputItems != null) - for (ItemStack tStack : mOutputItems) if (tStack != null) addOutput(tStack); - if (mOutputFluids != null) - for (FluidStack tStack : mOutputFluids) if (tStack != null) addOutput(tStack); - mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); - mOutputItems = null; - mProgresstime = 0; - mMaxProgresstime = 0; - mEfficiencyIncrease = 0; - if (mOutputFluids != null && mOutputFluids.length > 0) { - try { - GT_Mod.achievements.issueAchivementHatchFluid(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), mOutputFluids[0]); - } catch (Exception ignored) { - } + if (mMaxProgresstime > 0) { + this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mEUt, true); + if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { + if (mOutputItems != null) + for (ItemStack tStack : mOutputItems) if (tStack != null) addOutput(tStack); + if (mOutputFluids != null) + for (FluidStack tStack : mOutputFluids) if (tStack != null) addOutput(tStack); + mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]))); + mOutputItems = null; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + if (mOutputFluids != null && mOutputFluids.length > 0) { + try { + GT_Mod.achievements.issueAchivementHatchFluid(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), mOutputFluids[0]); + } catch (Exception ignored) { } - this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); - if (aBaseMetaTileEntity.isAllowedToWork()) - checkRecipe(mInventory[1]); } - } else { - if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified()) { - turnCasingActive(mMaxProgresstime > 0); - if (aBaseMetaTileEntity.isAllowedToWork()) { - this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); - if (checkRecipe(mInventory[1])) { - if (this.mEUStore < this.mLastRecipe.mSpecialValue - this.mEUt) { - mMaxProgresstime = 0; - turnCasingActive(false); - } - aBaseMetaTileEntity.decreaseStoredEnergyUnits(this.mLastRecipe.mSpecialValue - this.mEUt, true); + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + if (aBaseMetaTileEntity.isAllowedToWork()) + checkRecipe(mInventory[1]); + } + } else { + if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified()) { + turnCasingActive(mMaxProgresstime > 0); + if (aBaseMetaTileEntity.isAllowedToWork()) { + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + if (checkRecipe(mInventory[1])) { + if (this.mEUStore < this.mLastRecipe.mSpecialValue - this.mEUt) { + mMaxProgresstime = 0; + turnCasingActive(false); } + aBaseMetaTileEntity.decreaseStoredEnergyUnits(this.mLastRecipe.mSpecialValue - this.mEUt, true); } - if (mMaxProgresstime <= 0) - mEfficiency = Math.max(0, mEfficiency - 1000); } + if (mMaxProgresstime <= 0) + mEfficiency = Math.max(0, mEfficiency - 1000); } - } else { - this.mLastRecipe = null; - stopMachine(); } } else { turnCasingActive(false); @@ -403,8 +398,7 @@ public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity stopMachine(); } } - aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & ~127) | (mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8) - | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64)); + aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & ~127) | (mMachine ? 0 : 64)); aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java index a90e1948d0..b9ade288c1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java @@ -20,6 +20,7 @@ import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; @@ -126,7 +127,7 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult @Override public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sCrakingRecipes; + return GT_Recipe.GT_Recipe_Map.sCrackingRecipes; } @Override @@ -140,7 +141,7 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], - tFluidInputs , + tFluidInputs, mInventory[1] ); @@ -327,14 +328,15 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { tHatch.mRecipeMap = getRecipeMap(); if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) { - rList.add(tHatch.getFillableStack()); + if (!GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tHatch.getFillableStack())) + rList.add(tHatch.getFillableStack()); } } for (GT_MetaTileEntity_Hatch_Input tHatch : mMiddleInputHatches) { tHatch.mRecipeMap = getRecipeMap(); if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) { FluidStack tStack = tHatch.getFillableStack(); - if (tStack.isFluidEqual(GT_ModHandler.getSteam(1000)) || tStack.isFluidEqual(Materials.Hydrogen.getGas(1000))) { + if (GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tStack)) { rList.add(tStack); } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java index 26cccb7819..ad0f5bd7f8 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java @@ -12,6 +12,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_CubicMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; @@ -26,12 +27,11 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.ArrayUtils; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import java.util.Objects; +import java.util.stream.Stream; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static gregtech.api.enums.GT_Values.VN; @@ -43,10 +43,12 @@ import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Basi public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_CubicMultiBlockBase<GT_MetaTileEntity_ProcessingArray> { + private GT_Recipe_Map mLastRecipeMap; private GT_Recipe mLastRecipe; private int tTier = 0; private int mMult = 0; private boolean mSeparate = false; + private String mMachineName = ""; public GT_MetaTileEntity_ProcessingArray(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -67,7 +69,7 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_CubicMu tt.addMachineType("Processing Array") .addInfo("Runs supplied machines as if placed in the world") .addInfo("Place up to 64 singleblock GT machines into the controller") - .addInfo("Note that tou still need to supply power to them all") + .addInfo("Note that you still need to supply power to them all") .addInfo("Use a screwdriver to enable separate input busses") .addInfo("Maximal overclockedness of machines inside: Tier 9") .addInfo("Doesn't work on certain machines, deal with it") @@ -142,8 +144,6 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_CubicMu return aStack != null && aStack.getUnlocalizedName().startsWith("gt.blockmachines.basicmachine."); } - private String mMachine = ""; - @Override public boolean checkRecipe(ItemStack aStack) { if (!isCorrectMachinePart(mInventory[1])) { @@ -152,18 +152,18 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_CubicMu GT_Recipe.GT_Recipe_Map map = getRecipeMap(); if (map == null) return false; - if (!mMachine.equals(mInventory[1].getUnlocalizedName())) { + if (!mMachineName.equals(mInventory[1].getUnlocalizedName())) { mLastRecipe = null; - mMachine = mInventory[1].getUnlocalizedName(); + mMachineName = mInventory[1].getUnlocalizedName(); } int machineTier = 0; if (mLastRecipe == null) { try { - int length = mMachine.length(); + int length = mMachineName.length(); - machineTier = Integer.parseInt(mMachine.substring(length - 2)); + machineTier = Integer.parseInt(mMachineName.substring(length - 2)); } catch (NumberFormatException ignored) { /* do nothing */ @@ -285,37 +285,43 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_CubicMu int tSize = tFOut.amount; tFOut.amount = tSize * i; } - tOut = clean(tOut); this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - List<ItemStack> overStacks = new ArrayList<>(); - for (ItemStack itemStack : tOut) { - while (itemStack != null && itemStack.getMaxStackSize() < itemStack.stackSize) { - ItemStack tmp = itemStack.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - itemStack.stackSize = itemStack.stackSize - itemStack.getMaxStackSize(); - overStacks.add(tmp); - } - } - if (!overStacks.isEmpty()) { - ItemStack[] tmp = new ItemStack[overStacks.size()]; - tmp = overStacks.toArray(tmp); - tOut = ArrayUtils.addAll(tOut, tmp); - } - List<ItemStack> tSList = new ArrayList<>(); - for (ItemStack tS : tOut) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOut = tSList.toArray(new ItemStack[0]); - this.mOutputItems = tOut; + this.mOutputItems = Arrays.stream(tOut) + .filter(Objects::nonNull) + .flatMap(GT_MetaTileEntity_ProcessingArray::splitOversizedStack) + .filter(is -> is.stackSize > 0) + .toArray(ItemStack[]::new); this.mOutputFluids = new FluidStack[]{tFOut}; updateSlots(); return true; } - public static ItemStack[] clean(final ItemStack[] v) { - List<ItemStack> list = new ArrayList<>(Arrays.asList(v)); - list.removeAll(Collections.singleton(null)); - return list.toArray(new ItemStack[0]); + private static Stream<ItemStack> splitOversizedStack(ItemStack aStack) { + int tMaxStackSize = aStack.getMaxStackSize(); + if (aStack.stackSize <= tMaxStackSize) return Stream.of(aStack); + int tRepeat = aStack.stackSize / tMaxStackSize; + aStack.stackSize = aStack.stackSize % tMaxStackSize; + Stream.Builder<ItemStack> tBuilder = Stream.builder(); + tBuilder.add(aStack); + for (int i = 0; i < tRepeat; i++) { + ItemStack rStack = aStack.copy(); + rStack.stackSize = tMaxStackSize; + tBuilder.add(rStack); + } + return tBuilder.build(); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (mMachine && aTick % 20 == 0) { + GT_Recipe_Map tCurrentMap = getRecipeMap(); + if (tCurrentMap != mLastRecipeMap) { + for (GT_MetaTileEntity_Hatch_InputBus tInputBus : mInputBusses) tInputBus.mRecipeMap = tCurrentMap; + for (GT_MetaTileEntity_Hatch_Input tInputHatch : mInputHatches) tInputHatch.mRecipeMap = tCurrentMap; + mLastRecipeMap = tCurrentMap; + } + } } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java index 48da2c5dce..ae96b82a23 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java @@ -27,6 +27,7 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockUn import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_Values.MOD_ID_DC; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE_GLOW; @@ -43,8 +44,8 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_EnhancedMu private static IStructureDefinition<GT_MetaTileEntity_PyrolyseOven> createStructureDefinition() { IStructureElement<GT_MetaTileEntity_PyrolyseOven> tCasingElement = - Loader.isModLoaded("dreamcraft") ? - ofBlockUnlocalizedName("dreamcraft", "gt.blockcasingsNH", 2) : + Loader.isModLoaded(MOD_ID_DC) ? + ofBlockUnlocalizedName(MOD_ID_DC, "gt.blockcasingsNH", 2) : ofBlock(GregTech_API.sBlockCasings1, 0); return StructureDefinition.<GT_MetaTileEntity_PyrolyseOven>builder() |