aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2018-09-13 13:27:29 +1000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2018-09-13 13:27:29 +1000
commit84cce1bba9a1091f2428ebee464cbfdf57491def (patch)
tree5ca4ad0dcee8538c29aab947ef9d0f964d24a6ba /src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java
parent7fd2ec38b8d09ef465affb78c5e1c8a32ca7ba3b (diff)
downloadGT5-Unofficial-84cce1bba9a1091f2428ebee464cbfdf57491def.tar.gz
GT5-Unofficial-84cce1bba9a1091f2428ebee464cbfdf57491def.tar.bz2
GT5-Unofficial-84cce1bba9a1091f2428ebee464cbfdf57491def.zip
+ Added some Average functions to MathUtils.java.
+ Added a Proxy Grabber function to Meta_GT_Proxy.java. % Tweaked fuel values for Coal Gas & Coal Tar. $ Fixed issue with Semifluid Fuel generation where none were excluded. - Removed Logging from material Generation.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java41
1 files changed, 39 insertions, 2 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java
index 4c9e6c129c..6881c900b5 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java
@@ -2,6 +2,7 @@ package gtPlusPlus.xmod.gregtech.common;
import static gtPlusPlus.xmod.gregtech.common.covers.GTPP_Cover_Overflow.mOverflowCache;
+import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -12,11 +13,13 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
-
+import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
-
+import gregtech.common.GT_Proxy;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.api.objects.data.ObjMap;
+import gtPlusPlus.core.util.reflect.ProxyFinder;
+import gtPlusPlus.core.util.reflect.ReflectionUtils;
public class Meta_GT_Proxy {
@@ -82,5 +85,39 @@ public class Meta_GT_Proxy {
}
return aRemoved;
}
+
+
+ private static GT_Proxy[] mProxies = new GT_Proxy[2];
+
+ public static Object getFieldFromGregtechProxy(boolean client, String fieldName) {
+ Object proxyGT;
+
+ if (mProxies[0] != null && client) {
+ proxyGT = mProxies[0];
+ } else if (mProxies[1] != null && !client) {
+ proxyGT = mProxies[1];
+ } else {
+ try {
+ proxyGT = (client ? ProxyFinder.getClientProxy(GT_Mod.instance)
+ : ProxyFinder.getServerProxy(GT_Mod.instance));
+ } catch (final ReflectiveOperationException e1) {
+ proxyGT = null;
+ Logger.INFO("Failed to obtain instance of GT " + (client ? "Client" : "Server") + " proxy.");
+ }
+ if (mProxies[0] == null && client) {
+ mProxies[0] = (GT_Proxy) proxyGT;
+ } else if (mProxies[1] == null && !client) {
+ mProxies[1] = (GT_Proxy) proxyGT;
+ }
+ }
+
+ if (proxyGT != null && proxyGT instanceof GT_Proxy) {
+ try {
+ return ReflectionUtils.getField(proxyGT.getClass(), fieldName).get(proxyGT);
+ } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {
+ }
+ }
+ return null;
+ }
}