Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.10] Get Skin to use on custom model from a given username

Featured Replies

Posted

I'm not sure where to start with this. Let's say I have an item that has been named on an anvil with X player name.

 

How would I go around to get that X player skin to use it to render with my model?

 

I have done some tests with GameProfile and creating one with null UUID and the name of X player, and then trying to get the skin from the profile, but it doesn't seam to do the job.

 

  • Author

I'm trying to render them as a player itself, in a model.

 

On my Entity I have a "private static GameProfile owner;"

 

Then I have

 

	public MyEntityMe(World worldIn) {
	super(worldIn);
	this.owner = new GameProfile(null, "namegoeshere");
	// TODO Auto-generated constructor stub
}

 

Then I have a method to get the resource location that gets called on the renderer.

 

    public static ResourceLocation getResourceLocation() {

	Minecraft minecraft = Minecraft.getMinecraft();

	Map<?, ?> map = minecraft.getSkinManager().loadSkinFromCache(owner);

	if (map.containsKey(Type.SKIN)) {
		final MinecraftProfileTexture skin = (MinecraftProfileTexture)map.get(Type.SKIN);
		return minecraft.getSkinManager().loadSkin(skin, Type.SKIN);
	}
	return null;

}

  • Author

What actually happens, does it render with the missing texture? Or Steve skin?

 

Well, first to make sure everything else was working ok I had something like this on my Renderer:

public static final ResourceLocation TEXTURE = new ResourceLocation(ModInfo.MODID + ":textures/entities/steve.png");

 

And I have Steve Texture on my assets.

 

But now with the code I have above is renders the missing texture Purple and Black. I believe the problem is the way I'm creating the GameProfile, not sure.

 

 

  • Author

Don't store the name, when the user enters the name, immediately convert it to UUID and then use that from then on. If you need to display the name again, convert back. Otherwise your system will break when the user changes name.

 

So I should get the UUID from the given name, and then get a new GameProfile with the UUID I got and try from there?

 

Gonna try it, thanks you.

  • Author

So I should get the UUID from the given name, and then get a new GameProfile with the UUID I got and try from there?
Yes. You should never store usernames anywhere (except in a UUID->name cache).

I'm confuse on how would I get the UUID from a given name.

Any tips?

 

Thanks a lot.

  • Author

How would I go around to get that X player skin to use it to render with my model?

 

I was just offering a different way to get the player skin.

 

He can get it off the players client from the using getLocationSkin. Send it to the server via packet. If rendering an entity or tileEntity pass that resourceLocation to the renderer on the client by utilizing IEntityAdditionalSpawnData.

 

At least that is how I do it.

 

Also for my case, I need to have access to any Skin with the only starting information been the Minecraft Name of the player, so it's not just players connected to a server, or players ingame, but any given name.

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...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.