diff --git a/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryAdaptor.java b/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryAdaptor.java index 03d7848d..7ba7ac1b 100644 --- a/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryAdaptor.java +++ b/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryAdaptor.java @@ -201,18 +201,9 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor { p2p = invFluidsP2P.getInput(); checkedInput = true; } - if (p2p == invFluidsP2P || p2p == null) continue; - - try { - Method getTarget = p2p.getClass().getDeclaredMethod("getTarget"); - getTarget.setAccessible(true); - tankInfos.add(((IFluidHandler) getTarget.invoke(p2p)).getTankInfo(p2p.getSide().getOpposite())); - } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { - // skip if we can't read the target - } - + tankInfos.add(Ae2Reflect.getP2PLiquidTarget(p2p).getTankInfo(p2p.getSide().getOpposite())); } } catch (GridAccessException e) { // ignore diff --git a/src/main/java/com/glodblock/github/util/Ae2Reflect.java b/src/main/java/com/glodblock/github/util/Ae2Reflect.java index bbf763b9..185809cd 100644 --- a/src/main/java/com/glodblock/github/util/Ae2Reflect.java +++ b/src/main/java/com/glodblock/github/util/Ae2Reflect.java @@ -13,8 +13,10 @@ import appeng.crafting.MECraftingInventory; import appeng.me.cluster.implementations.CraftingCPUCluster; import appeng.me.storage.MEInventoryHandler; import appeng.me.storage.MEPassThrough; +import appeng.parts.p2p.PartP2PLiquids; import appeng.util.inv.ItemSlot; import appeng.util.prioitylist.IPartitionList; +import net.minecraftforge.fluids.IFluidHandler; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -36,6 +38,7 @@ public class Ae2Reflect { private static final Method mCPU_getGrid; private static final Method mCPU_postChange; private static final Method mCPU_markDirty; + private static final Method mP2PLiquids_getTarget; static { try { @@ -53,6 +56,7 @@ public class Ae2Reflect { mCPU_getGrid = reflectMethod(CraftingCPUCluster.class, "getGrid"); mCPU_postChange = reflectMethod(CraftingCPUCluster.class, "postChange", IAEItemStack.class, BaseActionSource.class); mCPU_markDirty = reflectMethod(CraftingCPUCluster.class, "markDirty"); + mP2PLiquids_getTarget = reflectMethod(PartP2PLiquids.class, "getTarget"); } catch (Exception e) { throw new IllegalStateException("Failed to initialize AE2 reflection hacks!", e); } @@ -172,4 +176,12 @@ public class Ae2Reflect { } } + public static IFluidHandler getP2PLiquidTarget(PartP2PLiquids p2p) { + try { + return (IFluidHandler) mP2PLiquids_getTarget.invoke(p2p); + } catch (Exception e) { + throw new IllegalStateException("Failed to invoke method: " + mP2PLiquids_getTarget, e); + } + } + }