diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2019-04-17 10:35:07 +1000 |
---|---|---|
committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2019-04-17 10:35:07 +1000 |
commit | 95747970ad7d142a2a981119bdfafca5ab5b27d2 (patch) | |
tree | 6e9e581cff710593e6d64205e3b76ad9e9fab836 /src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java | |
parent | f09983f7b7348e89fcc73e865cd11be048e45ba9 (diff) | |
download | GT5-Unofficial-95747970ad7d142a2a981119bdfafca5ab5b27d2.tar.gz GT5-Unofficial-95747970ad7d142a2a981119bdfafca5ab5b27d2.tar.bz2 GT5-Unofficial-95747970ad7d142a2a981119bdfafca5ab5b27d2.zip |
+ Added rmb information to Energy Buffers to show current Amperage.
% Migrated getFieldFromGregtechProxy() from Meta_GT_Proxy.java to StaticFields59.java.
$ Fixed hardness/resistance on a few blocks.
$ Fixed bad handling of Item Entities by Fluid Collectors.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java')
-rw-r--r-- | src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java index 2287d7964c..2a3fd5e77c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java @@ -9,6 +9,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; @@ -18,8 +19,10 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffl import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.common.GT_Proxy; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.reflect.ProxyFinder; import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; @@ -27,7 +30,7 @@ import net.minecraft.item.ItemStack; public class StaticFields59 { - public static final boolean mGT6StylePipes; + public static boolean mGT6StylePipes; public static final Field mGtBlockCasings5; public static final Field mPreventableComponents; @@ -49,8 +52,6 @@ public class StaticFields59 { static { Logger.INFO("[SH] Creating Static Helper for various fields which require reflective access."); - mGT6StylePipes = (boolean) Meta_GT_Proxy.getFieldFromGregtechProxy(false, "gt6Pipe"); - mGtBlockCasings5 = getField(GregTech_API.class, "sBlockCasings5"); Logger.INFO("[SH] Got Field: sBlockCasings5"); mPreventableComponents = getField(OrePrefixes.class, "mPreventableComponents"); @@ -182,5 +183,36 @@ public class StaticFields59 { return null; } + public static Object getFieldFromGregtechProxy(boolean client, String fieldName) { + Object proxyGT; + + if (Meta_GT_Proxy.mProxies[0] != null && client) { + proxyGT = Meta_GT_Proxy.mProxies[0]; + } else if (Meta_GT_Proxy.mProxies[1] != null && !client) { + proxyGT = Meta_GT_Proxy.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 (Meta_GT_Proxy.mProxies[0] == null && client) { + Meta_GT_Proxy.mProxies[0] = (GT_Proxy) proxyGT; + } else if (Meta_GT_Proxy.mProxies[1] == null && !client) { + Meta_GT_Proxy.mProxies[1] = (GT_Proxy) proxyGT; + } + } + + if (proxyGT != null && proxyGT instanceof GT_Proxy) { + try { + return ReflectionUtils.getField(proxyGT.getClass(), fieldName).get(proxyGT); + } catch (IllegalArgumentException | IllegalAccessException e) { + } + } + return null; + } + } |