summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities
diff options
context:
space:
mode:
Diffstat (limited to 'src/BlockEntities')
-rw-r--r--src/BlockEntities/BeaconEntity.cpp4
-rw-r--r--src/BlockEntities/BeaconEntity.h2
-rw-r--r--src/BlockEntities/BlockEntity.h2
-rw-r--r--src/BlockEntities/BlockEntityWithItems.h2
-rw-r--r--src/BlockEntities/CMakeLists.txt42
-rw-r--r--src/BlockEntities/ChestEntity.cpp6
-rw-r--r--src/BlockEntities/ChestEntity.h3
-rw-r--r--src/BlockEntities/CommandBlockEntity.cpp2
-rw-r--r--src/BlockEntities/CommandBlockEntity.h6
-rw-r--r--src/BlockEntities/DropSpenserEntity.cpp10
-rw-r--r--src/BlockEntities/DropSpenserEntity.h3
-rw-r--r--src/BlockEntities/EnderChestEntity.h4
-rw-r--r--src/BlockEntities/FlowerPotEntity.h6
-rw-r--r--src/BlockEntities/FurnaceEntity.cpp2
-rw-r--r--src/BlockEntities/HopperEntity.cpp8
-rw-r--r--src/BlockEntities/HopperEntity.h3
-rw-r--r--src/BlockEntities/JukeboxEntity.h2
-rw-r--r--src/BlockEntities/MobHeadEntity.h6
-rw-r--r--src/BlockEntities/NoteEntity.h2
-rw-r--r--src/BlockEntities/SignEntity.h6
20 files changed, 78 insertions, 43 deletions
diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp
index 0914353eb..4b9662797 100644
--- a/src/BlockEntities/BeaconEntity.cpp
+++ b/src/BlockEntities/BeaconEntity.cpp
@@ -32,7 +32,7 @@ int cBeaconEntity::GetPyramidLevel(void)
}
Area.Read(
- m_World,
+ m_World,
GetPosX() - 4, GetPosX() + 4,
MinY, MaxY,
GetPosZ() - 4, GetPosZ() + 4,
@@ -66,7 +66,7 @@ int cBeaconEntity::GetPyramidLevel(void)
bool cBeaconEntity::IsMineralBlock(BLOCKTYPE a_BlockType)
{
- switch(a_BlockType)
+ switch (a_BlockType)
{
case E_BLOCK_DIAMOND_BLOCK:
case E_BLOCK_GOLD_BLOCK:
diff --git a/src/BlockEntities/BeaconEntity.h b/src/BlockEntities/BeaconEntity.h
index b1df68bc4..ee1eda391 100644
--- a/src/BlockEntities/BeaconEntity.h
+++ b/src/BlockEntities/BeaconEntity.h
@@ -33,7 +33,7 @@ public:
static bool IsMineralBlock(BLOCKTYPE a_BlockType);
// cBlockEntity overrides:
- virtual void SaveToJson(Json::Value& a_Value ) override;
+ virtual void SaveToJson(Json::Value& a_Value) override;
virtual void SendTo(cClientHandle & a_Client) override;
virtual void UsedBy(cPlayer * a_Player) override;
virtual bool Tick(float a_Dt, cChunk & /* a_Chunk */) override;
diff --git a/src/BlockEntities/BlockEntity.h b/src/BlockEntities/BlockEntity.h
index 7c6688f8d..24c25e729 100644
--- a/src/BlockEntities/BlockEntity.h
+++ b/src/BlockEntities/BlockEntity.h
@@ -79,7 +79,7 @@ public:
virtual void SaveToJson (Json::Value & a_Value) = 0;
/// Called when a player uses this entity; should open the UI window
- virtual void UsedBy( cPlayer * a_Player ) = 0;
+ virtual void UsedBy( cPlayer * a_Player) = 0;
/** Sends the packet defining the block entity to the client specified.
To send to all eligible clients, use cWorld::BroadcastBlockEntity()
diff --git a/src/BlockEntities/BlockEntityWithItems.h b/src/BlockEntities/BlockEntityWithItems.h
index 918781a00..5f1639d45 100644
--- a/src/BlockEntities/BlockEntityWithItems.h
+++ b/src/BlockEntities/BlockEntityWithItems.h
@@ -50,7 +50,7 @@ public:
cItems Pickups;
m_Contents.CopyToItems(Pickups);
m_Contents.Clear();
- m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5); // Spawn in centre of block
+ m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5); // Spawn in centre of block
}
// tolua_begin
diff --git a/src/BlockEntities/CMakeLists.txt b/src/BlockEntities/CMakeLists.txt
index 3e3d17f86..d87594b0d 100644
--- a/src/BlockEntities/CMakeLists.txt
+++ b/src/BlockEntities/CMakeLists.txt
@@ -4,9 +4,41 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
-file(GLOB SOURCE
- "*.cpp"
- "*.h"
-)
+SET (SRCS
+ BeaconEntity.cpp
+ BlockEntity.cpp
+ ChestEntity.cpp
+ CommandBlockEntity.cpp
+ DispenserEntity.cpp
+ DropSpenserEntity.cpp
+ DropperEntity.cpp
+ EnderChestEntity.cpp
+ FlowerPotEntity.cpp
+ FurnaceEntity.cpp
+ HopperEntity.cpp
+ JukeboxEntity.cpp
+ MobHeadEntity.cpp
+ NoteEntity.cpp
+ SignEntity.cpp)
-add_library(BlockEntities ${SOURCE})
+SET (HDRS
+ BeaconEntity.h
+ BlockEntity.h
+ BlockEntityWithItems.h
+ ChestEntity.h
+ CommandBlockEntity.h
+ DispenserEntity.h
+ DropSpenserEntity.h
+ DropperEntity.h
+ EnderChestEntity.h
+ FlowerPotEntity.h
+ FurnaceEntity.h
+ HopperEntity.h
+ JukeboxEntity.h
+ MobHeadEntity.h
+ NoteEntity.h
+ SignEntity.h)
+
+if(NOT MSVC)
+ add_library(BlockEntities ${SRCS} ${HDRS})
+endif()
diff --git a/src/BlockEntities/ChestEntity.cpp b/src/BlockEntities/ChestEntity.cpp
index ca164464c..21e1f6ba2 100644
--- a/src/BlockEntities/ChestEntity.cpp
+++ b/src/BlockEntities/ChestEntity.cpp
@@ -169,15 +169,15 @@ void cChestEntity::OpenNewWindow(void)
if (
m_World->DoWithChestAt(m_PosX - 1, m_PosY, m_PosZ, OpenDbl) ||
m_World->DoWithChestAt(m_PosX + 1, m_PosY, m_PosZ, OpenDbl) ||
- m_World->DoWithChestAt(m_PosX , m_PosY, m_PosZ - 1, OpenDbl) ||
- m_World->DoWithChestAt(m_PosX , m_PosY, m_PosZ + 1, OpenDbl)
+ m_World->DoWithChestAt(m_PosX, m_PosY, m_PosZ - 1, OpenDbl) ||
+ m_World->DoWithChestAt(m_PosX, m_PosY, m_PosZ + 1, OpenDbl)
)
{
// The double-chest window has been opened in the callback
return;
}
- // There is no chest neighbor, open a single-chest window:
+ // There is no chest neighbor, open a single-chest window:
OpenWindow(new cChestWindow(this));
}
diff --git a/src/BlockEntities/ChestEntity.h b/src/BlockEntities/ChestEntity.h
index 310618504..cd06b3e2c 100644
--- a/src/BlockEntities/ChestEntity.h
+++ b/src/BlockEntities/ChestEntity.h
@@ -27,7 +27,8 @@ class cChestEntity :
typedef cBlockEntityWithItems super;
public:
- enum {
+ enum
+ {
ContentsHeight = 3,
ContentsWidth = 9,
} ;
diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp
index 146ad915b..45f8a3e4d 100644
--- a/src/BlockEntities/CommandBlockEntity.cpp
+++ b/src/BlockEntities/CommandBlockEntity.cpp
@@ -11,7 +11,7 @@
#include "../CommandOutput.h"
#include "../Root.h"
-#include "../Server.h" // ExecuteConsoleCommand()
+#include "../Server.h" // ExecuteConsoleCommand()
#include "../Chunk.h"
diff --git a/src/BlockEntities/CommandBlockEntity.h b/src/BlockEntities/CommandBlockEntity.h
index 12157670f..d02bf7d7b 100644
--- a/src/BlockEntities/CommandBlockEntity.h
+++ b/src/BlockEntities/CommandBlockEntity.h
@@ -26,7 +26,7 @@ namespace Json
// tolua_begin
-class cCommandBlockEntity :
+class cCommandBlockEntity :
public cBlockEntity
{
typedef cBlockEntity super;
@@ -38,8 +38,8 @@ public:
/// Creates a new empty command block entity
cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
- bool LoadFromJson( const Json::Value& a_Value );
- virtual void SaveToJson(Json::Value& a_Value ) override;
+ bool LoadFromJson( const Json::Value& a_Value);
+ virtual void SaveToJson(Json::Value& a_Value) override;
virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void SendTo(cClientHandle & a_Client) override;
diff --git a/src/BlockEntities/DropSpenserEntity.cpp b/src/BlockEntities/DropSpenserEntity.cpp
index 0012742fb..dc38e3e9b 100644
--- a/src/BlockEntities/DropSpenserEntity.cpp
+++ b/src/BlockEntities/DropSpenserEntity.cpp
@@ -42,7 +42,7 @@ cDropSpenserEntity::~cDropSpenserEntity()
void cDropSpenserEntity::AddDropSpenserDir(int & a_BlockX, int & a_BlockY, int & a_BlockZ, NIBBLETYPE a_Direction)
{
- switch (a_Direction)
+ switch (a_Direction & 0x07) // Vanilla uses the 8th bit to determine power state - we don't
{
case E_META_DROPSPENSER_FACING_YM: a_BlockY--; return;
case E_META_DROPSPENSER_FACING_YP: a_BlockY++; return;
@@ -90,7 +90,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
int SmokeDir = 0;
switch (Meta)
{
- case E_META_DROPSPENSER_FACING_YP: SmokeDir = 4; break; // YP & YM don't have associated smoke dirs, just do 4 (centre of block)
+ case E_META_DROPSPENSER_FACING_YP: SmokeDir = 4; break; // YP & YM don't have associated smoke dirs, just do 4 (centre of block)
case E_META_DROPSPENSER_FACING_YM: SmokeDir = 4; break;
case E_META_DROPSPENSER_FACING_XM: SmokeDir = 3; break;
case E_META_DROPSPENSER_FACING_XP: SmokeDir = 5; break;
@@ -99,7 +99,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
}
m_World->BroadcastSoundParticleEffect(2000, m_PosX, m_PosY, m_PosZ, SmokeDir);
m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.0f);
-}
+}
@@ -235,7 +235,7 @@ void cDropSpenserEntity::DropFromSlot(cChunk & a_Chunk, int a_SlotNum)
cItems Pickups;
Pickups.push_back(m_Contents.RemoveOneItem(a_SlotNum));
- const int PickupSpeed = m_World->GetTickRandomNumber(4) + 2; // At least 2, at most 6
+ const int PickupSpeed = m_World->GetTickRandomNumber(4) + 2; // At least 2, at most 6
int PickupSpeedX = 0, PickupSpeedY = 0, PickupSpeedZ = 0;
switch (Meta)
{
@@ -249,7 +249,7 @@ void cDropSpenserEntity::DropFromSlot(cChunk & a_Chunk, int a_SlotNum)
double MicroX, MicroY, MicroZ;
MicroX = DispX + 0.5;
- MicroY = DispY + 0.4; // Slightly less than half, to accomodate actual texture hole on DropSpenser
+ MicroY = DispY + 0.4; // Slightly less than half, to accomodate actual texture hole on DropSpenser
MicroZ = DispZ + 0.5;
diff --git a/src/BlockEntities/DropSpenserEntity.h b/src/BlockEntities/DropSpenserEntity.h
index 47d3bd492..9f58d0b07 100644
--- a/src/BlockEntities/DropSpenserEntity.h
+++ b/src/BlockEntities/DropSpenserEntity.h
@@ -35,7 +35,8 @@ class cDropSpenserEntity :
typedef cBlockEntityWithItems super;
public:
- enum {
+ enum
+ {
ContentsHeight = 3,
ContentsWidth = 3,
} ;
diff --git a/src/BlockEntities/EnderChestEntity.h b/src/BlockEntities/EnderChestEntity.h
index 04af67683..ed178f6fc 100644
--- a/src/BlockEntities/EnderChestEntity.h
+++ b/src/BlockEntities/EnderChestEntity.h
@@ -16,10 +16,10 @@ class cEnderChestEntity :
{
typedef cBlockEntity super;
-public:
+public:
// tolua_end
- cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
+ cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
virtual ~cEnderChestEntity();
static const char * GetClassStatic(void) { return "cEnderChestEntity"; }
diff --git a/src/BlockEntities/FlowerPotEntity.h b/src/BlockEntities/FlowerPotEntity.h
index e3570eb9a..89901cf2d 100644
--- a/src/BlockEntities/FlowerPotEntity.h
+++ b/src/BlockEntities/FlowerPotEntity.h
@@ -27,7 +27,7 @@ namespace Json
// tolua_begin
-class cFlowerPotEntity :
+class cFlowerPotEntity :
public cBlockEntity
{
typedef cBlockEntity super;
@@ -39,8 +39,8 @@ public:
/** Creates a new flowerpot entity at the specified block coords. a_World may be NULL */
cFlowerPotEntity(int a_BlocX, int a_BlockY, int a_BlockZ, cWorld * a_World);
- bool LoadFromJson( const Json::Value& a_Value );
- virtual void SaveToJson(Json::Value& a_Value ) override;
+ bool LoadFromJson( const Json::Value& a_Value);
+ virtual void SaveToJson(Json::Value& a_Value) override;
virtual void Destroy(void) override;
diff --git a/src/BlockEntities/FurnaceEntity.cpp b/src/BlockEntities/FurnaceEntity.cpp
index 1b1741713..72fd7f2b3 100644
--- a/src/BlockEntities/FurnaceEntity.cpp
+++ b/src/BlockEntities/FurnaceEntity.cpp
@@ -160,7 +160,7 @@ bool cFurnaceEntity::LoadFromJson(const Json::Value & a_Value)
-void cFurnaceEntity::SaveToJson( Json::Value& a_Value )
+void cFurnaceEntity::SaveToJson( Json::Value& a_Value)
{
a_Value["x"] = m_PosX;
a_Value["y"] = m_PosY;
diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp
index 7af4b9d5d..48d3b8dcc 100644
--- a/src/BlockEntities/HopperEntity.cpp
+++ b/src/BlockEntities/HopperEntity.cpp
@@ -219,7 +219,7 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
}
Vector3f EntityPos = a_Entity->GetPosition();
- Vector3f BlockPos(m_Pos.x + 0.5f, (float)m_Pos.y + 1, m_Pos.z + 0.5f); // One block above hopper, and search from center outwards
+ Vector3f BlockPos(m_Pos.x + 0.5f, (float)m_Pos.y + 1, m_Pos.z + 0.5f); // One block above hopper, and search from center outwards
double Distance = (EntityPos - BlockPos).Length();
if (Distance < 0.5)
@@ -243,7 +243,7 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
{
m_bFoundPickupsAbove = true;
m_Contents.SetSlot(i, Item);
- a_Pickup->Destroy(); // Kill pickup
+ a_Pickup->Destroy(); // Kill pickup
return true;
}
@@ -253,11 +253,11 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
int PreviousCount = m_Contents.GetSlot(i).m_ItemCount;
- Item.m_ItemCount -= m_Contents.ChangeSlotCount(i, Item.m_ItemCount) - PreviousCount; // Set count to however many items were added
+ Item.m_ItemCount -= m_Contents.ChangeSlotCount(i, Item.m_ItemCount) - PreviousCount; // Set count to however many items were added
if (Item.IsEmpty())
{
- a_Pickup->Destroy(); // Kill pickup if all items were added
+ a_Pickup->Destroy(); // Kill pickup if all items were added
}
return true;
}
diff --git a/src/BlockEntities/HopperEntity.h b/src/BlockEntities/HopperEntity.h
index 6ef98f43a..8e856fcda 100644
--- a/src/BlockEntities/HopperEntity.h
+++ b/src/BlockEntities/HopperEntity.h
@@ -22,7 +22,8 @@ class cHopperEntity :
typedef cBlockEntityWithItems super;
public:
- enum {
+ enum
+ {
ContentsHeight = 1,
ContentsWidth = 5,
TICKS_PER_TRANSFER = 8, ///< How many ticks at minimum between two item transfers to or from the hopper
diff --git a/src/BlockEntities/JukeboxEntity.h b/src/BlockEntities/JukeboxEntity.h
index 3d1d604f7..8bb3009eb 100644
--- a/src/BlockEntities/JukeboxEntity.h
+++ b/src/BlockEntities/JukeboxEntity.h
@@ -19,7 +19,7 @@ namespace Json
// tolua_begin
-class cJukeboxEntity :
+class cJukeboxEntity :
public cBlockEntity
{
typedef cBlockEntity super;
diff --git a/src/BlockEntities/MobHeadEntity.h b/src/BlockEntities/MobHeadEntity.h
index 367eb15e7..f91a3cc9e 100644
--- a/src/BlockEntities/MobHeadEntity.h
+++ b/src/BlockEntities/MobHeadEntity.h
@@ -25,7 +25,7 @@ namespace Json
// tolua_begin
-class cMobHeadEntity :
+class cMobHeadEntity :
public cBlockEntity
{
typedef cBlockEntity super;
@@ -37,8 +37,8 @@ public:
/** Creates a new mob head entity at the specified block coords. a_World may be NULL */
cMobHeadEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
- bool LoadFromJson( const Json::Value& a_Value );
- virtual void SaveToJson(Json::Value& a_Value ) override;
+ bool LoadFromJson( const Json::Value& a_Value);
+ virtual void SaveToJson(Json::Value& a_Value) override;
// tolua_begin
diff --git a/src/BlockEntities/NoteEntity.h b/src/BlockEntities/NoteEntity.h
index b698899c0..07b8fd259 100644
--- a/src/BlockEntities/NoteEntity.h
+++ b/src/BlockEntities/NoteEntity.h
@@ -28,7 +28,7 @@ enum ENUM_NOTE_INSTRUMENTS
// tolua_begin
-class cNoteEntity :
+class cNoteEntity :
public cBlockEntity
{
typedef cBlockEntity super;
diff --git a/src/BlockEntities/SignEntity.h b/src/BlockEntities/SignEntity.h
index 80c7bbfdf..33af100a4 100644
--- a/src/BlockEntities/SignEntity.h
+++ b/src/BlockEntities/SignEntity.h
@@ -25,7 +25,7 @@ namespace Json
// tolua_begin
-class cSignEntity :
+class cSignEntity :
public cBlockEntity
{
typedef cBlockEntity super;
@@ -37,8 +37,8 @@ public:
/// Creates a new empty sign entity at the specified block coords and block type (wall or standing). a_World may be NULL
cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World);
- bool LoadFromJson( const Json::Value& a_Value );
- virtual void SaveToJson(Json::Value& a_Value ) override;
+ bool LoadFromJson( const Json::Value& a_Value);
+ virtual void SaveToJson(Json::Value& a_Value) override;
// tolua_begin