ModelGuardian .java

net.minecraft.client.model.ModelGuardian (class, 137 lines): members: guardianSpines, func_178706_a, guardianBody, guardianTail, guardianEye, render.

net.minecraft.client.modelclass137 linesclientextends ModelBase6.6 KB

API Surface (3)

int func_178706_a()
void render(Entity entityIn, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale)
void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)

Fields & Constants (4)

guardianBody
guardianEye
guardianSpines
guardianTail

Code Graph: Dependencies (7)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

ModelGuardian.java137 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.model;
2
3
import net.minecraft.client.Minecraft;
4
import net.minecraft.entity.Entity;
5
import net.minecraft.entity.monster.EntityGuardian;
6
import net.minecraft.util.MathHelper;
7
import net.minecraft.util.Vec3;
8
9
public class ModelGuardian extends ModelBase
10
{
11
    private ModelRenderer guardianBody;
12
    private ModelRenderer guardianEye;
13
    private ModelRenderer[] guardianSpines;
14
    private ModelRenderer[] guardianTail;
15
16
    public ModelGuardian()
17
    {
18
        this.textureWidth = 64;
19
        this.textureHeight = 64;
20
        this.guardianSpines = new ModelRenderer[12];
21
        this.guardianBody = new ModelRenderer(this);
22
        this.guardianBody.setTextureOffset(0, 0).addBox(-6.0F, 10.0F, -8.0F, 12, 12, 16);
23
        this.guardianBody.setTextureOffset(0, 28).addBox(-8.0F, 10.0F, -6.0F, 2, 12, 12);
24
        this.guardianBody.setTextureOffset(0, 28).addBox(6.0F, 10.0F, -6.0F, 2, 12, 12, true);
25
        this.guardianBody.setTextureOffset(16, 40).addBox(-6.0F, 8.0F, -6.0F, 12, 2, 12);
26
        this.guardianBody.setTextureOffset(16, 40).addBox(-6.0F, 22.0F, -6.0F, 12, 2, 12);
27
28
        for (int i = 0; i < this.guardianSpines.length; ++i)
29
        {
30
            this.guardianSpines[i] = new ModelRenderer(this, 0, 0);
31
            this.guardianSpines[i].addBox(-1.0F, -4.5F, -1.0F, 2, 9, 2);
32
            this.guardianBody.addChild(this.guardianSpines[i]);
33
        }
34
35
        this.guardianEye = new ModelRenderer(this, 8, 0);
36
        this.guardianEye.addBox(-1.0F, 15.0F, 0.0F, 2, 2, 1);
37
        this.guardianBody.addChild(this.guardianEye);
38
        this.guardianTail = new ModelRenderer[3];
39
        this.guardianTail[0] = new ModelRenderer(this, 40, 0);
40
        this.guardianTail[0].addBox(-2.0F, 14.0F, 7.0F, 4, 4, 8);
41
        this.guardianTail[1] = new ModelRenderer(this, 0, 54);
42
        this.guardianTail[1].addBox(0.0F, 14.0F, 0.0F, 3, 3, 7);
43
        this.guardianTail[2] = new ModelRenderer(this);
44
        this.guardianTail[2].setTextureOffset(41, 32).addBox(0.0F, 14.0F, 0.0F, 2, 2, 6);
45
        this.guardianTail[2].setTextureOffset(25, 19).addBox(1.0F, 10.5F, 3.0F, 1, 9, 9);
46
        this.guardianBody.addChild(this.guardianTail[0]);
47
        this.guardianTail[0].addChild(this.guardianTail[1]);
48
        this.guardianTail[1].addChild(this.guardianTail[2]);
49
    }
50
51
    public int func_178706_a()
52
    {
53
        return 54;
54
    }
55
56
    /**
57
     * Sets the models various rotation angles then renders the model.
58
     */
59
    public void render(Entity entityIn, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale)
60
    {
61
        this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, scale, entityIn);
62
        this.guardianBody.render(scale);
63
    }
64
65
    /**
66
     * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
67
     * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
68
     * "far" arms and legs can swing at most.
69
     */
70
    public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
