Jump to content

Recommended Posts

Posted

So I want to create a new pose for my player.

I have tried using the PlayerRenderEvent.Pre and Post.

But the player's body are rendered upside down just like the following picture.FizVyu4.png

here is my code 

@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public static void onPreRender(RenderPlayerEvent.Pre e){
    PlayerEntity p = e.getPlayer();
    if(p.getHeldItemMainhand().getItem() instanceof Lance){
      	PlayerModel<AbstractClientPlayerEntity> model = e.getRenderer().getEntityModel();
        model.bipedBody.showModel = false;
    }
}

@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public static void onPostRender(RenderPlayerEvent.Post e){
    PlayerEntity p = e.getPlayer();
    if(p.getHeldItemMainhand().getItem() instanceof Lance){
      	PlayerModel<AbstractClientPlayerEntity> model = e.getRenderer().getEntityModel();
        IVertexBuilder builder = e.getBuffers().getBuffer(RenderType.getEntitySolid(((AbstractClientPlayerEntity)e.getPlayer()).getLocationSkin()));
        int light = e.getRenderer().getRenderManager().getPackedLight(e.getPlayer(), e.getPartialRenderTick());
        MatrixStack stack = e.getMatrixStack();
        model.bipedBody.showModel = true;
        model.bipedBody.render(stack, builder,light,655360);
    }
}

You can see I even didn't rotate anything.

I also have tried stack.push() and stack.pop() but it didn't help at all.

Can anyone help?

Thank you.

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.