the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "WitherBossModel.h"
3#include "..\Minecraft.World\WitherBoss.h"
4#include "ModelPart.h"
5
6WitherBossModel::WitherBossModel()
7{
8 texWidth = 64;
9 texHeight = 64;
10
11 upperBodyParts = ModelPartArray(3);
12
13 upperBodyParts[0] = new ModelPart(this, 0, 16);
14 upperBodyParts[0]->addBox(-10, 3.9f, -.5f, 20, 3, 3);
15
16 upperBodyParts[1] = new ModelPart(this);
17 upperBodyParts[1]->setTexSize(texWidth, texHeight);
18 upperBodyParts[1]->setPos(-2, 6.9f, -.5f);
19 upperBodyParts[1]->texOffs(0, 22)->addBox(0, 0, 0, 3, 10, 3);
20 upperBodyParts[1]->texOffs(24, 22)->addBox(-4.f, 1.5f, .5f, 11, 2, 2);
21 upperBodyParts[1]->texOffs(24, 22)->addBox(-4.f, 4, .5f, 11, 2, 2);
22 upperBodyParts[1]->texOffs(24, 22)->addBox(-4.f, 6.5f, .5f, 11, 2, 2);
23
24 upperBodyParts[2] = new ModelPart(this, 12, 22);
25 upperBodyParts[2]->addBox(0, 0, 0, 3, 6, 3);
26
27 heads = ModelPartArray(3);
28 heads[0] = new ModelPart(this, 0, 0);
29 heads[0]->addBox(-4, -4, -4, 8, 8, 8);
30 heads[1] = new ModelPart(this, 32, 0);
31 heads[1]->addBox(-4, -4, -4, 6, 6, 6);
32 heads[1]->x = -8;
33 heads[1]->y = 4;
34 heads[2] = new ModelPart(this, 32, 0);
35 heads[2]->addBox(-4, -4, -4, 6, 6, 6);
36 heads[2]->x = 10;
37 heads[2]->y = 4;
38}
39
40int WitherBossModel::modelVersion()
41{
42 return 32;
43}
44
45void WitherBossModel::render(shared_ptr<Entity> entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled)
46{
47 setupAnim(time, r, bob, yRot, xRot, scale, entity);
48
49 for (int i = 0; i < heads.length; i++)
50 {
51 heads[i]->render(scale, usecompiled);
52 }
53 for (int i = 0; i < upperBodyParts.length; i++)
54 {
55 upperBodyParts[i]->render(scale, usecompiled);
56 }
57}
58
59void WitherBossModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, shared_ptr<Entity> entity, unsigned int uiBitmaskOverrideAnim)
60{
61 float anim = cos(bob * .1f);
62 upperBodyParts[1]->xRot = (.065f + .05f * anim) * PI;
63
64 upperBodyParts[2]->setPos(-2.f, 6.9f + cos(upperBodyParts[1]->xRot) * 10.f, -.5f + sin(upperBodyParts[1]->xRot) * 10.f);
65 upperBodyParts[2]->xRot = (.265f + .1f * anim) * PI;
66
67 heads[0]->yRot = yRot / (180 / PI);
68 heads[0]->xRot = xRot / (180 / PI);
69}
70
71void WitherBossModel::prepareMobModel(shared_ptr<LivingEntity> mob, float time, float r, float a)
72{
73 shared_ptr<WitherBoss> boss = dynamic_pointer_cast<WitherBoss>(mob);
74
75 for (int i = 1; i < 3; i++)
76 {
77 heads[i]->yRot = (boss->getHeadYRot(i - 1) - mob->yBodyRot) / (180 / PI);
78 heads[i]->xRot = boss->getHeadXRot(i - 1) / (180 / PI);
79 }
80}