Jump to content

[1.15.2] Possible to get FPS integer ?


ChAoS_UnItY

Recommended Posts

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?

Link to comment
Share on other sites

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."

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.