aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/BatRenderer.cpp
blob: 97c6412d7a479848f5eda98c4d806a22f08f442a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "stdafx.h"
#include "..\Minecraft.World\net.minecraft.world.entity.ambient.h"
#include "BatRenderer.h"
#include "BatModel.h"

ResourceLocation BatRenderer::BAT_LOCATION = ResourceLocation(TN_MOB_BAT);

BatRenderer::BatRenderer() : MobRenderer(new BatModel(), 0.25f)
{
	modelVersion = static_cast<BatModel *>(model)->modelVersion();
}

void BatRenderer::render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a)
{
	int modelVersion = (dynamic_cast<BatModel*>(model))->modelVersion();
	if (modelVersion != this->modelVersion) {
		this->modelVersion = modelVersion;
		model = new BatModel();
	}
	MobRenderer::render(_mob, x, y, z, rot, a);
}

ResourceLocation *BatRenderer::getTextureLocation(shared_ptr<Entity> mob)
{
	return &BAT_LOCATION;
}

void BatRenderer::scale(shared_ptr<LivingEntity> mob, float a)
{
	glScalef(.35f, .35f, .35f);
}

void BatRenderer::setupPosition(shared_ptr<LivingEntity> mob, double x, double y, double z)
{
	MobRenderer::setupPosition(mob, x, y, z);
}

void BatRenderer::setupRotations(shared_ptr<LivingEntity> _mob, float bob, float bodyRot, float a)
{
	shared_ptr<Bat> mob = dynamic_pointer_cast<Bat>(_mob);
	if (!mob->isResting())
	{
		glTranslatef(0, cos(bob * .3f) * .1f, 0);
	}
	else
	{
		glTranslatef(0, -.1f, 0);
	}
	MobRenderer::setupRotations(mob, bob, bodyRot, a);
}