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 "..\Minecraft.World\net.minecraft.world.entity.animal.h"
3#include "..\Minecraft.World\net.minecraft.world.level.tile.h"
4#include "VillagerGolemModel.h"
5#include "ModelPart.h"
6#include "TextureAtlas.h"
7#include "VillagerGolemRenderer.h"
8
9ResourceLocation VillagerGolemRenderer::GOLEM_LOCATION = ResourceLocation(TN_MOB_VILLAGER_GOLEM);
10
11VillagerGolemRenderer::VillagerGolemRenderer() : MobRenderer(new VillagerGolemModel(), 0.5f)
12{
13 golemModel = (VillagerGolemModel *) model;
14}
15
16void VillagerGolemRenderer::render(shared_ptr<Entity> mob, double x, double y, double z, float rot, float a)
17{
18 MobRenderer::render(mob, x, y, z, rot, a);
19}
20
21void VillagerGolemRenderer::setupRotations(shared_ptr<LivingEntity> _mob, float bob, float bodyRot, float a)
22{
23 // 4J - original version used generics and thus had an input parameter of type Blaze rather than shared_ptr<Entity> we have here -
24 // do some casting around instead
25 shared_ptr<VillagerGolem> mob = dynamic_pointer_cast<VillagerGolem>(_mob);
26 MobRenderer::setupRotations(mob, bob, bodyRot, a);
27 if (mob->walkAnimSpeed < 0.01) return;
28
29 float p = 13;
30 float wp = mob->walkAnimPos - mob->walkAnimSpeed * (1 - a) + 6;
31 float triangleWave = (abs(fmod(wp ,p) - p * 0.5f) - p * 0.25f) / (p * 0.25f);
32 glRotatef(6.5f * triangleWave, 0, 0, 1);
33}
34
35ResourceLocation *VillagerGolemRenderer::getTextureLocation(shared_ptr<Entity> mob)
36{
37 return &GOLEM_LOCATION;
38}
39
40void VillagerGolemRenderer::additionalRendering(shared_ptr<LivingEntity> _mob, float a)
41{
42 // 4J - original version used generics and thus had an input parameter of type Blaze rather than shared_ptr<Entity> we have here -
43 // do some casting around instead
44 shared_ptr<VillagerGolem> mob = dynamic_pointer_cast<VillagerGolem>(_mob);
45 MobRenderer::additionalRendering(mob, a);
46 if (mob->getOfferFlowerTick() == 0) return;
47
48 glEnable(GL_RESCALE_NORMAL);
49 glPushMatrix();
50
51 // dont ask me how I got the flower into his hand.
52 glRotatef(5 + 180 * golemModel->arm0->xRot / PI, 1, 0, 0);
53 glTranslatef(-11 / 16.0f, 20 / 16.0f, -15 / 16.0f);
54 glRotatef(90, 1, 0, 0);
55 float s = 0.8f;
56 glScalef(s, -s, s);
57
58 if (SharedConstants::TEXTURE_LIGHTING)
59 {
60 int col = mob->getLightColor(a);
61 int u = col % 65536;
62 int v = col / 65536;
63 glMultiTexCoord2f(GL_TEXTURE1, u / 1.0f, v / 1.0f);
64 glColor4f(1, 1, 1, 1);
65 }
66
67 glColor4f(1, 1, 1, 1);
68 bindTexture(&TextureAtlas::LOCATION_BLOCKS); // TODO: By Icon
69 tileRenderer->renderTile(Tile::rose, 0, 1);
70 glPopMatrix();
71 glDisable(GL_RESCALE_NORMAL);
72}