From 7ed516e30ba224b4b8e3fad9c836c22ca00bfcdb Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Fri, 20 Jan 2023 00:30:50 -0800 Subject: MTE Inventory updates (#1496) * MTE Inventory updates * Separate Input/Output inventory * Use a LinkedHashMap to ensure inventory orders are deterministic * Input/Output work on either Input/Output inventories * MTE Inventory * Add GT_Packet_MultiTileEntity * More dyanmic packet with packetFeatures * Add IMTE_HasModes for MultiBlockPart * Help with MTE Inventory (#1613) * convert inventory to use ItemStackHandler * Update MUI * inventories * move Iteminventory to its own method Co-authored-by: miozune * Update MUI * Update MUI * Add IMultiBlockPart * Mte fluid inventory (#1639) * first work on fluid inventory * make gui work with numbers not dividable by 4 * use math.min * add outputfluids saving * actually working * Update MUI Co-authored-by: miozune * Ticking Covers! * Parts now register covers with the controller * Controllers now tick covers on parts * Break cover ticking out into `tickCoverAtSide` Fix some inventory methods on MultiBlockController * Filter on tickable covers * Improve GUIs for MTEs (#1650) * working controller GUI * locked inventory selection work * input and output locking of inventories Co-authored-by: miozune * spotless * CoverInfo refactor (#1654) * Add `CoverInfo` and deprecate the old fields to hold cover information * Disable MTE registration * Fix NPE - Return EMPTY_INFO for SIDE_UNKNOWN Temporarily add back old NBT saving in case of a revert so covers aren't lost. * Actually save the old NBT data, instead of empty Co-authored-by: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> Co-authored-by: miozune --- .../multi/GT_MetaTileEntity_Cleanroom.java | 36 ++++++++++++---------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'src/main/java/gregtech/common/tileentities/machines/multi') 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 0006c8b7d5..5e6651cdad 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,6 @@ package gregtech.common.tileentities.machines.multi; +import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; import static gregtech.api.enums.GT_Values.debugCleanroom; import static gregtech.api.enums.Textures.BlockIcons.*; @@ -45,6 +46,7 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_TooltipMultiB return new GT_MetaTileEntity_Cleanroom(mName); } + @Override protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Cleanroom") @@ -104,7 +106,7 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_TooltipMultiB int mDoorCount = 0; int mHullCount = 0; int mPlascreteCount = 0; - HashMap otherBlocks = new HashMap<>(); + final HashMap otherBlocks = new HashMap<>(); boolean doorState = false; this.mUpdate = 100; @@ -112,8 +114,8 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_TooltipMultiB GT_Log.out.println("Cleanroom: Checking machine"); } for (int i = 1; i < 8; i++) { - Block tBlock = aBaseMetaTileEntity.getBlockOffset(i, 0, 0); - int tMeta = aBaseMetaTileEntity.getMetaIDOffset(i, 0, 0); + final Block tBlock = aBaseMetaTileEntity.getBlockOffset(i, 0, 0); + final int tMeta = aBaseMetaTileEntity.getMetaIDOffset(i, 0, 0); if (tBlock != GregTech_API.sBlockCasings3 || tMeta != 11) { if (tBlock == GregTech_API.sBlockReinforced || tMeta == 2) { x = i; @@ -127,8 +129,8 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_TooltipMultiB } } for (int i = 1; i < 8; i++) { - Block tBlock = aBaseMetaTileEntity.getBlockOffset(0, 0, i); - int tMeta = aBaseMetaTileEntity.getMetaIDOffset(0, 0, i); + final Block tBlock = aBaseMetaTileEntity.getBlockOffset(0, 0, i); + final int tMeta = aBaseMetaTileEntity.getMetaIDOffset(0, 0, i); if (tBlock != GregTech_API.sBlockCasings3 || tMeta != 11) { if (tBlock == GregTech_API.sBlockReinforced || tMeta == 2) { z = i; @@ -145,8 +147,8 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_TooltipMultiB for (int i = -x + 1; i < x; i++) { for (int j = -z + 1; j < z; j++) { if (i == 0 && j == 0) continue; - Block tBlock = aBaseMetaTileEntity.getBlockOffset(j, 0, i); - int tMeta = aBaseMetaTileEntity.getMetaIDOffset(j, 0, i); + final Block tBlock = aBaseMetaTileEntity.getBlockOffset(j, 0, i); + final int tMeta = aBaseMetaTileEntity.getMetaIDOffset(j, 0, i); if (tBlock != GregTech_API.sBlockCasings3 && tMeta != 11) { return false; } @@ -154,8 +156,8 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_TooltipMultiB } for (int i = -1; i > -16; i--) { - Block tBlock = aBaseMetaTileEntity.getBlockOffset(x, i, z); - int tMeta = aBaseMetaTileEntity.getMetaIDOffset(x, i, z); + final Block tBlock = aBaseMetaTileEntity.getBlockOffset(x, i, z); + final int tMeta = aBaseMetaTileEntity.getMetaIDOffset(x, i, z); if (tBlock != GregTech_API.sBlockReinforced || tMeta != 2) { y = i + 1; break; @@ -193,7 +195,7 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_TooltipMultiB } else if (tBlock == GregTech_API.sBlockReinforced && tMeta == 2) { mPlascreteCount++; } else { - IGregTechTileEntity tTileEntity = + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(dX, dY, dZ); if ((!this.addMaintenanceToMachineList(tTileEntity, 210)) && (!this.addEnergyInputToMachineList(tTileEntity, 210))) { @@ -209,7 +211,7 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_TooltipMultiB mDoorCount++; } else { if (tTileEntity != null) { - IMetaTileEntity aMetaTileEntity = tTileEntity.getMetaTileEntity(); + final IMetaTileEntity aMetaTileEntity = tTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) { if (debugCleanroom) { GT_Log.out.println("Cleanroom: Missing block? Not a aMetaTileEntity"); @@ -255,9 +257,9 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_TooltipMultiB return false; } if (mPlascreteCount < 20) return false; - float ratio = (((float) mPlascreteCount) / 100f); + final float ratio = (((float) mPlascreteCount) / 100f); for (Map.Entry e : otherBlocks.entrySet()) { - ConfigEntry ce = config.get(e.getKey()); + final 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; @@ -268,9 +270,9 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_TooltipMultiB if (doorState) { this.mEfficiency = Math.max(0, this.mEfficiency - 200); } - for (byte i = 0; i < 6; i++) { - byte t = (byte) Math.max(1, (byte) (15 / (10000f / this.mEfficiency))); - aBaseMetaTileEntity.setInternalOutputRedstoneSignal(i, t); + for (byte tSide : ALL_VALID_SIDES) { + final byte t = (byte) Math.max(1, (byte) (15 / (10000f / this.mEfficiency))); + aBaseMetaTileEntity.setInternalOutputRedstoneSignal(tSide, t); } this.mHeight = -y; return true; @@ -430,7 +432,7 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_TooltipMultiB 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(); + final String name = cc.get("Name").getString(); if (cc.containsKey("Count")) { if (cc.containsKey("Meta")) config.put( -- cgit