From b3feddfef372618c8a9d7a0abcaf18cfad866c18 Mon Sep 17 00:00:00 2001 From: daoge <3523206925@qq.com> Date: Tue, 3 Mar 2026 03:04:10 +0800 Subject: feat: TU19 (Dec 2014) Features & Content (#155) * try to resolve merge conflict * feat: TU19 (Dec 2014) Features & Content (#32) * December 2014 files * Working release build * Fix compilation issues * Add sound to Windows64Media * Add DLC content and force Tutorial DLC * Revert "Add DLC content and force Tutorial DLC" This reverts commit 97a43994725008e35fceb984d5549df9c8cea470. * Disable broken light packing * Disable breakpoint during DLC texture map load Allows DLC loading but the DLC textures are still broken * Fix post build not working * ... * fix vs2022 build * fix cmake build --------- Co-authored-by: Loki --- Minecraft.Client/HorseRenderer.cpp | 102 +++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 Minecraft.Client/HorseRenderer.cpp (limited to 'Minecraft.Client/HorseRenderer.cpp') diff --git a/Minecraft.Client/HorseRenderer.cpp b/Minecraft.Client/HorseRenderer.cpp new file mode 100644 index 00000000..006f9e20 --- /dev/null +++ b/Minecraft.Client/HorseRenderer.cpp @@ -0,0 +1,102 @@ +#include "stdafx.h" +#include "HorseRenderer.h" +#include "MobRenderer.h" +#include "EntityRenderDispatcher.h" +#include "..\Minecraft.World\net.minecraft.world.entity.animal.h" + +ResourceLocation HorseRenderer::HORSE_LOCATION = ResourceLocation(TN_MOB_HORSE_WHITE); +ResourceLocation HorseRenderer::HORSE_MULE_LOCATION = ResourceLocation(TN_MOB_MULE); +ResourceLocation HorseRenderer::HORSE_DONKEY_LOCATION = ResourceLocation(TN_MOB_DONKEY); +ResourceLocation HorseRenderer::HORSE_ZOMBIE_LOCATION = ResourceLocation(TN_MOB_HORSE_ZOMBIE); +ResourceLocation HorseRenderer::HORSE_SKELETON_LOCATION = ResourceLocation(TN_MOB_HORSE_SKELETON); + +std::map HorseRenderer::LAYERED_LOCATION_CACHE; + +HorseRenderer::HorseRenderer(Model *model, float f) : MobRenderer(model, f) +{ +} + +void HorseRenderer::adjustHeight(shared_ptr mob, float FHeight) +{ + glTranslatef(0.0F, FHeight, 0.0F); +} + +void HorseRenderer::scale(shared_ptr entityliving, float f) +{ + float sizeFactor = 1.0f; + + int type = dynamic_pointer_cast(entityliving)->getType(); + if (type == EntityHorse::TYPE_DONKEY) + { + sizeFactor *= 0.87F; + } + else if (type == EntityHorse::TYPE_MULE) + { + sizeFactor *= 0.92F; + } + glScalef(sizeFactor, sizeFactor, sizeFactor); + MobRenderer::scale(entityliving, f); +} + +void HorseRenderer::renderModel(shared_ptr mob, float wp, float ws, float bob, float headRotMinusBodyRot, float headRotx, float scale) +{ + if (mob->isInvisible()) + { + model->setupAnim(wp, ws, bob, headRotMinusBodyRot, headRotx, scale, mob); + } + else + { + EntityRenderer::bindTexture(mob); + model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale, true); + // Ensure that any extra layers of texturing are disabled after rendering this horse + RenderManager.TextureBind(-1); + } +} + +void HorseRenderer::bindTexture(ResourceLocation *location) +{ + // Set up (potentially) multiple texture layers for the horse + entityRenderDispatcher->textures->bindTextureLayers(location); +} + +ResourceLocation *HorseRenderer::getTextureLocation(shared_ptr entity) +{ + shared_ptr horse = dynamic_pointer_cast(entity); + + if (!horse->hasLayeredTextures()) + { + switch (horse->getType()) + { + default: + case EntityHorse::TYPE_HORSE: return &HORSE_LOCATION; + case EntityHorse::TYPE_MULE: return &HORSE_MULE_LOCATION; + case EntityHorse::TYPE_DONKEY: return &HORSE_DONKEY_LOCATION; + case EntityHorse::TYPE_UNDEAD: return &HORSE_ZOMBIE_LOCATION; + case EntityHorse::TYPE_SKELETON: return &HORSE_SKELETON_LOCATION; + } + } + + return getOrCreateLayeredTextureLocation(horse); +} + +ResourceLocation *HorseRenderer::getOrCreateLayeredTextureLocation(shared_ptr horse) +{ + wstring textureName = horse->getLayeredTextureHashName(); + + AUTO_VAR(it, LAYERED_LOCATION_CACHE.find(textureName)); + + ResourceLocation *location; + if (it != LAYERED_LOCATION_CACHE.end()) + { + location = it->second; + } + else + { + LAYERED_LOCATION_CACHE[textureName] = new ResourceLocation(horse->getLayeredTextureLayers()); + + it = LAYERED_LOCATION_CACHE.find(textureName); + location = it->second; + } + + return location; +} \ No newline at end of file -- cgit v1.2.3