Ender crystals
This commit is contained in:
parent
b370cacf0c
commit
2e28c09770
56
src/Entities/EnderCrystal.cpp
Normal file
56
src/Entities/EnderCrystal.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
|
||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||
|
||||
#include "EnderCrystal.h"
|
||||
#include "ClientHandle.h"
|
||||
#include "Player.h"
|
||||
#include "../Chunk.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cEnderCrystal::cEnderCrystal(double a_X, double a_Y, double a_Z)
|
||||
: cEntity(etEnderCrystal, a_X, a_Y, a_Z, 1.0, 1.0)
|
||||
{
|
||||
SetMaxHealth(5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cEnderCrystal::SpawnOn(cClientHandle & a_ClientHandle)
|
||||
{
|
||||
a_ClientHandle.SendSpawnObject(*this, 51, 0, (Byte)GetYaw(), (Byte)GetPitch());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cEnderCrystal::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
{
|
||||
UNUSED(a_Dt);
|
||||
|
||||
a_Chunk.SetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT, E_BLOCK_FIRE, 0);
|
||||
|
||||
// No further processing (physics e.t.c.) is needed
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cEnderCrystal::KilledBy(cEntity * a_Killer)
|
||||
{
|
||||
super::KilledBy(a_Killer);
|
||||
|
||||
m_World->DoExplosionAt(6.0, GetPosX(), GetPosY(), GetPosZ(), true, esEnderCrystal, this);
|
||||
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
33
src/Entities/EnderCrystal.h
Normal file
33
src/Entities/EnderCrystal.h
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Entity.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// tolua_begin
|
||||
class cEnderCrystal :
|
||||
public cEntity
|
||||
{
|
||||
// tolua_end
|
||||
typedef cEntity super;
|
||||
|
||||
public:
|
||||
CLASS_PROTODEF(cEnderCrystal);
|
||||
|
||||
cEnderCrystal(double a_X, double a_Y, double a_Z);
|
||||
|
||||
private:
|
||||
|
||||
// cEntity overrides:
|
||||
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
||||
virtual void KilledBy(cEntity * a_Killer) override;
|
||||
|
||||
}; // tolua_export
|
||||
|
||||
|
||||
|
||||
|
@ -69,6 +69,7 @@ public:
|
||||
enum eEntityType
|
||||
{
|
||||
etEntity, // For all other types
|
||||
etEnderCrystal,
|
||||
etPlayer,
|
||||
etPickup,
|
||||
etMonster,
|
||||
@ -130,6 +131,7 @@ public:
|
||||
|
||||
eEntityType GetEntityType(void) const { return m_EntityType; }
|
||||
|
||||
bool IsEnderCrystal(void) const { return (m_EntityType == etEnderCrystal); }
|
||||
bool IsPlayer (void) const { return (m_EntityType == etPlayer); }
|
||||
bool IsPickup (void) const { return (m_EntityType == etPickup); }
|
||||
bool IsMob (void) const { return (m_EntityType == etMonster); }
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "../BlockEntities/FlowerPotEntity.h"
|
||||
|
||||
#include "../Entities/Entity.h"
|
||||
#include "../Entities/EnderCrystal.h"
|
||||
#include "../Entities/FallingBlock.h"
|
||||
#include "../Entities/Boat.h"
|
||||
#include "../Entities/Minecart.h"
|
||||
@ -335,6 +336,17 @@ void cNBTChunkSerializer::AddBoatEntity(cBoat * a_Boat)
|
||||
|
||||
|
||||
|
||||
void cNBTChunkSerializer::AddEnderCrystalEntity(cEnderCrystal * a_EnderCrystal)
|
||||
{
|
||||
m_Writer.BeginCompound("");
|
||||
AddBasicEntity(a_EnderCrystal, "EnderCrystal");
|
||||
m_Writer.EndCompound();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cNBTChunkSerializer::AddFallingBlockEntity(cFallingBlock * a_FallingBlock)
|
||||
{
|
||||
m_Writer.BeginCompound("");
|
||||
@ -729,6 +741,7 @@ void cNBTChunkSerializer::Entity(cEntity * a_Entity)
|
||||
switch (a_Entity->GetEntityType())
|
||||
{
|
||||
case cEntity::etBoat: AddBoatEntity ((cBoat *) a_Entity); break;
|
||||
case cEntity::etEnderCrystal: AddEnderCrystalEntity((cEnderCrystal *) a_Entity); break;
|
||||
case cEntity::etFallingBlock: AddFallingBlockEntity((cFallingBlock *) a_Entity); break;
|
||||
case cEntity::etMinecart: AddMinecartEntity ((cMinecart *) a_Entity); break;
|
||||
case cEntity::etMonster: AddMonsterEntity ((cMonster *) a_Entity); break;
|
||||
|
@ -24,6 +24,7 @@ class cChestEntity;
|
||||
class cCommandBlockEntity;
|
||||
class cDispenserEntity;
|
||||
class cDropperEntity;
|
||||
class cEnderCrystal;
|
||||
class cFurnaceEntity;
|
||||
class cHopperEntity;
|
||||
class cJukeboxEntity;
|
||||
@ -106,6 +107,7 @@ protected:
|
||||
// Entities:
|
||||
void AddBasicEntity (cEntity * a_Entity, const AString & a_ClassName);
|
||||
void AddBoatEntity (cBoat * a_Boat);
|
||||
void AddEnderCrystalEntity(cEnderCrystal * a_EnderCrystal);
|
||||
void AddFallingBlockEntity(cFallingBlock * a_FallingBlock);
|
||||
void AddMinecartEntity (cMinecart * a_Minecart);
|
||||
void AddMonsterEntity (cMonster * a_Monster);
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "../Mobs/IncludeAllMonsters.h"
|
||||
|
||||
#include "../Entities/Boat.h"
|
||||
#include "../Entities/EnderCrystal.h"
|
||||
#include "../Entities/FallingBlock.h"
|
||||
#include "../Entities/Minecart.h"
|
||||
#include "../Entities/Pickup.h"
|
||||
@ -1057,6 +1058,10 @@ void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a
|
||||
{
|
||||
LoadBoatFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
|
||||
}
|
||||
else if (strncmp(a_IDTag, "EnderCrystal", a_IDTagLength) == 0)
|
||||
{
|
||||
LoadEnderCrystalFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
|
||||
}
|
||||
else if (strncmp(a_IDTag, "FallingBlock", a_IDTagLength) == 0)
|
||||
{
|
||||
LoadFallingBlockFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
|
||||
@ -1275,6 +1280,20 @@ void cWSSAnvil::LoadBoatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N
|
||||
|
||||
|
||||
|
||||
void cWSSAnvil::LoadEnderCrystalFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
|
||||
{
|
||||
std::auto_ptr<cEnderCrystal> EnderCrystal(new cEnderCrystal(0, 0, 0));
|
||||
if (!LoadEntityBaseFromNBT(*EnderCrystal.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
a_Entities.push_back(EnderCrystal.release());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cWSSAnvil::LoadFallingBlockFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
|
||||
{
|
||||
int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "TileID");
|
||||
|
@ -148,6 +148,7 @@ protected:
|
||||
void LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_EntityTagIdx, const char * a_IDTag, int a_IDTagLength);
|
||||
|
||||
void LoadBoatFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
|
||||
void LoadEnderCrystalFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
|
||||
void LoadFallingBlockFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
|
||||
void LoadPickupFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
|
||||
void LoadTNTFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
|
||||
|
Loading…
Reference in New Issue
Block a user