Files
MinecraftConsoles/Minecraft.Client/BoatRenderer.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

47 lines
1.3 KiB
C++

#include "stdafx.h"
#include "BoatRenderer.h"
#include "BoatModel.h"
#include "..\Minecraft.World\net.minecraft.world.entity.item.h"
#include "..\Minecraft.World\Mth.h"
ResourceLocation BoatRenderer::BOAT_LOCATION = ResourceLocation(TN_ITEM_BOAT);
BoatRenderer::BoatRenderer() : EntityRenderer()
{
this->shadowRadius = 0.5f;
model = new BoatModel();
}
void BoatRenderer::render(shared_ptr<Entity> _boat, double x, double y, double z, float rot, float a)
{
// 4J - original version used generics and thus had an input parameter of type Boat rather than shared_ptr<Entity> we have here -
// do some casting around instead
shared_ptr<Boat> boat = dynamic_pointer_cast<Boat>(_boat);
glPushMatrix();
glTranslatef(static_cast<float>(x), static_cast<float>(y), static_cast<float>(z));
glRotatef(180-rot, 0, 1, 0);
float hurt = boat->getHurtTime() - a;
float dmg = boat->getDamage() - a;
if (dmg<0) dmg = 0;
if (hurt>0)
{
glRotatef(Mth::sin(hurt)*hurt*dmg/10*boat->getHurtDir(), 1, 0, 0);
}
float ss = 12/16.0f;
glScalef(ss, ss, ss);
glScalef(1/ss, 1/ss, 1/ss);
bindTexture(boat);
glScalef(-1, -1, 1);
model->render(boat, 0, 0, -0.1f, 0, 0, 1 / 16.0f, true);
glPopMatrix();
}
ResourceLocation *BoatRenderer::getTextureLocation(shared_ptr<Entity> mob)
{
return &BOAT_LOCATION;
}