Hi, I want to replace the player's model by a mob's model (ex: a creeper).
How can I do this with Minecraft Forge 1.12 ?
That's what I've tried:
@SubscribeEvent
public void onRenderPlayer(RenderPlayerEvent.Pre e) {
e.setCanceled(true);
ModelHorse model = new ModelHorse();
EntityLivingBase entity = e.getEntityLiving();
EntityCreeper creeper = new EntityCreeper(entity.getEntityWorld());
creeper.setPositionAndRotation(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
creeper.setEntityInvulnerable(true);
RenderCreeper render = new RenderCreeper(Minecraft.getMinecraft().getRenderManager());
render.prepareScale(creeper, 0);
render.doRender(creeper, entity.posX, entity.posY, entity.posZ, entity.rotationYaw, 0);
}
But that only results in the player being invisible.
Thank you for your help.
Why are you creating a horse model and an actual creeper entity? I think that would cause trouble.
Other people probably know better ways, but I think you should create your own creeper render class and maybe model class that copies the creeper code but changed enough so it will render based on the player not based on some new creeper entity.
Also, to debug an issue like this you should use debugger and set breakpoints and check what position it is being rendered in and other things. Often when rendering seems to be "invisible" it just means it is rendering in the wrong place or at wrong scale or something.
The horse model was a mistake I made, because when I noticed the creeper didn't work, I tried a different mob, and then I changed it back and forgot to change the model.
Thanks to your help, I managed to render a creeper with his texture, but it renders upside down (it's head is on the floor)
This is the code I used:
public class RenderCreeperMorph extends RenderLivingBase<EntityLivingBase> {
private ModelCreeper model = new ModelCreeper();
public RenderCreeperMorph(ModelCreeper model) {
super(Minecraft.getMinecraft().getRenderManager(), model, 1.0F);
this.model = model;
}
public void render(EntityPlayer player) {
doRender(player, player.posX, player.posY, player.posZ, player.rotationYaw, 1F);
model.render(player, player.limbSwing, player.limbSwingAmount, 1, player.rotationYaw, player.rotationPitch, 0.07F);
}
@Override
protected ResourceLocation getEntityTexture(EntityLivingBase entity) {
return new ResourceLocation("minecraft:textures/entity/creeper/creeper.png");
}
}
And then I called the RenderCreeperMorph#render method inside the onRenderPlayer method with the player as parameter.
I could just create another Creeper model and flip every part, but please let me know if there is any better solution.
Same way the creeper model does set rotations for all the other parts of the model like swinging the arms. Look at the code for that class to get ideas.
Hi, I want to replace the player's model by a mob's model (ex: a creeper).
How can I do this with Minecraft Forge 1.12 ?
That's what I've tried:
Bump!
Why are you creating a horse model and an actual creeper entity? I think that would cause trouble.
Other people probably know better ways, but I think you should create your own creeper render class and maybe model class that copies the creeper code but changed enough so it will render based on the player not based on some new creeper entity.
Also, to debug an issue like this you should use debugger and set breakpoints and check what position it is being rendered in and other things. Often when rendering seems to be "invisible" it just means it is rendering in the wrong place or at wrong scale or something.
Thank you for your answer
The horse model was a mistake I made, because when I noticed the creeper didn't work, I tried a different mob, and then I changed it back and forgot to change the model.
Thanks to your help, I managed to render a creeper with his texture, but it renders upside down (it's head is on the floor)
This is the code I used:
And then I called the RenderCreeperMorph#render method inside the onRenderPlayer method with the player as parameter.
I could just create another Creeper model and flip every part, but please let me know if there is any better solution.
Thank you
You should be able to just rotate in the model or in the render call, although not sure why it wouldn't be correct already.
How can I do that ?
Same way the creeper model does set rotations for all the other parts of the model like swinging the arms. Look at the code for that class to get ideas.