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 "CreeperRenderer.h"
3#include "CreeperModel.h"
4#include "..\Minecraft.World\net.minecraft.world.entity.monster.h"
5#include "..\Minecraft.World\Mth.h"
6
7ResourceLocation CreeperRenderer::POWER_LOCATION = ResourceLocation(TN_POWERED_CREEPER);
8ResourceLocation CreeperRenderer::CREEPER_LOCATION = ResourceLocation(TN_MOB_CREEPER);
9
10CreeperRenderer::CreeperRenderer() : MobRenderer(new CreeperModel(), 0.5f)
11{
12 armorModel = new CreeperModel(2);
13}
14
15void CreeperRenderer::scale(shared_ptr<LivingEntity> mob, float a)
16{
17 shared_ptr<Creeper> creeper = dynamic_pointer_cast<Creeper>(mob);
18
19 float g = creeper->getSwelling(a);
20
21 float wobble = 1.0f + Mth::sin(g * 100) * g * 0.01f;
22 if (g < 0) g = 0;
23 if (g > 1) g = 1;
24 g = g * g;
25 g = g * g;
26 float s = (1.0f + g * 0.4f) * wobble;
27 float hs = (1.0f + g * 0.1f) / wobble;
28 glScalef(s, hs, s);
29}
30
31int CreeperRenderer::getOverlayColor(shared_ptr<LivingEntity> mob, float br, float a)
32{
33 shared_ptr<Creeper> creeper = dynamic_pointer_cast<Creeper>(mob);
34
35 float step = creeper->getSwelling(a);
36
37 if ((int) (step * 10) % 2 == 0) return 0;
38
39 int _a = (int) (step * 0.2f * 255) + 25; // 4J - added 25 here as our entities are rendered with alpha test still enabled, and so anything less is invisible
40 if (_a < 0) _a = 0;
41 if (_a > 255) _a = 255;
42
43 int r = 255;
44 int g = 255;
45 int b = 255;
46
47 return (_a << 24) | (r << 16) | (g << 8) | b;
48}
49
50int CreeperRenderer::prepareArmor(shared_ptr<LivingEntity> _mob, int layer, float a)
51{
52 // 4J - dynamic cast required because we aren't using templates/generics in our version
53 shared_ptr<Creeper> mob = dynamic_pointer_cast<Creeper>(_mob);
54 if (mob->isPowered())
55 {
56 if (mob->isInvisible()) glDepthMask(false);
57 else glDepthMask(true);
58
59 if (layer == 1)
60 {
61 float time = mob->tickCount + a;
62 bindTexture(&POWER_LOCATION);
63 glMatrixMode(GL_TEXTURE);
64 glLoadIdentity();
65 float uo = time * 0.01f;
66 float vo = time * 0.01f;
67 glTranslatef(uo, vo, 0);
68 setArmor(armorModel);
69 glMatrixMode(GL_MODELVIEW);
70 glEnable(GL_BLEND);
71 float br = 0.5f;
72 glColor4f(br, br, br, 1);
73 glDisable(GL_LIGHTING);
74 glBlendFunc(GL_ONE, GL_ONE);
75 return 1;
76 }
77 if (layer == 2)
78 {
79 glMatrixMode(GL_TEXTURE);
80 glLoadIdentity();
81 glMatrixMode(GL_MODELVIEW);
82 glEnable(GL_LIGHTING);
83 glDisable(GL_BLEND);
84 }
85 }
86 return -1;
87
88}
89
90int CreeperRenderer::prepareArmorOverlay(shared_ptr<LivingEntity> mob, int layer, float a)
91{
92 return -1;
93}
94
95ResourceLocation *CreeperRenderer::getTextureLocation(shared_ptr<Entity> mob)
96{
97 return &CREEPER_LOCATION;
98}