File size: 4,083 Bytes
d46f4a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package net.minecraft.client.model;

import java.util.Arrays;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.CubeListBuilder;
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.model.geom.builders.PartDefinition;
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
import net.minecraft.util.Mth;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
public class BlazeModel extends EntityModel<LivingEntityRenderState> {
    private final ModelPart[] upperBodyParts;
    private final ModelPart head;

    public BlazeModel(ModelPart p_170443_) {
        super(p_170443_);
        this.head = p_170443_.getChild("head");
        this.upperBodyParts = new ModelPart[12];
        Arrays.setAll(this.upperBodyParts, p_170449_ -> p_170443_.getChild(getPartName(p_170449_)));
    }

    private static String getPartName(int p_170446_) {
        return "part" + p_170446_;
    }

    public static LayerDefinition createBodyLayer() {
        MeshDefinition meshdefinition = new MeshDefinition();
        PartDefinition partdefinition = meshdefinition.getRoot();
        partdefinition.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F), PartPose.ZERO);
        float f = 0.0F;
        CubeListBuilder cubelistbuilder = CubeListBuilder.create().texOffs(0, 16).addBox(0.0F, 0.0F, 0.0F, 2.0F, 8.0F, 2.0F);

        for (int i = 0; i < 4; i++) {
            float f1 = Mth.cos(f) * 9.0F;
            float f2 = -2.0F + Mth.cos((float)(i * 2) * 0.25F);
            float f3 = Mth.sin(f) * 9.0F;
            partdefinition.addOrReplaceChild(getPartName(i), cubelistbuilder, PartPose.offset(f1, f2, f3));
            f++;
        }

        f = (float) (Math.PI / 4);

        for (int j = 4; j < 8; j++) {
            float f4 = Mth.cos(f) * 7.0F;
            float f6 = 2.0F + Mth.cos((float)(j * 2) * 0.25F);
            float f8 = Mth.sin(f) * 7.0F;
            partdefinition.addOrReplaceChild(getPartName(j), cubelistbuilder, PartPose.offset(f4, f6, f8));
            f++;
        }

        f = 0.47123894F;

        for (int k = 8; k < 12; k++) {
            float f5 = Mth.cos(f) * 5.0F;
            float f7 = 11.0F + Mth.cos((float)k * 1.5F * 0.5F);
            float f9 = Mth.sin(f) * 5.0F;
            partdefinition.addOrReplaceChild(getPartName(k), cubelistbuilder, PartPose.offset(f5, f7, f9));
            f++;
        }

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

    public void setupAnim(LivingEntityRenderState p_364987_) {
        super.setupAnim(p_364987_);
        float f = p_364987_.ageInTicks * (float) Math.PI * -0.1F;

        for (int i = 0; i < 4; i++) {
            this.upperBodyParts[i].y = -2.0F + Mth.cos(((float)(i * 2) + p_364987_.ageInTicks) * 0.25F);
            this.upperBodyParts[i].x = Mth.cos(f) * 9.0F;
            this.upperBodyParts[i].z = Mth.sin(f) * 9.0F;
            f++;
        }

        f = (float) (Math.PI / 4) + p_364987_.ageInTicks * (float) Math.PI * 0.03F;

        for (int j = 4; j < 8; j++) {
            this.upperBodyParts[j].y = 2.0F + Mth.cos(((float)(j * 2) + p_364987_.ageInTicks) * 0.25F);
            this.upperBodyParts[j].x = Mth.cos(f) * 7.0F;
            this.upperBodyParts[j].z = Mth.sin(f) * 7.0F;
            f++;
        }

        f = 0.47123894F + p_364987_.ageInTicks * (float) Math.PI * -0.05F;

        for (int k = 8; k < 12; k++) {
            this.upperBodyParts[k].y = 11.0F + Mth.cos(((float)k * 1.5F + p_364987_.ageInTicks) * 0.5F);
            this.upperBodyParts[k].x = Mth.cos(f) * 5.0F;
            this.upperBodyParts[k].z = Mth.sin(f) * 5.0F;
            f++;
        }

        this.head.yRot = p_364987_.yRot * (float) (Math.PI / 180.0);
        this.head.xRot = p_364987_.xRot * (float) (Math.PI / 180.0);
    }
}