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 "WitherSkullRenderer.h"
3#include "SkeletonHeadModel.h"
4#include "../Minecraft.World/WitherSkull.h"
5
6ResourceLocation WitherSkullRenderer::WITHER_ARMOR_LOCATION(TN_MOB_WITHER_INVULNERABLE);
7ResourceLocation WitherSkullRenderer::WITHER_LOCATION(TN_MOB_WITHER);
8
9WitherSkullRenderer::WitherSkullRenderer()
10{
11 model = new SkeletonHeadModel();
12}
13
14void WitherSkullRenderer::render(shared_ptr<Entity> entity, double x, double y, double z, float rot, float a)
15{
16 glPushMatrix();
17 glDisable(GL_CULL_FACE);
18
19 float headRot = rotlerp(entity->yRotO, entity->yRot, a);
20 float headRotx = entity->xRotO + (entity->xRot - entity->xRotO) * a;
21
22 glTranslatef((float) x, (float) y, (float) z);
23
24 float scale = 1 / 16.0f;
25 glEnable(GL_RESCALE_NORMAL);
26 glScalef(-1, -1, 1);
27
28 glEnable(GL_ALPHA_TEST);
29
30 bindTexture(entity);
31
32 model->render(entity, 0, 0, 0, headRot, headRotx, scale, true);
33
34 glPopMatrix();
35}
36
37ResourceLocation *WitherSkullRenderer::getTextureLocation(shared_ptr<Entity> entity)
38{
39 shared_ptr<WitherSkull> mob = dynamic_pointer_cast<WitherSkull>(entity);
40
41 return mob->isDangerous() ? &WITHER_ARMOR_LOCATION : &WITHER_LOCATION;
42}
43
44float WitherSkullRenderer::rotlerp(float from, float to, float a)
45{
46 float diff = to - from;
47 while (diff < -180)
48 diff += 360;
49 while (diff >= 180)
50 diff -= 360;
51 return from + a * diff;
52}