mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 01:54:59 +00:00
move reflection to Ae2Reflect
This commit is contained in:
1 parent
521a256378
commit
e9351c5302
2 files changed
+13
-10
No files matched your search
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user