diff options
author | repo_alt <wvk17@yandex.ru> | 2021-08-11 18:00:18 +0300 |
---|---|---|
committer | repo_alt <wvk17@yandex.ru> | 2021-08-11 18:00:18 +0300 |
commit | c614c62d8277217a377a606d718dd398c1b53f72 (patch) | |
tree | e1d4ccb59948ad40f5ec08755874089bd69e8147 | |
parent | d19bc65f0409179a474f1bf4d07fd3864d840db2 (diff) | |
download | GT5-Unofficial-c614c62d8277217a377a606d718dd398c1b53f72.tar.gz GT5-Unofficial-c614c62d8277217a377a606d718dd398c1b53f72.tar.bz2 GT5-Unofficial-c614c62d8277217a377a606d718dd398c1b53f72.zip |
Optionally disable automation access to the digital chests with storage buses attached
3 files changed, 28 insertions, 1 deletions
diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index 590f01292e..2f26833fb6 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -289,7 +289,7 @@ public class GT_Mod implements IGT_Mod { GT_Values.enableChunkloaders = tMainConfig.get("machines", "enableChunkloaders", true).getBoolean(true); GT_Values.alwaysReloadChunkloaders = tMainConfig.get("machines", "alwaysReloadChunkloaders", false).getBoolean(false); GT_Values.debugChunkloaders = tMainConfig.get("machines", "debugChunkloaders", false).getBoolean(false); - + GT_Values.disableDigitalChestsExternalAccess = tMainConfig.get("machines", "disableDigitalChestsExternalAccess", false).getBoolean(false); GregTech_API.TICKS_FOR_LAG_AVERAGING = tMainConfig.get(aTextGeneral, "TicksForLagAveragingWithScanner", 25).getInt(25); GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING = tMainConfig.get(aTextGeneral, "MillisecondsPassedInGTTileEntityUntilLagWarning", 100).getInt(100); if (tMainConfig.get(aTextGeneral, "disable_STDOUT", false).getBoolean(false)) { diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java index 7152663c42..0c484d05e0 100644 --- a/src/main/java/gregtech/api/enums/GT_Values.java +++ b/src/main/java/gregtech/api/enums/GT_Values.java @@ -302,4 +302,8 @@ public class GT_Values { public static boolean hideAssLineRecipes = false; public static boolean updateFluidDisplayItems = true; public static final int STEAM_PER_WATER = 160; + /** + * If true, then digital chest with AE2 storage bus will be accessible only through AE2 + */ + public static boolean disableDigitalChestsExternalAccess = false; } diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java index 0a426adf35..1bd7ead0d4 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java @@ -2,6 +2,7 @@ package gregtech.common.tileentities.storage; import cpw.mods.fml.common.Optional; import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; @@ -406,6 +407,24 @@ public abstract class GT_MetaTileEntity_DigitalChestBase extends GT_MetaTileEnti }); } + @Optional.Method(modid = "appliedenergistics2") + private boolean hasActiveMEConnection() { + if (listeners == null || listeners.isEmpty()) + return false; + for (Map.Entry<appeng.api.storage.IMEMonitorHandlerReceiver<appeng.api.storage.data.IAEItemStack>, Object> e : listeners.entrySet()) + { + if ((e.getKey() instanceof appeng.api.parts.IPart)) + { + appeng.api.networking.IGridNode n = ((appeng.api.parts.IPart) e.getKey()).getGridNode(); + if (n != null && n.isActive()) + return true; + } + } + // if there are no active storage buses - clear the listeners + listeners = null; + return false; + } + @Override public void saveNBTData(NBTTagCompound aNBT) { aNBT.setInteger("mItemCount", getItemCount()); @@ -426,11 +445,15 @@ public abstract class GT_MetaTileEntity_DigitalChestBase extends GT_MetaTileEnti @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (GregTech_API.mAE2 && GT_Values.disableDigitalChestsExternalAccess && hasActiveMEConnection()) + return false; return aIndex == 1; } @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (GregTech_API.mAE2 && GT_Values.disableDigitalChestsExternalAccess && hasActiveMEConnection()) + return false; return aIndex == 0 && (mInventory[0] == null || GT_Utility.areStacksEqual(mInventory[0], aStack)); } |