Fix AEFluidInterfaceHandler to correctly work with Fluid P2P and Dual Interface (#477)

This commit is contained in:
Riever authored and GitHub committed 2026-10-31 21:33:32 +00:00
1 parent 358c238e17
commit c0ba18417d
1 file changed
+17 -9
@@ -5,8 +5,11 @@ import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.implementations.tiles.ITileStorageMonitorable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHost;
import appeng.api.storage.IExternalStorageHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.StorageChannel;
import appeng.util.Platform;
@@ -16,8 +19,8 @@ public class AEFluidInterfaceHandler implements IExternalStorageHandler {
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource mySrc) {
if (channel == StorageChannel.FLUIDS) {
if (te instanceof ITileStorageMonitorable) {
return true;
} else return Platform.getPartFromTE(te, d.getOpposite()) instanceof ITileStorageMonitorable;
return !(te instanceof IPartHost);
} else return getMonitorablePart(te, d, mySrc) != null;
}
return false;
}
@@ -26,14 +29,19 @@ public class AEFluidInterfaceHandler implements IExternalStorageHandler {
@SuppressWarnings("rawtypes")
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource src) {
if (channel == StorageChannel.FLUIDS) {
if (te instanceof ITileStorageMonitorable
&& ((ITileStorageMonitorable) te).getMonitorable(d, src) != null) {
return ((ITileStorageMonitorable) te).getMonitorable(d, src).getFluidInventory();
} else if (Platform.getPartFromTE(te, d.getOpposite()) instanceof ITileStorageMonitorable part
&& part.getMonitorable(d, src) != null) {
return part.getMonitorable(d, src).getFluidInventory();
}
if (te instanceof ITileStorageMonitorable tsm) {
final IStorageMonitorable monitorable = tsm.getMonitorable(d, src);
return monitorable != null ? monitorable.getFluidInventory() : null;
} else {
final IStorageMonitorable monitorable = getMonitorablePart(te, d, src);
return monitorable != null ? monitorable.getFluidInventory() : null;
}
}
return null;
}
private static IStorageMonitorable getMonitorablePart(TileEntity te, ForgeDirection d, BaseActionSource src) {
final IPart part = Platform.getPartFromTE(te, d);
return part instanceof ITileStorageMonitorable monitorablePart ? monitorablePart.getMonitorable(d, src) : null;
}
}