1
\$\begingroup\$

I'm working on an minecraft forge mod (1.8.8). I have en custom (ownable) entity and want to set its texture to the texture of its owner, because it's a mini version of the owner.

I found out that i can get the texture of players with AbstractClientPlayer#getLocationSkin(), but i can't figure out how to access either EntityOtherPlayerMP or EntityPlayerSP, which implement AbstractClientPlayer, in my custom renderer. Is there a way to get all AbstractClientPlayer, regardless of SP or MP? I can access the GameProfile and i have the EntityPlayer of the owner.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Ok, the solution is fairly simple: I was able to simply cast the EntityPlayer to an AbstractClientPlayer! I got the EntityPlayer with my EntityLiving, because its an ownable creature:

@Override
protected ResourceLocation getEntityTexture(EntityLiving entity) {
    IEntityOwnable creature = (IEntityOwnable) entity;
    AbstractClientPlayer player = (AbstractClientPlayer) creature.getOwner();
    return player.getLocationSkin();
}
\$\endgroup\$
3
  • 1
    \$\begingroup\$ This of course only works if the entity is an IEntityOwnable which you stated it was, but you might want to insert an instanceof check just to avoid potential problems. \$\endgroup\$ Jan 4, 2016 at 17:08
  • \$\begingroup\$ @Draco18s Generally, yes, but this i given when i set it. \$\endgroup\$
    – Alex H
    Jan 5, 2016 at 3:16
  • \$\begingroup\$ I think it isn't even possible to get an plain EntityPlayer on Client-Side. This is inside a renderer, so it will only get called on a Game Client. \$\endgroup\$
    – Alex H
    Jan 5, 2016 at 3:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .