Generalize ME Interface blocking logic (#531)
This commit is contained in:
@@ -40,6 +40,7 @@ import appeng.api.networking.ticking.IGridTickable;
|
|||||||
import appeng.api.networking.ticking.TickRateModulation;
|
import appeng.api.networking.ticking.TickRateModulation;
|
||||||
import appeng.api.networking.ticking.TickingRequest;
|
import appeng.api.networking.ticking.TickingRequest;
|
||||||
import appeng.api.parts.IPart;
|
import appeng.api.parts.IPart;
|
||||||
|
import appeng.api.parts.IPartHost;
|
||||||
import appeng.api.storage.*;
|
import appeng.api.storage.*;
|
||||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||||
import appeng.api.storage.channels.IItemStorageChannel;
|
import appeng.api.storage.channels.IItemStorageChannel;
|
||||||
@@ -55,6 +56,7 @@ import appeng.core.AELog;
|
|||||||
import appeng.core.settings.TickRates;
|
import appeng.core.settings.TickRates;
|
||||||
import appeng.me.GridAccessException;
|
import appeng.me.GridAccessException;
|
||||||
import appeng.me.helpers.AENetworkProxy;
|
import appeng.me.helpers.AENetworkProxy;
|
||||||
|
import appeng.me.helpers.IGridProxyable;
|
||||||
import appeng.me.helpers.MachineSource;
|
import appeng.me.helpers.MachineSource;
|
||||||
import appeng.me.storage.MEMonitorIInventory;
|
import appeng.me.storage.MEMonitorIInventory;
|
||||||
import appeng.me.storage.MEMonitorPassThrough;
|
import appeng.me.storage.MEMonitorPassThrough;
|
||||||
@@ -961,7 +963,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public appeng.api.util.IConfigManager getConfigManager() {
|
public IConfigManager getConfigManager() {
|
||||||
return this.cm;
|
return this.cm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1024,58 +1026,64 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
|
|
||||||
for (final EnumFacing s : visitedFaces) {
|
for (final EnumFacing s : visitedFaces) {
|
||||||
final TileEntity te = w.getTileEntity(tile.getPos().offset(s));
|
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);
|
visitedFaces.remove(s);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var mon = te.getCapability(Capabilities.STORAGE_MONITORABLE_ACCESSOR, s.getOpposite());
|
||||||
|
if (mon != null) {
|
||||||
|
visitedFaces.remove(s);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IInterfaceHost targetTE;
|
IGridProxyable proxyable;
|
||||||
if (te instanceof IInterfaceHost) {
|
if (te instanceof IGridProxyable) {
|
||||||
targetTE = (IInterfaceHost) te;
|
proxyable = (IGridProxyable) te;
|
||||||
|
} else if (te instanceof IPartHost partHost) {
|
||||||
|
proxyable = (IGridProxyable) partHost.getPart(s.getOpposite());
|
||||||
} else {
|
} else {
|
||||||
targetTE = (IInterfaceHost) ((TileCableBus) te).getPart(s.getOpposite());
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetTE.getInterfaceDuality().sameGrid(this.gridProxy.getGrid())) {
|
if (proxyable.getProxy().getGrid() == this.gridProxy.getGrid()) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
}
|
||||||
IStorageMonitorableAccessor mon = te.getCapability(Capabilities.STORAGE_MONITORABLE_ACCESSOR, s.getOpposite());
|
|
||||||
if (mon != null) {
|
IStorageMonitorable sm = mon.getInventory(this.mySource);
|
||||||
IStorageMonitorable sm = mon.getInventory(this.mySource);
|
if (sm != null && Platform.canAccess(proxyable.getProxy(), this.mySource)) {
|
||||||
if (sm != null && Platform.canAccess(targetTE.getInterfaceDuality().gridProxy, this.mySource)) {
|
if (this.isBlocking() && !sm.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)).getStorageList().isEmpty()) {
|
||||||
if (this.isBlocking() && sm.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)).getStorageList().size() > 0) {
|
continue;
|
||||||
|
} else {
|
||||||
|
IMEMonitor<IAEItemStack> inv = sm.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||||
|
|
||||||
|
var allItemsCanBeInserted = true;
|
||||||
|
for (int x = 0; x < table.getSizeInventory(); x++) {
|
||||||
|
final ItemStack is = table.getStackInSlot(x);
|
||||||
|
if (is.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
}
|
||||||
IMEMonitor<IAEItemStack> inv = sm.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
IAEItemStack result = inv.injectItems(AEItemStack.fromItemStack(is), Actionable.SIMULATE, this.mySource);
|
||||||
|
if (result != null) {
|
||||||
var allItemsCanBeInserted = true;
|
allItemsCanBeInserted = false;
|
||||||
for (int x = 0; x < table.getSizeInventory(); x++) {
|
break;
|
||||||
final ItemStack is = table.getStackInSlot(x);
|
|
||||||
if (is.isEmpty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
IAEItemStack result = inv.injectItems(AEItemStack.fromItemStack(is), Actionable.SIMULATE, this.mySource);
|
|
||||||
if (result != null) {
|
|
||||||
allItemsCanBeInserted = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!allItemsCanBeInserted) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.visitedFaces.clear();
|
|
||||||
for (int x = 0; x < table.getSizeInventory(); x++) {
|
|
||||||
final ItemStack is = table.getStackInSlot(x);
|
|
||||||
if (!is.isEmpty()) {
|
|
||||||
addToSendListFacing(is, s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onPushPatternSuccess(patternDetails);
|
|
||||||
pushItemsOut(s);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!allItemsCanBeInserted) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.visitedFaces.clear();
|
||||||
|
for (int x = 0; x < table.getSizeInventory(); x++) {
|
||||||
|
final ItemStack is = table.getStackInSlot(x);
|
||||||
|
if (!is.isEmpty()) {
|
||||||
|
addToSendListFacing(is, s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onPushPatternSuccess(patternDetails);
|
||||||
|
pushItemsOut(s);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final GridAccessException e) {
|
} catch (final GridAccessException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user