Jump to content

[1.12.2] Render fire in first person


Angercraft

Recommended Posts

I've found the method 

ItemRenderer#renderFireInFirstPerson()

and using reflection I can use it, but the fire is not actually shown on the screen.

 

Should I use a different way to render the fire?

 

This is what I have done so far:

private static Minecraft minecraft = Minecraft.getMinecraft();
private static Method renderFire1st = ObfuscationReflectionHelper.findMethod(minecraft.getItemRenderer().getClass(), "func_78442_d", void.class);

@SubscribeEvent
public static void renderEffect(RenderLivingEvent.Post event) {
    try {
        if (!net.minecraftforge.event.ForgeEventFactory.renderFireOverlay(minecraft.player, event.getPartialRenderTick()))
                renderFire1st.invoke(minecraft.getItemRenderer());
    } catch (IllegalAccessException | InvocationTargetException e) {
            System.out.println("Forge was not present.");
    }
}

 

Thank you in advance!

Link to comment
Share on other sites

Okay, I've tried various things, and the only thing I got to work was the following:

 

private static Minecraft minecraft = Minecraft.getMinecraft();
private static Method renderFire1st = ObfuscationReflectionHelper.findMethod(ItemRenderer.class, "func_78442_d", void.class);

@SubscribeEvent
public static void renderFirstPersonEffect(RenderHandEvent event) {
    if(minecraft.gameSettings.thirdPersonView == 0) {
        if (!net.minecraftforge.event.ForgeEventFactory.renderFireOverlay(minecraft.player, event.getPartialTicks())) {
            try {
                renderFire1st.invoke(minecraft.getItemRenderer());
            } catch (IllegalAccessException | InvocationTargetException e) {
                e.printStackTrace();
            }
        }
    }
}

 

But this seems like a hacky solution, and I would like to know if I should use an alternative way to do this. Maybe another event to subscribe to.

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.