mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-24 11:53:36 +00:00
48 lines
1.7 KiB
C++
48 lines
1.7 KiB
C++
#include "EnderCrystalRenderer.h"
|
|
|
|
#include <cmath>
|
|
#include <memory>
|
|
|
|
#include "platform/renderer/renderer.h"
|
|
#include "minecraft/client/model/dragon/EnderCrystalModel.h"
|
|
#include "minecraft/client/model/geom/Model.h"
|
|
#include "minecraft/client/renderer/Textures.h"
|
|
#include "minecraft/client/resources/ResourceLocation.h"
|
|
#include "minecraft/world/entity/Entity.h"
|
|
#include "minecraft/world/entity/boss/enderdragon/EnderCrystal.h"
|
|
|
|
ResourceLocation EnderCrystalRenderer::ENDER_CRYSTAL_LOCATION =
|
|
ResourceLocation(TN_MOB_ENDERDRAGON_ENDERCRYSTAL);
|
|
|
|
EnderCrystalRenderer::EnderCrystalRenderer() {
|
|
currentModel = -1;
|
|
this->shadowRadius = 0.5f;
|
|
}
|
|
|
|
void EnderCrystalRenderer::render(std::shared_ptr<Entity> _crystal, double x,
|
|
double y, double z, float rot, float a) {
|
|
// 4J - original version used generics and thus had an input parameter of
|
|
// type EnderCrystal rather than shared_ptr<Entity> we have here - do some
|
|
// casting around instead
|
|
std::shared_ptr<EnderCrystal> crystal =
|
|
std::dynamic_pointer_cast<EnderCrystal>(_crystal);
|
|
if (currentModel != EnderCrystalModel::MODEL_ID) {
|
|
model = new EnderCrystalModel(0);
|
|
currentModel = EnderCrystalModel::MODEL_ID;
|
|
}
|
|
|
|
float tt = crystal->time + a;
|
|
glPushMatrix();
|
|
glTranslatef((float)x, (float)y, (float)z);
|
|
bindTexture(&ENDER_CRYSTAL_LOCATION);
|
|
float hh = sin(tt * 0.2f) / 2 + 0.5f;
|
|
hh = hh * hh + hh;
|
|
model->render(crystal, 0, tt * 3, hh * 0.2f, 0, 0, 1 / 16.0f, true);
|
|
|
|
glPopMatrix();
|
|
}
|
|
|
|
ResourceLocation* EnderCrystalRenderer::getTextureLocation(
|
|
std::shared_ptr<Entity> mob) {
|
|
return &ENDER_CRYSTAL_LOCATION;
|
|
} |