Jump to content

Recommended Posts

Posted

Im trying to check whether a given player texture/player skin exists (ie is not missing) using AbstractClientPlayer.getLocationSkin(playerName) so that if the texture is missing I can render a default texture. How would you do this?

Posted

Im trying to check whether a given player texture/player skin exists (ie is not missing) using AbstractClientPlayer.getLocationSkin(playerName) so that if the texture is missing I can render a default texture. How would you do this?

You can find the player(AbstractClientPlayer) from the client world, and call AbstractClientPlayer#getLocationSkin() to get the skin of the player. That also covers the exceptional cases.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

I was thinking of checking whether or not the resource domain is empty but i dont think that will work as I think it will always have a length() > 0 even if the texture is missing. Not sure how else to achieve this.

 

I added my minecraft login credentials to eclipse debug config and gave myself a custom texture so that my player has a custom skin in game (which shows up on my player when I am debugging) but when I set the texture of my entity I get the missing texture icon when this is called

this.currentTexture = AbstractClientPlayer.getLocationSkin(playerName); //I get the missing texture texture overlaid over my model

but if I try

this.currentTexture = AbstractClientPlayer.locationStevePng;

Then I get the default steve texture/skin overlaid over my entity and it works perfectly

 

 

 

For those who are curious if you want to test your mod with your minecraft player so that you are the same player every time add this to your Debug Configurations \ (x)= Arguments tab \ inside the Program Arguments box

 

 

--version 1.7.10 --tweakClass cpw.mods.fml.common.launcher.FMLTweaker --accessToken modstest

--userProperties {}

--username yourMinecraftUsername

--password yourMinecraftPassword

 

 

 

This is my code currently I was changing

 !AbstractClientPlayer.getLocationSkin(playerName).getResourceDomain().isEmpty()

to

 AbstractClientPlayer.getLocationSkin(playerName).getResourceDomain().isEmpty() 

so that I could test whether or not having a custom player skin gets the entity to render without the pink/black missing texture but it doesnt. Even if the player has a normal skin when

this.currentTexture = AbstractClientPlayer.getLocationSkin(playerName); //I get the missing texture texture overlaid over my model

is called the missing texture shows up over my model. Anyone know what the issue is?

 

My doRender code

 

 

@Override
public void doRender(Entity entity, double x, double y, double z, float f, float F)
{
	if (entity instanceof EntityCustomType)
	{
		EntityCustomType ent = (EntityCustomType) entity;

		String playerName = ent.getPlayerName();
		if (playerName != null && !playerName.equals(""))
		{
			if(!AbstractClientPlayer.getLocationSkin(playerName).getResourceDomain().isEmpty()){
			this.currentTexture = AbstractClientPlayer.getLocationSkin(playerName);
			this.mainModel = this.playerModel;
			} else{
				this.currentTexture = AbstractClientPlayer.locationStevePng;
				this.mainModel = this.playerModel;
			}
		}
		else
		{
			this.currentTexture = this.consistentTexture;
			this.mainModel = this.consistentModel;
		}
	}

	super.doRender(entity, x, y, z, f, F);
}

 

 

Posted

I have been looking at it and it is quite difficult I am trying stuff but am not having much success as the code it obfuscated alot and uses quite a few fucntions to get the players game profile and somehow find the texture

Posted

From what I can tell this is the relevant bit of code where p_152674_7_ is the GameProfile of the player and is passed from TileEntitySkull is seems but I am not sure how all of it works as it is all obfuscated pretty much. I have managed to get my players game profile working but the f (map.containsKey(Type.SKIN)) isnt true for some reason.

 

ResourceLocation resourcelocation = AbstractClientPlayer.locationStevePng;

                if (p_152674_7_ != null)
                {
                    Minecraft minecraft = Minecraft.getMinecraft();
                    Map map = minecraft.func_152342_ad().func_152788_a(p_152674_7_);

                    if (map.containsKey(Type.SKIN))
                    {
                        resourcelocation = minecraft.func_152342_ad().func_152792_a((MinecraftProfileTexture)map.get(Type.SKIN), Type.SKIN);
                    }
                }

 

this is what I have so far in my render code. The game profile prints correctly it seems for my player it contains his uuid and name but for some reason I am not getting the texture not sure why or where this happens and thats the bit that I need.


private ModelBase playerModel = new ModelBiped();
private ModelBase consistentModel;
private GameProfile gameProfile = null;
private ResourceLocation consistentTexture;
private ResourceLocation currentTexture;

//more renderer code that is irrelevant to the issue

@Override
public void doRender(Entity entity, double x, double y, double z, float f, float F)
{
	if (entity instanceof EntityCustomType)
	{
		EntityCustomType ent = (EntityCustomType) entity;

		String playerName = ent.getPlayerName();
                        gameProfile = MinecraftServer.getServer().func_152358_ax().func_152655_a(playerName);
		if (playerName != null && !playerName.equals(""))
		{
			if(gameProfile !=null){
			this.getGameProfileTexture(gameProfile);
			this.mainModel = this.playerModel;
			} else{
				this.currentTexture = AbstractClientPlayer.locationStevePng;
				this.mainModel = this.playerModel;
			}
		}
		else
		{
			this.currentTexture = this.consistentTexture;
			this.mainModel = this.consistentModel;
		}
	}

	super.doRender(entity, x, y, z, f, F);
}

public void getGameProfileTexture(GameProfile profile)
    {
               ResourceLocation resourcelocation = AbstractClientPlayer.getLocationSkin(profile.getName());

               
                    Minecraft minecraft = Minecraft.getMinecraft();
                    Map map = minecraft.func_152342_ad().func_152788_a(profile);

                    if (map.containsKey(Type.SKIN))
                    { 
                    	System.out.println(map.containsKey(Type.SKIN)); //never called
                        resourcelocation = minecraft.func_152342_ad().func_152792_a((MinecraftProfileTexture)map.get(Type.SKIN), Type.SKIN);
                        this.currentTexture = resourcelocation;
                    }
               
                this.currentTexture = resourcelocation;
                }

Posted

Definately stuck on this one, the code is pretty complex I didnt realize how much it took to get the players chosen skin. I may just write my own system for when the mod starts choose your player skin and save it at that point rather than messing with all of this obfuscated hard to read code

Posted

What player do you want to get the skin from? An in-game player or someone can be logged out at the time?

For the former, you can find instance of the AbstractClientPlayer for the player.

For the latter, you should download the skin manually. In this case, see SkinManager code. (especially #func_152790_a)

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

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.