Jump to content

[1.12.2] Manually render fire on entity


Angercraft

Recommended Posts

15 minutes ago, diesieben07 said:

Subscribe to RenderLivingEvent.Post. If you want the entity to render on fire, call Render#renderEntityOnFire on the entity (you'll need reflection).

Appreciate the help, will try it out tomorrow. Thank you very much.

Link to comment
Share on other sites

On 6/24/2019 at 10:18 PM, diesieben07 said:

Subscribe to RenderLivingEvent.Post. If you want the entity to render on fire, call Render#renderEntityOnFire on the entity (you'll need reflection).

Okay I've gotten it to work, thank you very much! Now I don't have much experience with reflection in Java as it is not covered in my university, but I've read about it and would just like to know if this is considered good practice.

 

@SubscribeEvent
    @SideOnly(Side.CLIENT)
    public static void renderEffect(RenderLivingEvent.Post event) {
        if(affected.contains(event.getEntity())) {
            Class c = Render.class;
            try {
                Method method = c.getDeclaredMethod("renderEntityOnFire", Entity.class, double.class, double.class, double.class, float.class);
                method.setAccessible(true);
                method.invoke(event.getRenderer(), event.getEntity(), event.getX(), event.getY(), event.getZ(), event.getPartialRenderTick());
            } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
                System.out.println("Forge was not present, or method name 'renderEntityOnFire' was changed.");
            }
        }
    }

 

I know the exception handling is not proper, but I would like to know if I've handled the reflection properly?

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.