1
0
Fork 0
cuberite-2a/src/Mobs/Guardian.cpp

57 lines
1.3 KiB
C++
Raw Permalink Normal View History

2014-12-18 18:30:32 +00:00
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Guardian.h"
#include "../Chunk.h"
cGuardian::cGuardian(void) :
2021-04-06 15:09:16 +00:00
Super("Guardian", mtGuardian, "entity.guardian.hurt", "entity.guardian.death", "entity.guardian.ambient", 0.85f, 0.85f)
2014-12-18 18:30:32 +00:00
{
}
void cGuardian::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
// Drops 0-3 Ink Sacs
unsigned int LootingLevel = 0;
2014-12-18 18:30:32 +00:00
if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_PRISMARINE_SHARD);
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_RAW_FISH);
2014-12-24 23:44:09 +00:00
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_PRISMARINE_CRYSTALS); // TODO: Prismarine Crystals only drop if the raw fish drop is 0
2014-12-18 18:30:32 +00:00
}
void cGuardian::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
2014-12-18 18:30:32 +00:00
{
m_PathfinderActivated = false; // Disable Pathfinding until it's fixed. TODO
2014-12-18 18:30:32 +00:00
// We must first process current location, and only then tick, otherwise we risk processing a location in a chunk
// that is not where the entity currently resides (FS #411)
Vector3d Pos = GetPosition();
2015-05-28 11:29:26 +00:00
int RelY = FloorC(Pos.y);
2014-12-18 18:30:32 +00:00
if ((RelY < 0) || (RelY >= cChunkDef::Height))
{
return;
}
2020-04-13 16:38:06 +00:00
Super::Tick(a_Dt, a_Chunk);
2014-12-18 18:30:32 +00:00
}