From 5f82584eea96c1ad055448d33316e63c9bd55fb4 Mon Sep 17 00:00:00 2001 From: Moses Miller Date: Fri, 30 Aug 2024 14:15:24 -0700 Subject: Adjust cleanroom block composition check (#2581) Co-authored-by: Martin Robertz Co-authored-by: boubou19 --- .../machines/multi/GT_MetaTileEntity_Cleanroom.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src') 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 b0b9cdd078..93f6db2044 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 @@ -242,6 +242,7 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_TooltipMultiB } return false; } + mPlascreteCount++; } else if (dX != 0 || dZ != 0) { // Top Inner exclude center if (tBlock != GregTech_API.sBlockCasings3 || tMeta != 11) { if (debugCleanroom) { @@ -324,9 +325,14 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_TooltipMultiB } return false; } - final float ratio = (((float) mPlascreteCount) / 100f); + int otherBlockCount = 0; + for (int v : otherBlocks.values()) { + otherBlockCount += v; + } + int maxAllowedRatio = 0; for (Map.Entry e : otherBlocks.entrySet()) { final ConfigEntry ce = config.get(e.getKey()); + maxAllowedRatio += Math.max(maxAllowedRatio, ce.percentage); if (ce.allowedCount > 0) { // count has priority if (e.getValue() > ce.allowedCount) { if (debugCleanroom) { @@ -334,13 +340,19 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_TooltipMultiB } return false; } - } else if (e.getValue() > ratio * ce.percentage) { + } else if ((e.getValue() * 100) / (mPlascreteCount + otherBlockCount) > ce.percentage) { if (debugCleanroom) { GT_Log.out.println("Cleanroom: Relative count too high for a block."); } return false; } } + if ((otherBlockCount * 100) / (mPlascreteCount + otherBlockCount) > maxAllowedRatio) { + if (debugCleanroom) { + GT_Log.out.println("Cleanroom: Relative count of all non-plascrete blocks too high."); + } + return false; + } setCleanroomReceivers(x, y, z, aBaseMetaTileEntity); -- cgit