aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/LavaSlime.cpp
blob: 21982995dd96280a8ab37c0acb27a70807c4b226 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include "stdafx.h"
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.h"
#include "net.minecraft.world.entity.ai.attributes.h"
#include "net.minecraft.world.entity.monster.h"
#include "net.minecraft.world.item.h"
#include "..\Minecraft.Client\Textures.h"
#include "LavaSlime.h"
#include "SoundTypes.h"



LavaSlime::LavaSlime(Level *level) : Slime(level)
{
	// 4J Stu - This function call had to be moved here from the Entity ctor to ensure that
	// the derived version of the function is called
	// 4J Stu - The Slime ctor has already called this, and as we don't override it here don't need to call it
	//this->defineSynchedData();
	registerAttributes();

	fireImmune = true;
}

void LavaSlime::registerAttributes()
{
	Slime::registerAttributes();

	getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->setBaseValue(0.2f);
}

bool LavaSlime::canSpawn()
{
	return level->difficulty > Difficulty::PEACEFUL && level->isUnobstructed(bb) && level->getCubes(shared_from_this(), bb)->empty() && !level->containsAnyLiquid(bb);
}

int LavaSlime::getArmorValue()
{
	return getSize() * 3;
}

int LavaSlime::getLightColor(float a)
{
	return 15 << 20 | 15 << 4;
}

float LavaSlime::getBrightness(float a)
{
	return 1.0f;
}

ePARTICLE_TYPE LavaSlime::getParticleName()
{
	return eParticleType_flame;
}

shared_ptr<Slime> LavaSlime::createChild()
{
	return shared_ptr<LavaSlime>( new LavaSlime(level) );
}

int LavaSlime::getDeathLoot()
{
	// 4J-PB - brought forward the magma cream drops
	return Item::magmaCream_Id;
}

void LavaSlime::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel)
{
	int loot = getDeathLoot();
	if (loot > 0 && getSize() > 1)
	{
		int count = random->nextInt(4) - 2;
		if (playerBonusLevel > 0)
		{
			count += random->nextInt(playerBonusLevel + 1);
		}
		for (int i = 0; i < count; i++)
		{
			spawnAtLocation(loot, 1);
		}
	}
}

bool LavaSlime::isOnFire()
{
	return false;
}


int LavaSlime::getJumpDelay()
{
	return Slime::getJumpDelay() * 4;
}

void LavaSlime::decreaseSquish()
{
	targetSquish = targetSquish * 0.90f;
}

void LavaSlime::jumpFromGround()
{
	yd = 0.42f + getSize() * .1f;
	hasImpulse = true;
}

void LavaSlime::causeFallDamage(float distance)
{
}

bool LavaSlime::isDealsDamage()
{
	return true;
}

int LavaSlime::getAttackDamage()
{
	return Slime::getAttackDamage() + 2;
}

int LavaSlime::getHurtSound()
{
	return getSize() > 1 ? eSoundType_MOB_SLIME_BIG : eSoundType_MOB_SLIME_SMALL;
}

int LavaSlime::getDeathSound()
{
	return getSize() > 1 ? eSoundType_MOB_SLIME_BIG : eSoundType_MOB_SLIME_SMALL;
}

int LavaSlime::getSquishSound()
{
	if (getSize() > 1)
	{
		return eSoundType_MOB_MAGMACUBE_BIG;
	}
	return eSoundType_MOB_MAGMACUBE_SMALL;
}

bool LavaSlime::isInLava()
{
	// hack that makes the lava slimes move freely on the bottom of the lava
	// oceans
	return false;
}

bool LavaSlime::doPlayLandSound()
{
	return true;
}