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 "WitherBossRenderer.h"
3#include "WitherBossModel.h"
4#include "MobRenderer.h"
5#include "../Minecraft.World/WitherBoss.h"
6#include "../Minecraft.Client/BossMobGuiInfo.h"
7
8ResourceLocation WitherBossRenderer::WITHER_ARMOR_LOCATION = ResourceLocation(TN_MOB_WITHER_ARMOR);
9ResourceLocation WitherBossRenderer::WITHER_INVULERABLE_LOCATION = ResourceLocation(TN_MOB_WITHER_INVULNERABLE);
10ResourceLocation WitherBossRenderer::WITHER_LOCATION = ResourceLocation(TN_MOB_WITHER);
11
12
13WitherBossRenderer::WitherBossRenderer() : MobRenderer(new WitherBossModel(), 1.0f)
14{
15 modelVersion = dynamic_cast<WitherBossModel*>(model)->modelVersion();
16}
17
18void WitherBossRenderer::render(shared_ptr<Entity> entity, double x, double y, double z, float rot, float a)
19{
20 shared_ptr<WitherBoss> mob = dynamic_pointer_cast<WitherBoss>(entity);
21
22 BossMobGuiInfo::setBossHealth(mob, true);
23
24 int modelVersion = dynamic_cast<WitherBossModel*>(model)->modelVersion();
25 if (modelVersion != this->modelVersion)
26 {
27 this->modelVersion = modelVersion;
28 model = new WitherBossModel();
29 }
30 MobRenderer::render(entity, x, y, z, rot, a);
31}
32
33ResourceLocation *WitherBossRenderer::getTextureLocation(shared_ptr<Entity> entity)
34{
35 shared_ptr<WitherBoss> mob = dynamic_pointer_cast<WitherBoss>(entity);
36
37 int invulnerableTicks = mob->getInvulnerableTicks();
38 if (invulnerableTicks <= 0 || ( (invulnerableTicks <= (SharedConstants::TICKS_PER_SECOND * 4)) && (invulnerableTicks / 5) % 2 == 1) )
39 {
40 return &WITHER_LOCATION;
41 }
42 return &WITHER_INVULERABLE_LOCATION;
43}
44
45void WitherBossRenderer::scale(shared_ptr<LivingEntity> _mob, float a)
46{
47 shared_ptr<WitherBoss> mob = dynamic_pointer_cast<WitherBoss>(_mob);
48 int inTicks = mob->getInvulnerableTicks();
49 if (inTicks > 0)
50 {
51 float scale = 2.0f - (((float) inTicks - a) / (SharedConstants::TICKS_PER_SECOND * 11)) * .5f;
52 glScalef(scale, scale, scale);
53 }
54 else
55 {
56 glScalef(2, 2, 2);
57 }
58}
59
60int WitherBossRenderer::prepareArmor(shared_ptr<LivingEntity> entity, int layer, float a)
61{
62 shared_ptr<WitherBoss> mob = dynamic_pointer_cast<WitherBoss>(entity);
63
64 if (mob->isPowered())
65 {
66 if (mob->isInvisible())
67 {
68 glDepthMask(false);
69 }
70 else
71 {
72 glDepthMask(true);
73 }
74
75 if (layer == 1)
76 {
77 float time = mob->tickCount + a;
78 bindTexture(&WITHER_ARMOR_LOCATION);
79 glMatrixMode(GL_TEXTURE);
80 glLoadIdentity();
81 float uo = cos(time * 0.02f) * 3;
82 float vo = time * 0.01f;
83 glTranslatef(uo, vo, 0);
84 setArmor(model);
85 glMatrixMode(GL_MODELVIEW);
86 glEnable(GL_BLEND);
87 float br = 0.5f;
88 glColor4f(br, br, br, 1);
89 glDisable(GL_LIGHTING);
90 glBlendFunc(GL_ONE, GL_ONE);
91 glTranslatef(0, -.01f, 0);
92 glScalef(1.1f, 1.1f, 1.1f);
93 return 1;
94 }
95 if (layer == 2)
96 {
97 glMatrixMode(GL_TEXTURE);
98 glLoadIdentity();
99 glMatrixMode(GL_MODELVIEW);
100 glEnable(GL_LIGHTING);
101 glDisable(GL_BLEND);
102 }
103 }
104 return -1;
105}
106
107int WitherBossRenderer::prepareArmorOverlay(shared_ptr<LivingEntity> entity, int layer, float a)
108{
109 return -1;
110}