Model name is not filename but the name inside the model java code

Started by zeinov on

Topic category: Help with Minecraft modding (Java Edition)

Joined Feb 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Model name is not filename but the name inside the model java code

Hello I am trying to add a Java model in Mcreator but I have an error message which is this:
your model name is not valid java name

custom mob model can not contain whitespace start with number or any non ASCII letters

Model name is not filename but the name inside the model java code (model class name)

here is the code (I don't know anything about code) : 

// Made with Blockbench 4.6.3
// Exported for Minecraft version 1.17 or later with Mojang mappings
// Paste this class into your mod and generate all required imports


public class custom_model<T extends Entity> extends EntityModel<T> {
    // This layer location should be baked with EntityRendererProvider.Context in the entity renderer and passed into this model's constructor
    public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(new ResourceLocation("modid", "custom_model"), "main");
    private final ModelPart Body;
    private final ModelPart RightArm;
    private final ModelPart LeftArm;

    public custom_model(ModelPart root) {
        this.Body = root.getChild("Body");
        this.RightArm = root.getChild("RightArm");
        this.LeftArm = root.getChild("LeftArm");
    }

    public static LayerDefinition createBodyLayer() {
        MeshDefinition meshdefinition = new MeshDefinition();
        PartDefinition partdefinition = meshdefinition.getRoot();

        PartDefinition Body = partdefinition.addOrReplaceChild("Body", CubeListBuilder.create().texOffs(0, 0).addBox(-5.0F, 2.0F, -3.0F, 10.0F, 10.0F, 0.0F, new CubeDeformation(0.0F))
        .texOffs(0, 12).addBox(-5.0F, 0.0F, 3.0F, 10.0F, 12.0F, 0.0F, new CubeDeformation(0.0F))
        .texOffs(21, -6).addBox(-5.0F, 0.0F, -3.0F, 0.0F, 12.0F, 6.0F, new CubeDeformation(0.0F))
        .texOffs(52, -6).addBox(5.0F, 0.0F, -3.0F, 0.0F, 12.0F, 6.0F, new CubeDeformation(0.0F))
        .texOffs(56, 17).addBox(-5.0F, 1.0F, -3.0F, 4.0F, 1.0F, 0.0F, new CubeDeformation(0.0F))
        .texOffs(56, 19).addBox(1.0F, 1.0F, -3.0F, 4.0F, 1.0F, 0.0F, new CubeDeformation(0.0F))
        .texOffs(58, 21).addBox(-5.0F, 0.0F, -3.0F, 3.0F, 1.0F, 0.0F, new CubeDeformation(0.0F))
        .texOffs(58, 26).addBox(2.0F, 0.0F, -3.0F, 3.0F, 1.0F, 0.0F, new CubeDeformation(0.0F))
        .texOffs(31, 27).addBox(-5.0F, 0.0F, -3.0F, 3.0F, 0.0F, 6.0F, new CubeDeformation(0.0F))
        .texOffs(23, 12).addBox(2.0F, 0.0F, -3.0F, 3.0F, 0.0F, 6.0F, new CubeDeformation(0.0F))
        .texOffs(54, 32).addBox(-2.0F, 0.0F, 1.0F, 4.0F, 0.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 0.0F, 0.0F));

        PartDefinition RightArm = partdefinition.addOrReplaceChild("RightArm", CubeListBuilder.create().texOffs(0, 25).addBox(-4.0F, -2.0F, -3.0F, 0.0F, 11.0F, 6.0F, new CubeDeformation(0.0F))
        .texOffs(0, 25).addBox(-4.0F, -2.0F, -3.0F, 6.0F, 11.0F, 0.0F, new CubeDeformation(0.0F))
        .texOffs(0, 25).addBox(-4.0F, -2.0F, 3.0F, 6.0F, 11.0F, 0.0F, new CubeDeformation(0.0F))
        .texOffs(0, 25).addBox(-4.0F, -2.0F, -3.0F, 6.0F, 0.0F, 6.0F, new CubeDeformation(0.0F))
        .texOffs(0, 25).addBox(2.0F, -2.0F, -3.0F, 0.0F, 11.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offset(-5.0F, 2.0F, 0.0F));

        PartDefinition LeftArm = partdefinition.addOrReplaceChild("LeftArm", CubeListBuilder.create().texOffs(0, 25).addBox(-2.0F, -2.0F, -3.0F, 6.0F, 11.0F, 0.0F, new CubeDeformation(0.0F))
        .texOffs(0, 25).addBox(-2.0F, -2.0F, 3.0F, 6.0F, 11.0F, 0.0F, new CubeDeformation(0.0F))
        .texOffs(0, 25).addBox(4.0F, -2.0F, -3.0F, 0.0F, 11.0F, 6.0F, new CubeDeformation(0.0F))
        .texOffs(0, 25).addBox(-2.0F, -2.0F, -3.0F, 6.0F, 0.0F, 6.0F, new CubeDeformation(0.0F))
        .texOffs(0, 25).addBox(-2.0F, -2.0F, -3.0F, 0.0F, 11.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offset(5.0F, 2.0F, 0.0F));

        return LayerDefinition.create(meshdefinition, 64, 64);
    }

    @Override
    public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {

    }

    @Override
    public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
        Body.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
        RightArm.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
        LeftArm.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
    }
}