Need help with the making of an Entity that wears the player skin

Started by Ze Phoenixx on

Topic category: Advanced modding

Joined Apr 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Need help with the making of an Entity that wears the player skin

So I've been trying to make an entity that wears the skin(and also the model) of the player for a little while now, I know that this requires coding but the problem is I don't have any knowledge in JAVA script. Which is why I asked chat GPT for help. I know I know that's a really bland way to do it, I'm aware of that. But I wasn't planning to just copy paste whatever code chat GPT gave me, I just tried to have it explain my custom entity's default code and the code it suggested me to rewrite it with so that I could understand what to change and learn in the process.

 

I already looked on the mcreator forum a little bit and figured out that I just needed to change my entity's(which is named "Echo") "Renderer" script.

Here is the code I wrote with chat GPT's help, I separated annoted what part is different from the default and also excluded the imports.

// Part modified by me; was trying to make the entity wear the player's current model by replacing every of the entity base model references with the player model(that I imported beforehand)//
																								
public class EchoRenderer extends MobRenderer<EchoEntity, LivingEntityRenderState, PlayerModel> {
	private EchoEntity entity = null;

	public EchoRenderer(EntityRendererProvider.Context context) {
		super(context, new PlayerModel(context.bakeLayer(PlayerModel.LAYER_LOCATION)), 0.5f); 
	}


																											// Unchanged
	@Override
	public LivingEntityRenderState createRenderState() {
		return new LivingEntityRenderState();
	}

	@Override
	public void extractRenderState(EchoEntity entity, LivingEntityRenderState state, float partialTicks) {
		super.extractRenderState(entity, state, partialTicks);
		this.entity = entity;
	}

	@Override
	public ResourceLocation getTextureLocation(LivingEntityRenderState state) {
																											// Unchanged


																							// The part modified by Chat GPT
		Minecraft mc = Minecraft.getInstance();
		if (mc.player != null && entity.level().isClientSide) {
			GameProfile profile = mc.player.getGameProfile();
			SkinManager sm = mc.getSkinManager(); // On this line I was just experiencing with Chat GPT's code and extended it a bit
			PlayerSkin skin = sm.getInsecureSkin(profile);
			if (skin != null) {
				return skin.texture();
			}
		}
																							// The part modified by Chat GPT


																							//	Unchanged	
		
		return ResourceLocation.parse("testmod:textures/entities/empty_playertexture.png");
	}
}

From what chat GPT said and what I understand, the code it wrote checks if the player exists, if we're on the client side, gets the player skin and makes the client render my entity with it, and if any of that fails it will just render my entity with its default texture.

Now, when I try to launch the client, I keep getting errors. And when I try to fix those errors, I get met with more errors. And even when I ask chat GPT to fix the errors, I still get errors.

 

I did manage to reduce the errors but now I'm stuck with the following ones:

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler output below.
[The code file location]:26: error: cannot find symbol super(context, new PlayerModel(context.bakeLayer(PlayerModel.LAYER_LOCATION)), 0.5f);
^
symbol: variable LAYER_LOCATION
location: class PlayerModel

The arrow may be misplaced here but it's pointing at the dot between PlayerModel and LAYER_LOCATION.



[The code file location]:22: error: type argument PlayerModel is not within bounds of type-variable M public class EchoRenderer extends MobRenderer<EchoEntity, LivingEntityRenderState, PlayerModel> {
^
 where M,S are type-variables: 
      M extends EntityModel<? super S> declared in class MobRenderer 
      S extends LivingEntityRenderState declared in class MobRenderer 
  2 errors 
* Try: 
> Check your code and dependencies to fix the compilation error(s) 
> Run with --scan to get full insights. 
BUILD FAILED in 3s

The arrow may be misplaced here but it's pointing at "PlayerModel". I can't manage to understand the issue here, i figured it's saying "PlayerModel" needs a parameter, chat GPT suggested to add "EchoEntity" as a parameter in order to specify we wanna render EchoEntity with PlayerModel except whenever I do the console says "PlayerModel" doesn't take parameters so I'm really confused.

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
ai sucks, what is your…
Mon, 10/27/2025 - 21:52

ai sucks, what is your minecraft version and modloader?

this works in 1.21.4 neoforge

Minecraft minecraft = Minecraft.getInstance();
return minecraft.getSkinManager().getInsecureSkin(minecraft.getGameProfile()).texture();
Joined Apr 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I am on NeoForge 1.21.4, so…
Mon, 10/27/2025 - 22:14

I am on NeoForge 1.21.4, so from what I understand I only got the last part you framed wrong? So I don't need to write a backup code in case the player skin isn't found? 

And do I need to also make it wear the players model? I thought to do that incase the player has a slim model.

I'll edit that part of the code right now.

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
no you don't need to handle…
Mon, 10/27/2025 - 22:26

no you don't need to handle the case of the player's skin not being found

if you want it to also copy the slim part simply do this,

private static ModelLayerLocation getModelLayerLocation() {
	Minecraft minecraft = Minecraft.getInstance();
	PlayerSkin.Model model = minecraft.getSkinManager().getInsecureSkin(Minecraft.getInstance().getGameProfile()).model();
	return model == PlayerSkin.Model.SLIM ? ModelLayers.PLAYER_SLIM : ModelLayers.PLAYER;
}

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
if you don't already know,…
Mon, 10/27/2025 - 22:28

if you don't already know, in the mcreator code editor, you can import all the imports by pressing ctrl+w

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
*all the required imports
Mon, 10/27/2025 - 22:28

*all the required imports

Joined Apr 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I rewrote the code and now I…
Mon, 10/27/2025 - 23:07

I rewrote the code and now I keep getting those 2 errors:

EchoRenderer.java:30: error: cannot find symbol public EchoRenderState createRenderState() {
^
symbol: class EchoRenderState
location: class EchoRenderer

EchoRenderer.java:31: error: cannot find symbol return new EchoRenderState();
^
symbol: class EchoRenderState
location: class EchoRenderer

And when I try to delete the problematic method(if that's how it's called) I just get this error instead:

EchoRenderer.java:15: error: EchoRenderer is not abstract and does not override abstract method createRenderState() in EntityRenderer public class EchoRenderer extends HumanoidMobRenderer<EchoEntity, HumanoidRenderState, HumanoidModel<HumanoidRenderState>> {
^
Joined Apr 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Nevermind I figured how to…
Mon, 10/27/2025 - 23:13

Nevermind I figured how to fix it, I just replaced "EchoRenderState" with "HumanoidRenderState" and I think it's working now!

Thank you so much for the help and #### this useless chatGPT