Jump to content

Recommended Posts

Posted (edited)

Hello everyone,

I'm attempting to set the rotation angles of my model, however, it's not working. So what I've done so far: Made a Living entity, cancelled render player event at pre. Then I called a dorender method for the custom living entity. The new model loads fine. Just the animations do not. I'm thinking that it's because I'm typing this line in the render player event pre, which i suppose only fires when the player is being rendered the first time? I'm really not sure though. Any help is appreciated!

Here's what I've tried.

    @SubscribeEvent
    public static void onPlayerRender(RenderPlayerEvent.Pre event) {
        if (event.getEntity() instanceof EntityPlayer) {
            event.setCanceled(true);
        }

        RenderRealPlayer renderRealPlayer = new RenderRealPlayer(Minecraft.getMinecraft().getRenderManager(), new ModelRealPlayer());
        EntityRealPlayer player = new EntityRealPlayer(Minecraft.getMinecraft().world);
        renderRealPlayer.doRender(player, 0, 0, 0, 0.5f, event.getPartialRenderTick());
        renderRealPlayer.getMainModel().setRotationAngles(player.limbSwing, player.limbSwingAmount, player.ticksExisted, player.rotationYawHead, player.rotationPitch, 0.0f, player);

Also tried setting the rotation angles in living update event and didn't get very far because it felt wrong.

 

Edited by LittleOne
Posted
12 minutes ago, LittleOne said:

    @SubscribeEvent
    public static void onPlayerRender(RenderPlayerEvent.Pre event) {
        if (event.getEntity() instanceof EntityPlayer) {
            event.setCanceled(true);
        }

        RenderRealPlayer renderRealPlayer = new RenderRealPlayer(Minecraft.getMinecraft().getRenderManager(), new ModelRealPlayer());
        EntityRealPlayer player = new EntityRealPlayer(Minecraft.getMinecraft().world);
        renderRealPlayer.doRender(player, 0, 0, 0, 0.5f, event.getPartialRenderTick());
        renderRealPlayer.getMainModel().setRotationAngles(player.limbSwing, player.limbSwingAmount, player.ticksExisted, player.rotationYawHead, player.rotationPitch, 0.0f, player);

 

 

 

You are creating a new instance of EntityRealPlayer every time the player is rendering and then using the variables from that instance, instead of the player that is already in the world.

  • Thanks 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

I might understand. Thanks for the help! 

Tried a few things but still can't get it to work. Would I have to pull everything from event. ? From where I would have to change what my entity and render class inherits from? Right now they're not from renderplayer or entityplayer.

 

Or do I just need to pull the variables from event and apply them to set rotation angles? I tried this, but perhaps I did it wrong?

Posted
24 minutes ago, LittleOne said:

I might understand. Thanks for the help! 

Tried a few things but still can't get it to work. Would I have to pull everything from event. ? From where I would have to change what my entity and render class inherits from? Right now they're not from renderplayer or entityplayer.

 

Or do I just need to pull the variables from event and apply them to set rotation angles? I tried this, but perhaps I did it wrong?

event.getEntityPlayer().limbSwing;

Will give you the actual players limbSwing, also why not make your renderer use EntityPlayer, what is the point of using a new Entity?

  • Like 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

Honestly, I thought that was the only way to render a new model onto the player. While learning, I gathered that an entity has three things. Entity, render, and model classes. Going to test a few things now to try and fix it. Thank you.

Posted

I attempted to render the entityplayer in the new renderer. Is there a way to change the main model though? I'm not seeing getmainmodel or setrotationangles. Perhaps I didn't follow your suggestion right?

 

What I did: public class RenderRealPlayer extends Render<EntityPlayer>

Posted
55 minutes ago, LittleOne said:

What I did: public class RenderRealPlayer extends Render<EntityPlayer> 

Extend RenderPlayer and then in the constructor set the mainModel variable to whatever your model is, and if this doesn't work for you then tell me exactly what you are trying to accomplish by setting the rotation angles and overriding the main model.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

I'm trying to get the animations set in the rotation angles in the model class to work. They're supposed to be consistent back and forth animations of the designated box. The method does fire but it auto rotates to only one side instead of going back and forth. The animations work for a mob entity extending, for example, entity horse, just not the player. That's why I was using entityliving because the animations definitely work for it. However, since it doesn't work, it leads me to believe it's something with how I render the player. And you said that I'm creating a new instance of the player every time it's rendering and using the variables from that instance. If set rotation angles is already being called then I finally see that it doesn't need to be called again. Just the way I'm rendering it is wrong. Is it impossible to render what I'm attempting to render through entityliving/renderliving? If it is, I did try your way. I got a stack overflow error null at the dorender method in the renderplayerevent, pre. I've never learned about this type of error. What I tried was:

EntityPlayer player = event.getEntityPlayer();
EntityPlayerSP playerSP = (EntityPlayerSP)player;
RenderRealPlayer renderRealPlayer = new RenderRealPlayer(insert proper perameters here);
renderRealPlayer.doRender(playerSP, 0, 0, 0, 0.5f, event.getPartialRenderTicks);

So I looked up this type of error and found that the usual cause is deep recursion or an infinite loop of some sort. After reading this, I attempted to realize how it was calling itself. My IQ is very low so I, of course, was not able to accomplish this goal. Therefore, I'm unsure how to fix this and what I did wrong. Moving into uncharted territory, I was scared. So I went back to extending renderliving<EntityRealPlayer>. This does not mean that I'm not willing to return to this method. 

 

Next, I contacted someone more experienced in programming minecraft mods. Specifically animations. They too have not yet figured out what's going on. It seems you know exactly what's going on though. I'm just really hard headed and unlikely to learn quickly. You're giving me the answers. It's just that I have so many presumptions that it's making it difficult to process new information.


Truly sorry if I'm giving you a headache. It's not my intention even if it's occurring. I really do appreciate your time in helping me solve this.

Posted
5 hours ago, LittleOne said:

Truly sorry if I'm giving you a headache. It's not my intention even if it's occurring. I really do appreciate your time in helping me solve this.

Honestly, this is not a problem. If I received a headache from this I would have just gone to sleep, taken some medicine, or just took a break in general.

 

5 hours ago, LittleOne said:

So I looked up this type of error and found that the usual cause is deep recursion or an infinite loop of some sort. After reading this, I attempted to realize how it was calling itself. My IQ is very low so I, of course, was not able to accomplish this goal. Therefore, I'm unsure how to fix this and what I did wrong.

The recursion was caused by RenderPlayer.doRender calling the RenderPlayerEvent.Pre

if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderPlayerEvent.Pre(entity, this, partialTicks, x, y, z))) return;

To fix this just simply override RenderPlayer#doRender and use the same code but exclude that line of code.

 

Mind you this will just render your model with the default vanilla way so you may have to override the whole doRender method.

  • Thanks 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

I followed your instructions and everything worked out! Thank you soooo much!.

 

I ended up creating a RenderLivingBaseEx that inherits from renderlivingbase and changed the dorender method as instructed. Then I inherited from the class in my RenderLivBaseExEx and did some more things, then finally in my renderrealplayer class I used RenderLivBaseExEx, plugged in my model and texture and the animations are now playing. 

 

I love this site.

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.