aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common
diff options
context:
space:
mode:
authorMartin Robertz <dream-master@gmx.net>2021-08-11 18:09:54 +0200
committerGitHub <noreply@github.com>2021-08-11 18:09:54 +0200
commit5451998388b35d89d3496ae3e16694983a31f6cb (patch)
tree5a41341ab62be37a0322c421899a6e13afb28929 /src/main/java/gregtech/common
parentd19bc65f0409179a474f1bf4d07fd3864d840db2 (diff)
parent43feab055e075c19df598841ffa0da477b1eecef (diff)
downloadGT5-Unofficial-5451998388b35d89d3496ae3e16694983a31f6cb.tar.gz
GT5-Unofficial-5451998388b35d89d3496ae3e16694983a31f6cb.tar.bz2
GT5-Unofficial-5451998388b35d89d3496ae3e16694983a31f6cb.zip
Merge pull request #636 from repo-alt/experimental
Optionally disable automation access to the digital chests with storage buses attached
Diffstat (limited to 'src/main/java/gregtech/common')
-rw-r--r--src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java23
1 files changed, 23 insertions, 0 deletions
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..7110ed20f9 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.clear();
+ 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));
}