Jump to content

Recommended Posts

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.

 

Posted

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;

}

Posted

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.

 

 

Posted

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.

Posted

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.

Posted

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

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