Files
MinecraftConsoles/Minecraft.Client/SlimeRenderer.cpp
ModMaker101 a9be52c41a Project modernization (#630)
* Fixed boats falling and a TP glitch #266

* Replaced every C-style cast with C++ ones

* Replaced every C-style cast with C++ ones

* Fixed boats falling and a TP glitch #266

* Updated NULL to nullptr and fixing some type issues

* Modernized and fixed a few bugs

- Replaced most instances of `NULL` with `nullptr`.
- Replaced most `shared_ptr(new ...)` with `make_shared`.
- Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances.

* Fixing more conflicts

* Replace int loops with size_t and start work on overrides
2026-03-08 09:56:03 +07:00

53 lines
1.4 KiB
C++

#include "stdafx.h"
#include "SlimeRenderer.h"
#include "..\Minecraft.World\net.minecraft.world.entity.monster.h"
ResourceLocation SlimeRenderer::SLIME_LOCATION = ResourceLocation(TN_MOB_SLIME);
SlimeRenderer::SlimeRenderer(Model *model, Model *armor, float shadow) : MobRenderer(model, shadow)
{
this->armor = armor;
}
int SlimeRenderer::prepareArmor(shared_ptr<LivingEntity> _slime, int layer, float a)
{
// 4J - dynamic cast required because we aren't using templates/generics in our version
shared_ptr<Slime> slime = dynamic_pointer_cast<Slime>(_slime);
if (slime->isInvisible())
{
return 0;
}
if (layer == 0)
{
setArmor(armor);
glEnable(GL_NORMALIZE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
return 1;
}
if (layer == 1)
{
glDisable(GL_BLEND);
glColor4f(1, 1, 1, 1);
}
return -1;
}
void SlimeRenderer::scale(shared_ptr<LivingEntity> _slime, float a)
{
// 4J - dynamic cast required because we aren't using templates/generics in our version
shared_ptr<Slime> slime = dynamic_pointer_cast<Slime>(_slime);
float size = static_cast<float>(slime->getSize());
float ss = (slime->oSquish + (slime->squish - slime->oSquish) * a) / (size * 0.5f + 1);
float w = 1 / (ss + 1);
glScalef(w * size, 1 / w * size, w * size);
}
ResourceLocation *SlimeRenderer::getTextureLocation(shared_ptr<Entity> mob)
{
return &SLIME_LOCATION;
}