summaryrefslogtreecommitdiffstats
path: root/source/cChestEntity.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-13 22:47:03 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-13 22:47:03 +0100
commit4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c (patch)
treefebea3ecd89c0d4aa83924e430bf11366d754733 /source/cChestEntity.cpp
parentNew makefile with automatic *.cpp sourcefile import, automatic header file dependencies and switchable debug / release configuration. gnumake-specific :( (diff)
downloadcuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.gz
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.bz2
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.lz
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.xz
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.tar.zst
cuberite-4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c.zip
Diffstat (limited to '')
-rw-r--r--source/cChestEntity.cpp56
1 files changed, 44 insertions, 12 deletions
diff --git a/source/cChestEntity.cpp b/source/cChestEntity.cpp
index b30800700..e96d4bbb2 100644
--- a/source/cChestEntity.cpp
+++ b/source/cChestEntity.cpp
@@ -23,14 +23,18 @@ class cRoot;
-cChestEntity::cChestEntity(int a_X, int a_Y, int a_Z, cChunk* a_Chunk)
- : cBlockEntity( E_BLOCK_CHEST, a_X, a_Y, a_Z, a_Chunk )
+cChestEntity::cChestEntity(int a_X, int a_Y, int a_Z, cWorld * a_World)
+ : cBlockEntity( E_BLOCK_CHEST, a_X, a_Y, a_Z, a_World)
, m_TopChest( false )
- , m_JoinedChest( 0 )
+ , m_JoinedChest( NULL )
{
m_Content = new cItem[ c_ChestHeight*c_ChestWidth ];
}
+
+
+
+
cChestEntity::~cChestEntity()
{
if( GetWindow() )
@@ -44,6 +48,10 @@ cChestEntity::~cChestEntity()
}
}
+
+
+
+
void cChestEntity::Destroy()
{
// Drop items
@@ -51,15 +59,21 @@ void cChestEntity::Destroy()
{
if( !m_Content[i].IsEmpty() )
{
- cPickup* Pickup = new cPickup( m_PosX*32 + 16, m_PosY*32 + 16, m_PosZ*32 + 16, m_Content[i], 0, 1.f, 0 );
- Pickup->Initialize( GetChunk()->GetWorld() );
+ cPickup * Pickup = new cPickup( m_PosX * 32 + 16, m_PosY * 32 + 16, m_PosZ * 32 + 16, m_Content[i], 0, 1.f, 0 );
+ Pickup->Initialize(m_World);
m_Content[i].Empty();
}
}
if (m_JoinedChest)
+ {
m_JoinedChest->RemoveJoinedChest(this);
+ }
}
+
+
+
+
cItem * cChestEntity::GetSlot( int a_Slot )
{
if( a_Slot > -1 && a_Slot < c_ChestHeight*c_ChestWidth )
@@ -69,6 +83,10 @@ cItem * cChestEntity::GetSlot( int a_Slot )
return 0;
}
+
+
+
+
void cChestEntity::SetSlot( int a_Slot, cItem & a_Item )
{
if( a_Slot > -1 && a_Slot < c_ChestHeight*c_ChestWidth )
@@ -129,6 +147,10 @@ bool cChestEntity::LoadFromJson( const Json::Value& a_Value )
return true;
}
+
+
+
+
void cChestEntity::SaveToJson( Json::Value& a_Value )
{
a_Value["x"] = m_PosX;
@@ -147,6 +169,10 @@ void cChestEntity::SaveToJson( Json::Value& a_Value )
a_Value["Slots"] = AllSlots;
}
+
+
+
+
void cChestEntity::SendTo( cClientHandle* a_Client, cServer* a_Server )
{
(void)a_Client;
@@ -154,6 +180,10 @@ void cChestEntity::SendTo( cClientHandle* a_Client, cServer* a_Server )
return;
}
+
+
+
+
void cChestEntity::UsedBy( cPlayer & a_Player )
{
LOG("Used a chest");
@@ -185,15 +215,13 @@ void cChestEntity::UsedBy( cPlayer & a_Player )
ChestOpen.m_PosZ = GetPosZ();
ChestOpen.m_Byte1 = (char)1;
ChestOpen.m_Byte2 = (char)1;
- cWorld::PlayerList PlayerList = cRoot::Get()->GetWorld()->GetAllPlayers();
- for( cWorld::PlayerList::iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr )
- {
- if ((*itr) && (*itr)->GetClientHandle() && !((*itr)->GetClientHandle()->IsDestroyed())) {
- (*itr)->GetClientHandle()->Send( ChestOpen );
- }
- }
+ m_World->GetChunkOfBlock(m_PosX, m_PosY, m_PosZ)->Broadcast(&ChestOpen);
}
+
+
+
+
cItem *cChestEntity::GetContents(bool a_OnlyThis)
{
if (m_JoinedChest && !a_OnlyThis)
@@ -215,3 +243,7 @@ cItem *cChestEntity::GetContents(bool a_OnlyThis)
else
return m_Content;
}
+
+
+
+