aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/util/reflect
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2018-09-12 22:12:00 +1000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2018-09-12 22:12:00 +1000
commitfc3d445a23d8e6b4a6f87d7a9aeea3c8315aa9b6 (patch)
tree62a50989e8a5c08c9880dd3eb86c82d5e128d6a6 /src/Java/gtPlusPlus/core/util/reflect
parented64f971b4298b186f2486dc553c9fab955d36b4 (diff)
downloadGT5-Unofficial-fc3d445a23d8e6b4a6f87d7a9aeea3c8315aa9b6.tar.gz
GT5-Unofficial-fc3d445a23d8e6b4a6f87d7a9aeea3c8315aa9b6.tar.bz2
GT5-Unofficial-fc3d445a23d8e6b4a6f87d7a9aeea3c8315aa9b6.zip
+ Added Advanced Mufflers.
+ Added custom overlay textures for new mufflers. % Logging changes. $ Fixed generation of recipes for pocket fusion.
Diffstat (limited to 'src/Java/gtPlusPlus/core/util/reflect')
-rw-r--r--src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java55
-rw-r--r--src/Java/gtPlusPlus/core/util/reflect/ServerProxyFinder.java32
2 files changed, 55 insertions, 32 deletions
diff --git a/src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java b/src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java
new file mode 100644
index 0000000000..85599e4695
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java
@@ -0,0 +1,55 @@
+package gtPlusPlus.core.util.reflect;
+
+import java.lang.reflect.Field;
+
+import cpw.mods.fml.common.SidedProxy;
+
+public class ProxyFinder {
+
+ public static Object getServerProxy(final Object modInstance) throws ReflectiveOperationException {
+ for(final Field field : modInstance.getClass().getDeclaredFields()) {
+ if(field.isAnnotationPresent(SidedProxy.class)) {
+ final SidedProxy sidedProxy = field.getAnnotation(SidedProxy.class);
+ final Object fieldValue = field.get(modInstance);
+ try {
+ final Class<?> serverSideClass = Class.forName(sidedProxy.serverSide());
+ if(serverSideClass.isAssignableFrom(fieldValue.getClass())) {
+ final Object serverProxy = serverSideClass.cast(fieldValue);
+ //do what you want with server proxy instance
+ return serverProxy;
+ }
+
+ } catch (final NoClassDefFoundError err) {
+ //its server side
+ return null;
+ }
+ break;
+ }
+ }
+ return null;
+ }
+
+ public static Object getClientProxy(final Object modInstance) throws ReflectiveOperationException {
+ for(final Field field : modInstance.getClass().getDeclaredFields()) {
+ if(field.isAnnotationPresent(SidedProxy.class)) {
+ final SidedProxy sidedProxy = field.getAnnotation(SidedProxy.class);
+ final Object fieldValue = field.get(modInstance);
+ try {
+ final Class<?> clientSideClass = Class.forName(sidedProxy.clientSide());
+ if(clientSideClass.isAssignableFrom(fieldValue.getClass())) {
+ final Object clientProxy = clientSideClass.cast(fieldValue);
+ //do what you want with client proxy instance
+ return clientProxy;
+ }
+
+ } catch (final NoClassDefFoundError err) {
+ //its server side
+ return null;
+ }
+ break;
+ }
+ }
+ return null;
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/util/reflect/ServerProxyFinder.java b/src/Java/gtPlusPlus/core/util/reflect/ServerProxyFinder.java
deleted file mode 100644
index 38382b4a46..0000000000
--- a/src/Java/gtPlusPlus/core/util/reflect/ServerProxyFinder.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package gtPlusPlus.core.util.reflect;
-
-import java.lang.reflect.Field;
-
-import cpw.mods.fml.common.SidedProxy;
-
-public class ServerProxyFinder {
-
- public static Object getInstance(final Object modInstance) throws ReflectiveOperationException {
- for(final Field field : modInstance.getClass().getDeclaredFields()) {
- if(field.isAnnotationPresent(SidedProxy.class)) {
- final SidedProxy sidedProxy = field.getAnnotation(SidedProxy.class);
- final Object fieldValue = field.get(modInstance);
- try {
- final Class<?> serverSideClass = Class.forName(sidedProxy.serverSide());
- if(serverSideClass.isAssignableFrom(fieldValue.getClass())) {
- final Object serverProxy = serverSideClass.cast(fieldValue);
- //do what you want with server proxy instance
- return serverProxy;
- }
-
- } catch (final NoClassDefFoundError err) {
- //its server side
- return null;
- }
- break;
- }
- }
- return null;
- }
-
-} \ No newline at end of file