|
1 | 1 | package com.glodblock.github.inventory; |
2 | 2 |
|
| 3 | +import appeng.api.AEApi; |
3 | 4 | import appeng.api.config.FuzzyMode; |
4 | 5 | import appeng.api.parts.IPart; |
| 6 | +import appeng.api.storage.IMEMonitor; |
| 7 | +import appeng.api.storage.data.IAEFluidStack; |
| 8 | +import appeng.api.storage.data.IAEItemStack; |
5 | 9 | import appeng.fluids.helper.DualityFluidInterface; |
6 | 10 | import appeng.fluids.helper.IFluidInterfaceHost; |
7 | 11 | import appeng.helpers.DualityInterface; |
|
20 | 24 | import com.glodblock.github.integration.mek.FakeGases; |
21 | 25 | import com.glodblock.github.util.Ae2Reflect; |
22 | 26 | import com.glodblock.github.util.ModAndClassUtil; |
| 27 | +import com.glodblock.github.util.Util; |
| 28 | +import com.mekeng.github.common.me.data.IAEGasStack; |
23 | 29 | import com.mekeng.github.common.me.duality.IGasInterfaceHost; |
| 30 | +import com.mekeng.github.common.me.duality.impl.DualityGasInterface; |
| 31 | +import com.mekeng.github.common.me.storage.IGasStorageChannel; |
24 | 32 | import mekanism.api.gas.GasStack; |
25 | 33 | import mekanism.api.gas.GasTankInfo; |
26 | 34 | import mekanism.api.gas.IGasHandler; |
@@ -364,25 +372,49 @@ public boolean containsItems() { |
364 | 372 | } |
365 | 373 | boolean checkFluid = blockMode != 1; |
366 | 374 | boolean checkItem = blockMode != 2; |
367 | | - if (invFluids != null && checkFluid) { |
| 375 | + |
| 376 | + IFluidInterfaceHost fluidHost = getFluidInterfaceTE((TileEntity) facingTE, facing); |
| 377 | + if (fluidHost != null && !isSameGrid(fluidHost) && checkFluid) { |
| 378 | + DualityFluidInterface inter = fluidHost.getDualityFluidInterface(); |
| 379 | + IMEMonitor<IAEFluidStack> monitor = inter.getInventory(Util.getFluidChannel()); |
| 380 | + if (monitor != null && !monitor.getStorageList().isEmpty()) { |
| 381 | + return true; |
| 382 | + } |
| 383 | + } else if (invFluids != null && checkFluid) { |
368 | 384 | for (IFluidTankProperties tank : invFluids.getTankProperties()) { |
369 | 385 | FluidStack fluid = tank.getContents(); |
370 | 386 | if (fluid != null && fluid.amount > 0) { |
371 | 387 | return true; |
372 | 388 | } |
373 | 389 | } |
374 | 390 | } |
| 391 | + |
375 | 392 | /*yeah, gas is fluid*/ |
376 | | - if (invGases != null && checkFluid) { |
377 | | - IGasHandler gasHandler = (IGasHandler) invGases; |
378 | | - for (GasTankInfo tank : gasHandler.getTankInfo()) { |
379 | | - GasStack gas = tank.getGas(); |
380 | | - if (gas != null && gas.getGas() != null && gas.amount > 0) { |
| 393 | + if (ModAndClassUtil.GAS) { |
| 394 | + Object gasHost = getGasInterfaceTE((TileEntity) facingTE, facing); |
| 395 | + if (gasHost != null && !isSameGrid(((IGasInterfaceHost) gasHost).getProxy()) && checkFluid) { |
| 396 | + DualityGasInterface inter = ((IGasInterfaceHost) gasHost).getDualityGasInterface(); |
| 397 | + IMEMonitor<IAEGasStack> monitor = inter.getInventory(AEApi.instance().storage().getStorageChannel(IGasStorageChannel.class)); |
| 398 | + if (monitor != null && !monitor.getStorageList().isEmpty()) { |
381 | 399 | return true; |
382 | 400 | } |
| 401 | + } else if (invGases != null && checkFluid) { |
| 402 | + IGasHandler gasHandler = (IGasHandler) invGases; |
| 403 | + for (GasTankInfo tank : gasHandler.getTankInfo()) { |
| 404 | + GasStack gas = tank.getGas(); |
| 405 | + if (gas != null && gas.getGas() != null && gas.amount > 0) { |
| 406 | + return true; |
| 407 | + } |
| 408 | + } |
383 | 409 | } |
384 | 410 | } |
385 | | - if (invItems != null && checkItem) { |
| 411 | + |
| 412 | + IInterfaceHost itemHost = getInterfaceTE((TileEntity) facingTE, facing); |
| 413 | + if (itemHost != null && !isSameGrid(itemHost) && checkItem) { |
| 414 | + DualityInterface inter = itemHost.getInterfaceDuality(); |
| 415 | + IMEMonitor<IAEItemStack> monitor = inter.getInventory(Util.getItemChannel()); |
| 416 | + return monitor != null && !monitor.getStorageList().isEmpty(); |
| 417 | + } else if (invItems != null && checkItem) { |
386 | 418 | return invItems.containsItems(); |
387 | 419 | } |
388 | 420 | return false; |
@@ -420,6 +452,19 @@ protected static IFluidInterfaceHost getFluidInterfaceTE(TileEntity te, EnumFaci |
420 | 452 | return null; |
421 | 453 | } |
422 | 454 |
|
| 455 | + @Nullable |
| 456 | + protected static Object getGasInterfaceTE(TileEntity te, EnumFacing face) { |
| 457 | + if (te instanceof IGasInterfaceHost) { |
| 458 | + return te; |
| 459 | + } else if (te instanceof TileCableBus) { |
| 460 | + IPart part = ((TileCableBus) te).getPart(face.getOpposite()); |
| 461 | + if (part instanceof IGasInterfaceHost) { |
| 462 | + return part; |
| 463 | + } |
| 464 | + } |
| 465 | + return null; |
| 466 | + } |
| 467 | + |
423 | 468 | protected static AENetworkProxy getGasInterfaceGrid(@Nullable TileEntity te, EnumFacing face) { |
424 | 469 | if (te instanceof IGasInterfaceHost) { |
425 | 470 | return Ae2Reflect.getGasInterfaceGrid(((IGasInterfaceHost) te).getDualityGasInterface()); |
|
0 commit comments