Topic category: Advanced modding
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.
*still work without playing on a paid/premium account
Ooh okay alright. Though, just for my own conscience, can I make it work on mcreator by applying the first script you gave to the last one? Something like this:
probably not because the required classes aren't set up yet when the entity is registering (which is where this code is being called)
Alright, I'll just deal with it.
Thank you very much for the help :D
np :3