Generalize ME Interface blocking logic (#531)

This commit is contained in:
Neeve
2025-03-14 15:33:58 +11:00
committed by GitHub
parent f1d9fda6ce
commit d131e12498
@@ -40,6 +40,7 @@ import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHost;
import appeng.api.storage.*;
import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
@@ -55,6 +56,7 @@ import appeng.core.AELog;
import appeng.core.settings.TickRates;
import appeng.me.GridAccessException;
import appeng.me.helpers.AENetworkProxy;
import appeng.me.helpers.IGridProxyable;
import appeng.me.helpers.MachineSource;
import appeng.me.storage.MEMonitorIInventory;
import appeng.me.storage.MEMonitorPassThrough;
@@ -961,7 +963,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
}
@Override
public appeng.api.util.IConfigManager getConfigManager() {
public IConfigManager getConfigManager() {
return this.cm;
}
@@ -1024,24 +1026,32 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
for (final EnumFacing s : visitedFaces) {
final TileEntity te = w.getTileEntity(tile.getPos().offset(s));
if (te instanceof IInterfaceHost || (te instanceof TileCableBus && ((TileCableBus) te).getPart(s.getOpposite()) instanceof PartInterface)) {
if (te == null) {
visitedFaces.remove(s);
try {
IInterfaceHost targetTE;
if (te instanceof IInterfaceHost) {
targetTE = (IInterfaceHost) te;
} else {
targetTE = (IInterfaceHost) ((TileCableBus) te).getPart(s.getOpposite());
continue;
}
if (targetTE.getInterfaceDuality().sameGrid(this.gridProxy.getGrid())) {
continue;
} else {
IStorageMonitorableAccessor mon = te.getCapability(Capabilities.STORAGE_MONITORABLE_ACCESSOR, s.getOpposite());
var mon = te.getCapability(Capabilities.STORAGE_MONITORABLE_ACCESSOR, s.getOpposite());
if (mon != null) {
visitedFaces.remove(s);
try {
IGridProxyable proxyable;
if (te instanceof IGridProxyable) {
proxyable = (IGridProxyable) te;
} else if (te instanceof IPartHost partHost) {
proxyable = (IGridProxyable) partHost.getPart(s.getOpposite());
} else {
continue;
}
if (proxyable.getProxy().getGrid() == this.gridProxy.getGrid()) {
continue;
}
IStorageMonitorable sm = mon.getInventory(this.mySource);
if (sm != null && Platform.canAccess(targetTE.getInterfaceDuality().gridProxy, this.mySource)) {
if (this.isBlocking() && sm.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)).getStorageList().size() > 0) {
if (sm != null && Platform.canAccess(proxyable.getProxy(), this.mySource)) {
if (this.isBlocking() && !sm.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)).getStorageList().isEmpty()) {
continue;
} else {
IMEMonitor<IAEItemStack> inv = sm.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
@@ -1076,8 +1086,6 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
return true;
}
}
}
}
} catch (final GridAccessException e) {
continue;
}