71
    {
72
        EntityGuardian entityguardian = (EntityGuardian)entityIn;
73
        float f = ageInTicks - (float)entityguardian.ticksExisted;
74
        this.guardianBody.rotateAngleY = netHeadYaw / (180F / (float)Math.PI);
75
        this.guardianBody.rotateAngleX = headPitch / (180F / (float)Math.PI);
76
        float[] afloat = new float[] {1.75F, 0.25F, 0.0F, 0.0F, 0.5F, 0.5F, 0.5F, 0.5F, 1.25F, 0.75F, 0.0F, 0.0F};
77
        float[] afloat1 = new float[] {0.0F, 0.0F, 0.0F, 0.0F, 0.25F, 1.75F, 1.25F, 0.75F, 0.0F, 0.0F, 0.0F, 0.0F};
78
        float[] afloat2 = new float[] {0.0F, 0.0F, 0.25F, 1.75F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.75F, 1.25F};
79
        float[] afloat3 = new float[] {0.0F, 0.0F, 8.0F, -8.0F, -8.0F, 8.0F, 8.0F, -8.0F, 0.0F, 0.0F, 8.0F, -8.0F};
80
        float[] afloat4 = new float[] { -8.0F, -8.0F, -8.0F, -8.0F, 0.0F, 0.0F, 0.0F, 0.0F, 8.0F, 8.0F, 8.0F, 8.0F};
81
        float[] afloat5 = new float[] {8.0F, -8.0F, 0.0F, 0.0F, -8.0F, -8.0F, 8.0F, 8.0F, 8.0F, -8.0F, 0.0F, 0.0F};
82
        float f1 = (1.0F - entityguardian.func_175469_o(f)) * 0.55F;
83
84
        for (int i = 0; i < 12; ++i)
85
        {
86
            this.guardianSpines[i].rotateAngleX = (float)Math.PI * afloat[i];
87
            this.guardianSpines[i].rotateAngleY = (float)Math.PI * afloat1[i];
88
            this.guardianSpines[i].rotateAngleZ = (float)Math.PI * afloat2[i];
89
            this.guardianSpines[i].rotationPointX = afloat3[i] * (1.0F + MathHelper.cos(ageInTicks * 1.5F + (float)i) * 0.01F - f1);
90
            this.guardianSpines[i].rotationPointY = 16.0F + afloat4[i] * (1.0F + MathHelper.cos(ageInTicks * 1.5F + (float)i) * 0.01F - f1);
91
            this.guardianSpines[i].rotationPointZ = afloat5[i] * (1.0F + MathHelper.cos(ageInTicks * 1.5F + (float)i) * 0.01F - f1);
92
        }
93
94
        this.guardianEye.rotationPointZ = -8.25F;
95
        Entity entity = Minecraft.getMinecraft().getRenderViewEntity();
96
97
        if (entityguardian.hasTargetedEntity())
98
        {
99
            entity = entityguardian.getTargetedEntity();
100
        }
101
102
        if (entity != null)
103
        {
104
            Vec3 vec3 = entity.getPositionEyes(0.0F);
105
            Vec3 vec31 = entityIn.getPositionEyes(0.0F);
106
            double d0 = vec3.yCoord - vec31.yCoord;
107
108
            if (d0 > 0.0D)
109
            {
110
                this.guardianEye.rotationPointY = 0.0F;
111
            }
112
            else
113
            {
114
                this.guardianEye.rotationPointY = 1.0F;
115
            }
116
117
            Vec3 vec32 = entityIn.getLook(0.0F);
118
            vec32 = new Vec3(vec32.xCoord, 0.0D, vec32.zCoord);
119
            Vec3 vec33 = (new Vec3(vec31.xCoord - vec3.xCoord, 0.0D, vec31.zCoord - vec3.zCoord)).normalize().rotateYaw(((float)Math.PI / 2F));
120
            double d1 = vec32.dotProduct(vec33);
121
            this.guardianEye.rotationPointX = MathHelper.sqrt_float((float)Math.abs(d1)) * 2.0F * (float)Math.signum(d1);
122
        }
123
124
        this.guardianEye.showModel = true;
125
        float f2 = entityguardian.func_175471_a(f);
126
        this.guardianTail[0].rotateAngleY = MathHelper.sin(f2) * (float)Math.PI * 0.05F;
127
        this.guardianTail[1].rotateAngleY = MathHelper.sin(f2) * (float)Math.PI * 0.1F;
128
        this.guardianTail[1].rotationPointX = -1.5F;
129
        this.guardianTail[1].rotationPointY = 0.5F;
130
        this.guardianTail[1].rotationPointZ = 14.0F;
131
        this.guardianTail[2].rotateAngleY = MathHelper.sin(f2) * (float)Math.PI * 0.15F;
132
        this.guardianTail[2].rotationPointX = 0.5F;
133
        this.guardianTail[2].rotationPointY = 0.5F;
134
        this.guardianTail[2].rotationPointZ = 6.0F;
135
    }
136
}
137

Deobfuscated MCP 1.8.9 source of ModelGuardian from Marcelektro/MavenMCP-1.8.9 (net/minecraft/client/model/ModelGuardian.java), stored verbatim.