From 8a581938862a4d612f510a8afed88727a34c3916 Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Thu, 15 Dec 2022 16:53:12 +0100 Subject: MODULAR UI (#34) * MODULAR UUUUUUUUIIIIIIIIIII * Tea * Add recipe to ULTIMATE TEA * Stupid MT Scripts. I hate it * Yeet * More TEA * Add blocks * More Modular UIs * Textures * Fix custom UI containers * Texture, tooltip * UI with tabs * ButtonWidget * fix * Fix * Texture * Color is fixed * More UI work * Modular UI is hard dependency now * Spotless * Simplify * Format numbers * A * Update TeaAcceptorTile.java * Shadow is fixed, lets gooooo * hardness * Mixins mixins mixins * Tab icons * Fix crash * Shop concept * Bump ModularUI * Bump Modular UI * Nooooooooooo * GREY -> GRAY * Bump ModularUI * Bump GT5 * EEC with MUI test * Include incomplete structure * REFLECTIONS !! * Just use slot filter * Update pos when needed * Update GT_MetaTileEntity_ExtremeExterminationChamber.java * Spawner status * Nice toggle button * Send messages * Next toggle button * Start work on IAADDS * Scrollable inventory test * Draw queen slots * Fix * Update dependencies.gradle * Use sync widget * Add button to enable/disable working * Configuration in Mega Apiary * Refactor a bit * Update ModularUI * Bump ModularUI * Bump GT5 * Fix build * Update dependencies.gradle * Update build.gradle * Update dependencies.gradle * spotless * Begin working on configuration window * Update dependencies.gradle * Deprecated * Update dependencies.gradle * Optimize bee storage rendering (2 fps -> 100 fps) * Make Mega Apiary storage GUI usable * Configuration window looks ok * Color is fixed * TC research * Disable for now * Finish tea command * ok * Fix * Update en_US.lang * ZzZ * Stuff changed --- .../kubatech/api/helpers/ReflectionHelper.java | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/main/java/kubatech/api/helpers') diff --git a/src/main/java/kubatech/api/helpers/ReflectionHelper.java b/src/main/java/kubatech/api/helpers/ReflectionHelper.java index 1d7449afc4..7b02fe6c82 100644 --- a/src/main/java/kubatech/api/helpers/ReflectionHelper.java +++ b/src/main/java/kubatech/api/helpers/ReflectionHelper.java @@ -45,6 +45,7 @@ public class ReflectionHelper { boolean exceptionDetected = false; Field f = null; do { + exceptionDetected = false; try { f = cl.getDeclaredField(fieldName); f.setAccessible(true); @@ -61,6 +62,38 @@ public class ReflectionHelper { } } + public static boolean setField(Object obj, String fieldName, T value) { + Class cl = obj.getClass(); + String clName = cl.getName(); + HashMap classmap = classes.computeIfAbsent(clName, s -> new _FieldsMethods()).fields; + try { + if (classmap.containsKey(fieldName)) { + Field f = classmap.get(fieldName); + if (f == null) return false; + f.set(obj, value); + return true; + } + boolean exceptionDetected = false; + Field f = null; + do { + exceptionDetected = false; + try { + f = cl.getDeclaredField(fieldName); + f.setAccessible(true); + } catch (Exception ex) { + exceptionDetected = true; + cl = cl.getSuperclass(); + } + } while (exceptionDetected && !cl.equals(Object.class)); + classmap.put(fieldName, f); + if (f == null) return false; + f.set(obj, value); + return true; + } catch (Exception ex) { + return false; + } + } + public static T getField(Object obj, String fieldName) { return getField(obj, fieldName, null); } @@ -87,6 +120,7 @@ public class ReflectionHelper { boolean exceptionDetected = false; Method m = null; do { + exceptionDetected = false; try { m = cl.getDeclaredMethod(methodName, argsTypes); m.setAccessible(true); -- cgit