package net.rustnotmc.client; import net.rustnotmc.loader.Log; /** * Temporary diagnostics, added to work out why jumping and flight misbehave. * * Static analysis kept producing confident and wrong answers about this path, so * the state is measured instead. Delete this file and its patch entry once the * movement bugs are closed. */ public final class RsxDebug { private static int ticks; private RsxDebug() { } /** One-off trace for the empty sound registry. */ public static void sound(String message) { Log.info("DBG snd " + message); } /** Called from EntityPlayerSP.onLivingUpdate, once a second. */ public static void movement(Object self) { if (++ticks % 20 != 0) { return; } Log.info("DBG sp onGround=" + read(self, "onGround") + " inJump=" + read(self, "movementInput") + " isJumping=" + read(self, "isJumping") + " riding=" + read(self, "isRiding") + " srvWorld=" + read(self, "isServerWorld") + " allowFly=" + read(self, "allowFlying") + " flying=" + read(self, "isFlying") + " mY=" + read(self, "motionY") + " y=" + read(self, "posY")); } /** * Reads a field by name. * * Deliberately reflective and deliberately forgiving: a diagnostic that * throws when a field is renamed is worse than one that prints null. */ private static String read(Object target, String field) { if (target == null) { return "?"; } try { java.lang.reflect.Field f = findField(target.getClass(), field); if (f == null) { return "?"; } f.setAccessible(true); return String.valueOf(f.get(target)); } catch (Throwable t) { return "!"; } } private static java.lang.reflect.Field findField(Class type, String name) { while (type != null) { try { return type.getDeclaredField(name); } catch (NoSuchFieldException e) { type = type.getSuperclass(); } } return null; } }