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 "EndermanRenderer.h"
3#include "EndermanModel.h"
4#include "TextureAtlas.h"
5#include "..\Minecraft.World\net.minecraft.world.entity.monster.h"
6#include "..\Minecraft.World\net.minecraft.world.level.tile.h"
7
8ResourceLocation EndermanRenderer::ENDERMAN_EYES_LOCATION = ResourceLocation(TN_MOB_ENDERMAN_EYES);
9ResourceLocation EndermanRenderer::ENDERMAN_LOCATION = ResourceLocation(TN_MOB_ENDERMAN);
10
11EndermanRenderer::EndermanRenderer() : MobRenderer(new EndermanModel(), 0.5f)
12{
13 model = (EndermanModel *) MobRenderer::model;
14 this->setArmor(model);
15}
16
17void EndermanRenderer::render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a)
18{
19 // 4J - original version used generics and thus had an input parameter of type Boat rather than shared_ptr<Entity> we have here -
20 // do some casting around instead
21 shared_ptr<EnderMan> mob = dynamic_pointer_cast<EnderMan>(_mob);
22
23 model->carrying = mob->getCarryingTile() > 0;
24 model->creepy = mob->isCreepy();
25
26 if (mob->isCreepy())
27 {
28 double d = 0.02;
29 x += random.nextGaussian() * d;
30 z += random.nextGaussian() * d;
31 }
32
33 MobRenderer::render(mob, x, y, z, rot, a);
34}
35
36ResourceLocation *EndermanRenderer::getTextureLocation(shared_ptr<Entity> mob)
37{
38 return &ENDERMAN_LOCATION;
39}
40
41void EndermanRenderer::additionalRendering(shared_ptr<LivingEntity> _mob, float a)
42{
43 // 4J - original version used generics and thus had an input parameter of type Boat rather than shared_ptr<Entity> we have here -
44 // do some casting around instead
45 shared_ptr<EnderMan> mob = dynamic_pointer_cast<EnderMan>(_mob);
46
47 MobRenderer::additionalRendering(_mob, a);
48
49 if (mob->getCarryingTile() > 0)
50 {
51 glEnable(GL_RESCALE_NORMAL);
52 glPushMatrix();
53
54 float s = 8 / 16.0f;
55 glTranslatef(-0 / 16.0f, 11 / 16.0f, -12 / 16.0f);
56 s *= 1.00f;
57 glRotatef(20, 1, 0, 0);
58 glRotatef(45, 0, 1, 0);
59 glScalef(-s, -s, s);
60
61
62 if (SharedConstants::TEXTURE_LIGHTING)
63 {
64 int col = mob->getLightColor(a);
65 int u = col % 65536;
66 int v = col / 65536;
67
68 glMultiTexCoord2f(GL_TEXTURE1, u / 1.0f, v / 1.0f);
69 glColor4f(1, 1, 1, 1);
70 }
71
72 glColor4f(1, 1, 1, 1);
73 bindTexture(&TextureAtlas::LOCATION_BLOCKS); // TODO: bind by icon
74 tileRenderer->renderTile(Tile::tiles[mob->getCarryingTile()], mob->getCarryingData(), 1);
75 glPopMatrix();
76 glDisable(GL_RESCALE_NORMAL);
77 }
78}
79
80int EndermanRenderer::prepareArmor(shared_ptr<LivingEntity> _mob, int layer, float a)
81{
82 // 4J - original version used generics and thus had an input parameter of type Boat rather than shared_ptr<Entity> we have here -
83 // do some casting around instead
84 shared_ptr<EnderMan> mob = dynamic_pointer_cast<EnderMan>(_mob);
85
86 if (layer != 0) return -1;
87
88 bindTexture(&ENDERMAN_EYES_LOCATION); // 4J was L"/mob/enderman_eyes.png"
89 float br = 1;
90 glEnable(GL_BLEND);
91 // 4J Stu - We probably don't need to do this on 360 either (as we force it back on the renderer)
92 // However we do want it off for other platforms that don't force it on in the render lib CBuff handling
93 // Several texture packs have fully transparent bits that break if this is off
94#ifdef _XBOX
95 glDisable(GL_ALPHA_TEST);
96#endif
97 glBlendFunc(GL_ONE, GL_ONE);
98 glDisable(GL_LIGHTING);
99
100 if (mob->isInvisible())
101 {
102 glDepthMask(false);
103 }
104 else
105 {
106 glDepthMask(true);
107 }
108
109 if (SharedConstants::TEXTURE_LIGHTING)
110 {
111 int col = 0xf0f0;
112 int u = col % 65536;
113 int v = col / 65536;
114
115 glMultiTexCoord2f(GL_TEXTURE1, u / 1.0f, v / 1.0f);
116 glColor4f(1, 1, 1, 1);
117 }
118
119 glEnable(GL_LIGHTING);
120 glColor4f(1, 1, 1, br);
121 return 1;
122}