The Meaning of Life, the Universe, and Everything.
Join Date:
8/9/2013
Posts:
211
Minecraft:
HappyKiller1O1
Xbox:
HappyKiller101
Member Details
So, I actually got some progress done on this (looking through the system). And, the model renders, but with two problems: first is MAJOR FPS drop (150 to 3). I am guessing it is because I add the layer in my event constantly, but I am not sure. Secondly, the model scale is incorrect, as shown here (it's rendered too small, just below the body which is where it needs to be):
The FPS issue is caused by a memory leak. Every time the entity renders (every frame) you add a new layer to the entity, and those layers are not being removed or garbage collected. This will cause the time required to complete a frame to increase (because you now have to do 1000+ times more rendering) and your memory to slowly fill up. The current solution that I have found is to add the layer to the skinMap during the init phase. You will need to add it to both the steve and alex model.
As for the backpack being rendered at the wrong size, and at the wrong position, you can use GLStateManager to scale (increase / decrease size) and translate (move on an XYZ axis) to the correct size and location.
The Meaning of Life, the Universe, and Everything.
Join Date:
8/9/2013
Posts:
211
Minecraft:
HappyKiller1O1
Xbox:
HappyKiller101
Member Details
Thank you for the reply! My only problem with this seems to be that I can not get an instance of RendererLivingEntity (which I need for my layer class):
(Minecraft.getMinecraft().getRenderManager().getSkinMap().get("default")).addLayer(new LayerBipedBackpack(need RenderLivingEntity instance for the player));
If you know how to get this, I would be very grateful!
Minecraft.getMinecraft().getRenderManager().getSkinMap().get("default")) will give you an instance of PlayerRenderer which is a RendererLivingEntity. You can simply store it as a variable before adding the layer.
The Meaning of Life, the Universe, and Everything.
Join Date:
8/9/2013
Posts:
211
Minecraft:
HappyKiller1O1
Xbox:
HappyKiller101
Member Details
I have actually been programming in Java for two years, and someone on the MinecraftForge forums pointed out this silly mistake I made. Thank you for the reply!
So, I actually got some progress done on this (looking through the system). And, the model renders, but with two problems: first is MAJOR FPS drop (150 to 3). I am guessing it is because I add the layer in my event constantly, but I am not sure. Secondly, the model scale is incorrect, as shown here (it's rendered too small, just below the body which is where it needs to be):
https://imgur.com/OczS36k
My classes:
Layer renderer base (for ease when I need to render different backpack models):
LayerBipedBackpack (the layer I add):
My Event:
I hope someone can help me here, I don't understand this plague of the new layer system. It seems no one ever has a clue on what to do here. :/
The FPS issue is caused by a memory leak. Every time the entity renders (every frame) you add a new layer to the entity, and those layers are not being removed or garbage collected. This will cause the time required to complete a frame to increase (because you now have to do 1000+ times more rendering) and your memory to slowly fill up. The current solution that I have found is to add the layer to the skinMap during the init phase. You will need to add it to both the steve and alex model.
((RenderPlayer)Minecraft.getMinecraft().getRenderManager().skinMap.get("default")).addLayer(layer);
((RenderPlayer)Minecraft.getMinecraft().getRenderManager().skinMap.get("slim")).addLayer(layer);
As for the backpack being rendered at the wrong size, and at the wrong position, you can use GLStateManager to scale (increase / decrease size) and translate (move on an XYZ axis) to the correct size and location.
Farewell everyone o/
Thank you for the reply! My only problem with this seems to be that I can not get an instance of RendererLivingEntity (which I need for my layer class):
If you know how to get this, I would be very grateful!
Looks like you are not very familiar with Java
Minecraft.getMinecraft().getRenderManager().getSkinMap().get("default")) will give you an instance of PlayerRenderer which is a RendererLivingEntity. You can simply store it as a variable before adding the layer.
RendererLivingEntity renderer = Minecraft.getMinecraft().getRenderManager().getSkinMap().get("default"));
renderer.addLayer(new LayerBipedBackpack(renderer));
Edit: That being said, you shouldn't actually need access to the LayerRenderer. In iChun's mod GuiltTrip he has an example of a LayerRenderer which does not depend of that information. https://github.com/iChun/GuiltTrip/blob/master/src/main/java/us/ichun/mods/guilttrip/client/layer/LayerGuiltTrip.java
Farewell everyone o/
I have actually been programming in Java for two years, and someone on the MinecraftForge forums pointed out this silly mistake I made. Thank you for the reply!