summaryrefslogtreecommitdiffstats
path: root/source/Chunk.cpp
diff options
context:
space:
mode:
authorluksor111@gmail.com <luksor111@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-12-26 18:16:33 +0100
committerluksor111@gmail.com <luksor111@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-12-26 18:16:33 +0100
commit575abe8691bf2f615f17e6212ea5ec6265ffd4ed (patch)
treed37b31c6eac993b643cf0dccd7d38c2fe316ff04 /source/Chunk.cpp
parentAdjusted the protocol framework to support different types of falling block spawning. (diff)
downloadcuberite-575abe8691bf2f615f17e6212ea5ec6265ffd4ed.tar
cuberite-575abe8691bf2f615f17e6212ea5ec6265ffd4ed.tar.gz
cuberite-575abe8691bf2f615f17e6212ea5ec6265ffd4ed.tar.bz2
cuberite-575abe8691bf2f615f17e6212ea5ec6265ffd4ed.tar.lz
cuberite-575abe8691bf2f615f17e6212ea5ec6265ffd4ed.tar.xz
cuberite-575abe8691bf2f615f17e6212ea5ec6265ffd4ed.tar.zst
cuberite-575abe8691bf2f615f17e6212ea5ec6265ffd4ed.zip
Diffstat (limited to '')
-rw-r--r--source/Chunk.cpp64
1 files changed, 63 insertions, 1 deletions
diff --git a/source/Chunk.cpp b/source/Chunk.cpp
index 165eda831..96522d6bf 100644
--- a/source/Chunk.cpp
+++ b/source/Chunk.cpp
@@ -442,7 +442,15 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom)
m_IsDirty = ((cFurnaceEntity *)(*itr))->Tick( a_Dt ) | m_IsDirty;
}
}
-
+
+ // Tick block entities (dispensers)
+ for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)
+ {
+ if ((*itr)->GetBlockType() == E_BLOCK_DISPENSER)
+ {
+ m_IsDirty = ((cDispenserEntity *)(*itr))->Tick( a_Dt ) | m_IsDirty;
+ }
+ }
ApplyWeatherToTop(a_TickRandom);
}
@@ -1588,6 +1596,28 @@ bool cChunk::ForEachChest(cChestCallback & a_Callback)
+bool cChunk::ForEachDispenser(cDispenserCallback & a_Callback)
+{
+ // The blockentity list is locked by the parent chunkmap's CS
+ for (cBlockEntityList::iterator itr = m_BlockEntities.begin(), itr2 = itr; itr != m_BlockEntities.end(); itr = itr2)
+ {
+ ++itr2;
+ if ((*itr)->GetBlockType() != E_BLOCK_DISPENSER)
+ {
+ continue;
+ }
+ if (a_Callback.Item((cDispenserEntity *)*itr))
+ {
+ return false;
+ }
+ } // for itr - m_BlockEntitites[]
+ return true;
+}
+
+
+
+
+
bool cChunk::ForEachFurnace(cFurnaceCallback & a_Callback)
{
// The blockentity list is locked by the parent chunkmap's CS
@@ -1650,6 +1680,38 @@ bool cChunk::DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, cChestCallb
+bool cChunk::DoWithDispenserAt(int a_BlockX, int a_BlockY, int a_BlockZ, cDispenserCallback & a_Callback)
+{
+ // The blockentity list is locked by the parent chunkmap's CS
+ for (cBlockEntityList::iterator itr = m_BlockEntities.begin(), itr2 = itr; itr != m_BlockEntities.end(); itr = itr2)
+ {
+ ++itr2;
+ if (((*itr)->GetPosX() != a_BlockX) || ((*itr)->GetPosY() != a_BlockY) || ((*itr)->GetPosZ() != a_BlockZ))
+ {
+ continue;
+ }
+ if ((*itr)->GetBlockType() != E_BLOCK_DISPENSER)
+ {
+ // There is a block entity here, but of different type. No other block entity can be here, so we can safely bail out
+ return false;
+ }
+
+ // The correct block entity is here
+ if (a_Callback.Item((cDispenserEntity *)*itr))
+ {
+ return false;
+ }
+ return true;
+ } // for itr - m_BlockEntitites[]
+
+ // Not found:
+ return false;
+}
+
+
+
+
+
bool cChunk::DoWithFurnaceAt(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceCallback & a_Callback)
{
// The blockentity list is locked by the parent chunkmap's CS