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 "HorseRenderer.h"
3#include "MobRenderer.h"
4#include "EntityRenderDispatcher.h"
5#include "..\Minecraft.World\net.minecraft.world.entity.animal.h"
6
7ResourceLocation HorseRenderer::HORSE_LOCATION = ResourceLocation(TN_MOB_HORSE_WHITE);
8ResourceLocation HorseRenderer::HORSE_MULE_LOCATION = ResourceLocation(TN_MOB_MULE);
9ResourceLocation HorseRenderer::HORSE_DONKEY_LOCATION = ResourceLocation(TN_MOB_DONKEY);
10ResourceLocation HorseRenderer::HORSE_ZOMBIE_LOCATION = ResourceLocation(TN_MOB_HORSE_ZOMBIE);
11ResourceLocation HorseRenderer::HORSE_SKELETON_LOCATION = ResourceLocation(TN_MOB_HORSE_SKELETON);
12
13std::map<wstring, ResourceLocation *> HorseRenderer::LAYERED_LOCATION_CACHE;
14
15HorseRenderer::HorseRenderer(Model *model, float f) : MobRenderer(model, f)
16{
17}
18
19void HorseRenderer::adjustHeight(shared_ptr<PathfinderMob> mob, float FHeight)
20{
21 glTranslatef(0.0F, FHeight, 0.0F);
22}
23
24void HorseRenderer::scale(shared_ptr<LivingEntity> entityliving, float f)
25{
26 float sizeFactor = 1.0f;
27
28 int type = dynamic_pointer_cast<EntityHorse>(entityliving)->getType();
29 if (type == EntityHorse::TYPE_DONKEY)
30 {
31 sizeFactor *= 0.87F;
32 }
33 else if (type == EntityHorse::TYPE_MULE)
34 {
35 sizeFactor *= 0.92F;
36 }
37 glScalef(sizeFactor, sizeFactor, sizeFactor);
38 MobRenderer::scale(entityliving, f);
39}
40
41void HorseRenderer::renderModel(shared_ptr<LivingEntity> mob, float wp, float ws, float bob, float headRotMinusBodyRot, float headRotx, float scale)
42{
43 if (mob->isInvisible())
44 {
45 model->setupAnim(wp, ws, bob, headRotMinusBodyRot, headRotx, scale, mob);
46 }
47 else
48 {
49 EntityRenderer::bindTexture(mob);
50 model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale, true);
51 // Ensure that any extra layers of texturing are disabled after rendering this horse
52 RenderManager.TextureBind(-1);
53 }
54}
55
56void HorseRenderer::bindTexture(ResourceLocation *location)
57{
58 // Set up (potentially) multiple texture layers for the horse
59 entityRenderDispatcher->textures->bindTextureLayers(location);
60}
61
62ResourceLocation *HorseRenderer::getTextureLocation(shared_ptr<Entity> entity)
63{
64 shared_ptr<EntityHorse> horse = dynamic_pointer_cast<EntityHorse>(entity);
65
66 if (!horse->hasLayeredTextures())
67 {
68 switch (horse->getType())
69 {
70 default:
71 case EntityHorse::TYPE_HORSE: return &HORSE_LOCATION;
72 case EntityHorse::TYPE_MULE: return &HORSE_MULE_LOCATION;
73 case EntityHorse::TYPE_DONKEY: return &HORSE_DONKEY_LOCATION;
74 case EntityHorse::TYPE_UNDEAD: return &HORSE_ZOMBIE_LOCATION;
75 case EntityHorse::TYPE_SKELETON: return &HORSE_SKELETON_LOCATION;
76 }
77 }
78
79 return getOrCreateLayeredTextureLocation(horse);
80}
81
82ResourceLocation *HorseRenderer::getOrCreateLayeredTextureLocation(shared_ptr<EntityHorse> horse)
83{
84 wstring textureName = horse->getLayeredTextureHashName();
85
86 AUTO_VAR(it, LAYERED_LOCATION_CACHE.find(textureName));
87
88 ResourceLocation *location;
89 if (it != LAYERED_LOCATION_CACHE.end())
90 {
91 location = it->second;
92 }
93 else
94 {
95 LAYERED_LOCATION_CACHE[textureName] = new ResourceLocation(horse->getLayeredTextureLayers());
96
97 it = LAYERED_LOCATION_CACHE.find(textureName);
98 location = it->second;
99 }
100
101 return location;
102}