Jump to content

[1.15.2] How to apply patches to vanilla classes using reflection


lisilew

Recommended Posts

I am trying to modify a method in FirstPersonRenderer.

Since it is not declared as a field in many classes, I chose to use reflection rather than coremod.

I have a method shown below in my class that extends FirstPersonRenderer.

public static void patch() {
    FirstPersonRenderer instance = new FirstPersonRenderer(Minecraft.getInstance());
    ObfuscationReflectionHelper.setPrivateValue(Minecraft.class, Minecraft.getInstance(), instance, "field_175620_Y");
    ObfuscationReflectionHelper.setPrivateValue(GameRenderer.class, Minecraft.getInstance().gameRenderer, instance, "field_78516_c");
    ObfuscationReflectionHelper.setPrivateValue(GameRenderer.class, ObfuscationReflectionHelper.getPrivateValue(LightTexture.class, Minecraft.getInstance().gameRenderer.getLightTexture(), "field_205116_g"), instance, "field_78516_c");
}

Is it correct that I cannot call this method in main class when FMLClientSetupEvent is fired as it accesses client only classes?

If so, how can I apply these patches correctly?

Link to comment
Share on other sites

5 hours ago, _Cruelar_ said:

Just add a propertyOverride to your Item and change the position that way

I also have considered that but I wanted to use exact values that were used before 1.9 and I do not know how should I change those values to fit in JSON.

Link to comment
Share on other sites

Maybe try looking at shield_blocking.json or try applying the patches in your ClientProxy which should be Client-only, however note that any change to these should also be done in Client-only classes/methods

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

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.