Jump to content

How can I get AbstractClientPlayer


MGlolenstine

Recommended Posts

7 hours ago, lexy said:

Minecraft.getMinecraft().player is an EntityPlayerSP which is a AbstractClientPlayer (see inheritance hierarchy below). Why do you say it isn't the right one?

entityPlayerSP inheritance hierarchy.PNG

Well... to be honest, I don't think that my assumption that it wasn't the correct one was correct, but when I try it with Minecraft.player, I get NPE. And I'm 100% sure that I call it when it's not null

Link to comment
Share on other sites

1 minute ago, MGlolenstine said:

Well... to be honest, I don't think that my assumption that it wasn't the correct one was correct, but when I try it with Minecraft.player, I get NPE. And I'm 100% sure that I call it when it's not null

 

Post your code and the exception using Gist/Pastebin.

 

What do you need the player for? Why does it need to be an AbstractClientPlayer specifically?

Edited by Choonster
  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Ok, so I'm trying to use Minecraft's deadmou5e ears code, so I copy-pasted code from Minecraft's class into my class, and it requires AbstractClientPlayer.

 

public static void renderEars(AbstractClientPlayer entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
        if (entitylivingbaseIn.hasSkin() && !entitylivingbaseIn.isInvisible()) {
            playerRenderer.bindTexture(entitylivingbaseIn.getLocationSkin());

            for (int i = 0; i < 2; ++i) {
                float f = entitylivingbaseIn.prevRotationYaw + (entitylivingbaseIn.rotationYaw - entitylivingbaseIn.prevRotationYaw) * partialTicks - (entitylivingbaseIn.prevRenderYawOffset + (entitylivingbaseIn.renderYawOffset - entitylivingbaseIn.prevRenderYawOffset) * partialTicks);
                float f1 = entitylivingbaseIn.prevRotationPitch + (entitylivingbaseIn.rotationPitch - entitylivingbaseIn.prevRotationPitch) * partialTicks;
                GlStateManager.pushMatrix();
                GlStateManager.rotate(f, 0.0F, 1.0F, 0.0F);
                GlStateManager.rotate(f1, 1.0F, 0.0F, 0.0F);
                GlStateManager.translate(0.375F * (float)(i * 2 - 1), 0.0F, 0.0F);
                GlStateManager.translate(0.0F, -0.375F, 0.0F);
                GlStateManager.rotate(-f1, 1.0F, 0.0F, 0.0F);
                GlStateManager.rotate(-f, 0.0F, 1.0F, 0.0F);
                float f2 = 1.3333334F;
                GlStateManager.scale(1.3333334F, 1.3333334F, 1.3333334F);
                playerRenderer.getMainModel().renderDeadmau5Head(0.0625F);
                GlStateManager.popMatrix();
            }
        }
    }

 

Link to comment
Share on other sites

1 hour ago, MGlolenstine said:

Ok, so I'm trying to use Minecraft's deadmou5e ears code, so I copy-pasted code from Minecraft's class into my class, and it requires AbstractClientPlayer.

 

Where are you calling this from? Which player are you trying to render the ears for?

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

14 minutes ago, MGlolenstine said:

I only want to render ears for the local player and I'm calling it from 


RenderLivingEvent.Post event

 

Use RenderLivingEvent#getEntity to get the entity being rendered, check if it's the client player (Minecraft#player) and then cast it to AbstractClientPlayer before rendering the ears.

 

Since you're only rendering this for a player, it's probably best to subscribe to RenderPlayerEvent.Post instead of RenderLivingEvent.Post. This is only fired for players rather than every living entity.

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Just now, Choonster said:

 

Use RenderLivingEvent#getEntity to get the entity being rendered, check if it's the client player (Minecraft#player) and then cast it to AbstractClientPlayer before rendering the ears.

 

Since you're only rendering this for a player, it's probably best to subscribe to RenderPlayerEvent.Post instead of RenderLivingEvent.Post. This is only fired for players rather than every living entity.

Thank you!

Link to comment
Share on other sites

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.