Posted June 24, 20196 yr comment_347896 How would I go about manually rendering the fire effect on an entity? I've tried using Entity#setFire but do not want to damage the entity.
June 24, 20196 yr Author comment_347941 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.
June 26, 20196 yr Author comment_348292 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?
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.