#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_LOCATIONS[6] = { ResourceLocation(TN_ITEM_BOAT_OAK), ResourceLocation(TN_ITEM_BOAT_SPRUCE), ResourceLocation(TN_ITEM_BOAT_BIRCH), ResourceLocation(TN_ITEM_BOAT_JUNGLE), ResourceLocation(TN_ITEM_BOAT_ACACIA), ResourceLocation(TN_ITEM_BOAT_DARKOAK), }; bool BoatRenderer::s_secondPass = false; BoatRenderer::BoatRenderer() : EntityRenderer() { this->shadowRadius = 0.5f; model = new BoatModel(); } void BoatRenderer::render(shared_ptr _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 we have here - // do some casting around instead shared_ptr boat = dynamic_pointer_cast(_boat); const float hullOffset = 0.375f - boat->heightOffset; if (s_secondPass) { glPushMatrix(); glTranslatef(static_cast(x), static_cast(y) + hullOffset, static_cast(z)); glRotatef(180-rot, 0, 1, 0); glScalef(-1, -1, 1); static_cast(model)->renderWaterPatch(1 / 16.0f, true); glPopMatrix(); return; } glPushMatrix(); glTranslatef(static_cast(x), static_cast(y) + hullOffset, static_cast(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); } bindTexture(boat); glScalef(-1, -1, 1); model->render(boat, a, 0, -0.1f, 0, 0, 1 / 16.0f, true); glPopMatrix(); } ResourceLocation *BoatRenderer::getTextureLocation(shared_ptr mob) { shared_ptr boat = dynamic_pointer_cast(mob); return &BOAT_LOCATIONS[boat != nullptr ? boat->getType() : 0]; } void BoatRenderer::postRender(shared_ptr entity, double x, double y, double z, float rot, float a, bool bRenderPlayerShadow) { if (s_secondPass) return; EntityRenderer::postRender(entity, x, y, z, rot, a, bRenderPlayerShadow); }