Posted June 25, 20205 yr I've tried to use Reflection to get the "debugFPS" field like below : int fps = 0; try { Field field = mc.getClass().getDeclaredField("debugFPS"); field.setAccessible(true); fps = (int) field.get(mc); } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); } but it only works on dev one, not working on compiled one. Anything I did not noticed?
June 25, 20205 yr Author Ok, my exception part is fixed, but after a further discover, I don't know what the "E" in the code below should be....... @Nullable public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, String fieldName) { try { return (T) findField(classToAccess, fieldName).get(instance); } catch (UnableToFindFieldException e) { LOGGER.error(REFLECTION,"Unable to locate field {} ({}) on type {}", fieldName, remapName(INameMappingService.Domain.FIELD, fieldName), classToAccess.getName(), e); throw e; } catch (IllegalAccessException e) { LOGGER.error(REFLECTION,"Unable to access field {} ({}) on type {}", fieldName, remapName(INameMappingService.Domain.FIELD, fieldName), classToAccess.getName(), e); throw new UnableToAccessFieldException(e); } } It says "The type of the classToAccess."
June 25, 20205 yr Author After a compiled run, it says no such field, how can I get the field I want? (note: the field calls "debugFPS")
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.