From 8b028c5c78e53c149dfa8b3e7ec878f7f0428f1d Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 18 Nov 2014 15:33:41 +0100 Subject: Finished mob spawner implementation. --- src/BlockEntities/BeaconEntity.h | 10 +--------- src/BlockEntities/BlockEntity.h | 5 ----- src/BlockEntities/ChestEntity.h | 5 ----- src/BlockEntities/CommandBlockEntity.h | 8 -------- src/BlockEntities/DropSpenserEntity.h | 4 ---- src/BlockEntities/FlowerPotEntity.h | 10 ---------- src/BlockEntities/FurnaceEntity.h | 5 ----- src/BlockEntities/JukeboxEntity.h | 9 --------- src/BlockEntities/MobHeadEntity.h | 8 -------- src/BlockEntities/MobSpawnerEntity.cpp | 33 ++++----------------------------- src/BlockEntities/MobSpawnerEntity.h | 19 +++++-------------- src/BlockEntities/NoteEntity.h | 6 ------ src/BlockEntities/SignEntity.h | 9 --------- 13 files changed, 10 insertions(+), 121 deletions(-) (limited to 'src/BlockEntities') diff --git a/src/BlockEntities/BeaconEntity.h b/src/BlockEntities/BeaconEntity.h index d1db3a68f..783e04fe2 100644 --- a/src/BlockEntities/BeaconEntity.h +++ b/src/BlockEntities/BeaconEntity.h @@ -1,3 +1,4 @@ + // BeaconEntity.h // Declares the cBeaconEntity class representing a single beacon in the world @@ -14,15 +15,6 @@ -namespace Json -{ - class Value; -} - - - - - // tolua_begin class cBeaconEntity : public cBlockEntityWithItems diff --git a/src/BlockEntities/BlockEntity.h b/src/BlockEntities/BlockEntity.h index c778e97bc..056a88721 100644 --- a/src/BlockEntities/BlockEntity.h +++ b/src/BlockEntities/BlockEntity.h @@ -28,11 +28,6 @@ -namespace Json -{ - class Value; -}; - class cChunk; class cPlayer; class cWorld; diff --git a/src/BlockEntities/ChestEntity.h b/src/BlockEntities/ChestEntity.h index 09fffb923..a8a765430 100644 --- a/src/BlockEntities/ChestEntity.h +++ b/src/BlockEntities/ChestEntity.h @@ -7,11 +7,6 @@ -namespace Json -{ - class Value; -}; - class cClientHandle; diff --git a/src/BlockEntities/CommandBlockEntity.h b/src/BlockEntities/CommandBlockEntity.h index 217390293..8b5a2b87f 100644 --- a/src/BlockEntities/CommandBlockEntity.h +++ b/src/BlockEntities/CommandBlockEntity.h @@ -15,14 +15,6 @@ -namespace Json -{ - class Value; -} - - - - // tolua_begin diff --git a/src/BlockEntities/DropSpenserEntity.h b/src/BlockEntities/DropSpenserEntity.h index f77a28c28..8ce7f8bb8 100644 --- a/src/BlockEntities/DropSpenserEntity.h +++ b/src/BlockEntities/DropSpenserEntity.h @@ -16,10 +16,6 @@ -namespace Json -{ - class Value; -} class cClientHandle; diff --git a/src/BlockEntities/FlowerPotEntity.h b/src/BlockEntities/FlowerPotEntity.h index fc886c51f..e98d0a395 100644 --- a/src/BlockEntities/FlowerPotEntity.h +++ b/src/BlockEntities/FlowerPotEntity.h @@ -15,16 +15,6 @@ - -namespace Json -{ - class Value; -} - - - - - // tolua_begin class cFlowerPotEntity : diff --git a/src/BlockEntities/FurnaceEntity.h b/src/BlockEntities/FurnaceEntity.h index 71c2fe127..0a66c60e3 100644 --- a/src/BlockEntities/FurnaceEntity.h +++ b/src/BlockEntities/FurnaceEntity.h @@ -8,11 +8,6 @@ -namespace Json -{ - class Value; -} - class cClientHandle; diff --git a/src/BlockEntities/JukeboxEntity.h b/src/BlockEntities/JukeboxEntity.h index 7a69d6499..67a8aa62a 100644 --- a/src/BlockEntities/JukeboxEntity.h +++ b/src/BlockEntities/JukeboxEntity.h @@ -7,15 +7,6 @@ -namespace Json -{ - class Value; -} - - - - - // tolua_begin class cJukeboxEntity : diff --git a/src/BlockEntities/MobHeadEntity.h b/src/BlockEntities/MobHeadEntity.h index 7132ef558..55e45f0a6 100644 --- a/src/BlockEntities/MobHeadEntity.h +++ b/src/BlockEntities/MobHeadEntity.h @@ -14,14 +14,6 @@ -namespace Json -{ - class Value; -} - - - - // tolua_begin diff --git a/src/BlockEntities/MobSpawnerEntity.cpp b/src/BlockEntities/MobSpawnerEntity.cpp index 0d14ad647..696a109d1 100644 --- a/src/BlockEntities/MobSpawnerEntity.cpp +++ b/src/BlockEntities/MobSpawnerEntity.cpp @@ -2,7 +2,6 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "MobSpawnerEntity.h" -#include "json/json.h" #include "../World.h" #include "../FastRandom.h" @@ -38,8 +37,8 @@ void cMobSpawnerEntity::UsedBy(cPlayer * a_Player) { if (a_Player->GetEquippedItem().m_ItemType == E_ITEM_SPAWN_EGG) { - cMonster::eType MonsterType = cItemSpawnEggHandler::ItemDamageToMonsterType(a_Player->GetEquippedItem().m_ItemDamage); - if (MonsterType == mtInvalidType) + eMonsterType MonsterType = cItemSpawnEggHandler::ItemDamageToMonsterType(a_Player->GetEquippedItem().m_ItemDamage); + if (MonsterType == eMonsterType::mtInvalidType) { return; } @@ -50,7 +49,7 @@ void cMobSpawnerEntity::UsedBy(cPlayer * a_Player) { a_Player->GetInventory().RemoveOneEquippedItem(); } - LOGD("Changed monster spawner entity to %s!", GetEntityName().c_str()); + LOGD("Changed monster spawner at {%d, %d, %d} to type %s.", GetPosX(), GetPosY(), GetPosZ(), GetEntityName().c_str()); } } @@ -105,7 +104,7 @@ bool cMobSpawnerEntity::Tick(float a_Dt, cChunk & a_Chunk) void cMobSpawnerEntity::ResetTimer(void) { - m_SpawnDelay = 200 + m_World->GetTickRandomNumber(600); + m_SpawnDelay = (short) (200 + m_World->GetTickRandomNumber(600)); m_World->BroadcastBlockEntity(m_PosX, m_PosY, m_PosZ); } @@ -196,30 +195,6 @@ void cMobSpawnerEntity::SpawnEntity(void) -bool cMobSpawnerEntity::LoadFromJson(const Json::Value & a_Value) -{ - m_PosX = a_Value.get("x", 0).asInt(); - m_PosY = a_Value.get("y", 0).asInt(); - m_PosZ = a_Value.get("z", 0).asInt(); - - return true; -} - - - - - -void cMobSpawnerEntity::SaveToJson(Json::Value & a_Value) -{ - a_Value["x"] = m_PosX; - a_Value["y"] = m_PosY; - a_Value["z"] = m_PosZ; -} - - - - - AString cMobSpawnerEntity::GetEntityName() const { switch (m_Entity) diff --git a/src/BlockEntities/MobSpawnerEntity.h b/src/BlockEntities/MobSpawnerEntity.h index 7fec2699c..073eb03ab 100644 --- a/src/BlockEntities/MobSpawnerEntity.h +++ b/src/BlockEntities/MobSpawnerEntity.h @@ -8,15 +8,6 @@ -namespace Json -{ - class Value; -} - - - - - // tolua_begin class cMobSpawnerEntity : @@ -54,23 +45,23 @@ public: AString GetEntityName(void) const; /** Returns the spawn delay. */ - int GetSpawnDelay(void) const { return m_SpawnDelay; } + short GetSpawnDelay(void) const { return m_SpawnDelay; } + + /** Sets the spawn delay. */ + void SetSpawnDelay(short a_Delay) { m_SpawnDelay = a_Delay; } int GetNearbyPlayersNum(void); int GetNearbyMonsterNum(eMonsterType a_EntityType); // tolua_end - bool LoadFromJson(const Json::Value & a_Value); - virtual void SaveToJson(Json::Value & a_Value) override; - static const char * GetClassStatic(void) { return "cMobSpawnerEntity"; } private: /** The entity to spawn. */ eMonsterType m_Entity; - int m_SpawnDelay; + short m_SpawnDelay; bool m_IsActive; } ; // tolua_end diff --git a/src/BlockEntities/NoteEntity.h b/src/BlockEntities/NoteEntity.h index fc5f27d07..b33edba4e 100644 --- a/src/BlockEntities/NoteEntity.h +++ b/src/BlockEntities/NoteEntity.h @@ -5,12 +5,6 @@ #include "RedstonePoweredEntity.h" -namespace Json -{ - class Value; -} - - diff --git a/src/BlockEntities/SignEntity.h b/src/BlockEntities/SignEntity.h index 52baa486d..09ab46f0b 100644 --- a/src/BlockEntities/SignEntity.h +++ b/src/BlockEntities/SignEntity.h @@ -14,15 +14,6 @@ -namespace Json -{ - class Value; -} - - - - - // tolua_begin class cSignEntity : -- cgit v1.2.3