Posted May 11, 20196 yr ok i wanted to make a renderlayer (on the player) that renders a model / entity on the player ... i have done all of this but the renderlayer causes Frame drops over time .... after like 1 minute of looking on anything that renders on it the fps are 0-4 fps here a screen of the Lag o Meter of minecraft when i am in thirdperson: ^^ Slowly going up and getting Frame drops ^^ here is the relevant code(i am using a parrot as placeholder just to test): My Render Layer Class: @SideOnly(Side.CLIENT) public class LayerEntityOnPlayerBack implements LayerRenderer<EntityLivingBase>{ private final RenderManager renderManager; protected RenderLivingBase <? extends EntityLivingBase > Renderer; private ModelBase Model = new ModelParrot(); private ResourceLocation Resource = RenderParrot.PARROT_TEXTURES[2]; public LayerEntityOnPlayerBack(RenderManager rendermanager) { this.renderManager = rendermanager; } public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { if (entitylivingbaseIn.getCapability(ModelProvider.MODEL_CAP, null).getModelID() != 0) { GlStateManager.enableRescaleNormal(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); if (entitylivingbaseIn.getCapability(ModelProvider.MODEL_CAP, null).getModelID() == 1) { if(Renderer == null) Renderer = new RenderParrot(this.renderManager); Renderer.bindTexture(Resource); GlStateManager.pushMatrix(); float f = entitylivingbaseIn.isSneaking() ? -1.3F : -1.5F; GlStateManager.translate(0.0F, f, 0.0F); ageInTicks = 0.0F; Model.setLivingAnimations(entitylivingbaseIn, limbSwing, limbSwingAmount, partialTicks); Model.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entitylivingbaseIn); Model.render(entitylivingbaseIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); GlStateManager.popMatrix(); } GlStateManager.disableRescaleNormal(); } } public boolean shouldCombineTextures() { return false; } } RenderPlayerEvent.Pre: @SubscribeEvent public void RenderPlayerEvent(RenderPlayerEvent.Pre event) { LayerEntityOnPlayerBack layer = new LayerEntityOnPlayerBack(event.getRenderer().getRenderManager()); event.getRenderer().addLayer(layer); }
May 11, 20196 yr Well, since RenderPlayerEvent fires every time the player is rendered(aka every frame) you are adding a new layer each frame...
May 11, 20196 yr Author Thanks!... ofc it would ... actually.. which event should i use then ? Edited May 11, 20196 yr by Oscarita25
May 11, 20196 yr You can add a layer to the renderer at any point after which the renderer itself is created. So maybe postinit would be fine? You would need to debug it.
May 11, 20196 yr Author then how would i get the renderer of the player.... from the postinit? thats the main point why i thought i should use the renderplayerevent Edited May 11, 20196 yr by Oscarita25
May 11, 20196 yr RenderPlayer is very specific since it is attached to a "skin" identifier(steve or alex) You can get the map from Minecraft.getMinecraft().getRenderManager().getSkinMap() The value of a given key in said map will be the RenderPlayer instance. Edited May 11, 20196 yr by V0idWa1k3r
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.