diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-02-02 23:09:03 +0100 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-02-02 23:09:03 +0100 |
commit | 2d0b31e7b671447ca49988d14c13b6eb6bad4cf2 (patch) | |
tree | a0b28406e9c9f561fed241a47f3a51ef4db791a1 /src/Chunk.cpp | |
parent | Fixed #624 (diff) | |
parent | Merge pull request #622 from worktycho/registerfix (diff) | |
download | cuberite-2d0b31e7b671447ca49988d14c13b6eb6bad4cf2.tar cuberite-2d0b31e7b671447ca49988d14c13b6eb6bad4cf2.tar.gz cuberite-2d0b31e7b671447ca49988d14c13b6eb6bad4cf2.tar.bz2 cuberite-2d0b31e7b671447ca49988d14c13b6eb6bad4cf2.tar.lz cuberite-2d0b31e7b671447ca49988d14c13b6eb6bad4cf2.tar.xz cuberite-2d0b31e7b671447ca49988d14c13b6eb6bad4cf2.tar.zst cuberite-2d0b31e7b671447ca49988d14c13b6eb6bad4cf2.zip |
Diffstat (limited to 'src/Chunk.cpp')
-rw-r--r-- | src/Chunk.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp index a72464ec3..b48bfe65e 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -31,7 +31,7 @@ #include "Simulator/FluidSimulator.h" #include "MobCensus.h" #include "MobSpawner.h" - +#include "BlockInServerPluginInterface.h" #include "json/json.h" @@ -638,7 +638,9 @@ void cChunk::TickBlock(int a_RelX, int a_RelY, int a_RelZ) unsigned Index = MakeIndex(a_RelX, a_RelY, a_RelZ); cBlockHandler * Handler = BlockHandler(m_BlockTypes[Index]); ASSERT(Handler != NULL); // Happenned on server restart, FS #243 - Handler->OnUpdate(*this, a_RelX, a_RelY, a_RelZ); + cChunkInterface ChunkInterface(this->GetWorld()->GetChunkMap()); + cBlockInServerPluginInterface PluginInterface(*this->GetWorld()); + Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface,*this, a_RelX, a_RelY, a_RelZ); } @@ -753,7 +755,7 @@ void cChunk::BroadcastPendingBlockChanges(void) -void cChunk::CheckBlocks(void) +void cChunk::CheckBlocks() { if (m_ToTickBlocks.size() == 0) { @@ -762,13 +764,16 @@ void cChunk::CheckBlocks(void) std::vector<unsigned int> ToTickBlocks; std::swap(m_ToTickBlocks, ToTickBlocks); + cChunkInterface ChunkInterface(m_World->GetChunkMap()); + cBlockInServerPluginInterface PluginInterface(*m_World); + for (std::vector<unsigned int>::const_iterator itr = ToTickBlocks.begin(), end = ToTickBlocks.end(); itr != end; ++itr) { unsigned int index = (*itr); Vector3i BlockPos = IndexToCoordinate(index); cBlockHandler * Handler = BlockHandler(GetBlock(index)); - Handler->Check(BlockPos.x, BlockPos.y, BlockPos.z, *this); + Handler->Check(ChunkInterface, PluginInterface, BlockPos.x, BlockPos.y, BlockPos.z, *this); } // for itr - ToTickBlocks[] } @@ -786,6 +791,9 @@ void cChunk::TickBlocks(void) int TickX = m_BlockTickX; int TickY = m_BlockTickY; int TickZ = m_BlockTickZ; + + cChunkInterface ChunkInterface(this->GetWorld()->GetChunkMap()); + cBlockInServerPluginInterface PluginInterface(*this->GetWorld()); // This for loop looks disgusting, but it actually does a simple thing - first processes m_BlockTick, then adds random to it // This is so that SetNextBlockTick() works @@ -811,7 +819,7 @@ void cChunk::TickBlocks(void) unsigned int Index = MakeIndexNoCheck(m_BlockTickX, m_BlockTickY, m_BlockTickZ); cBlockHandler * Handler = BlockHandler(m_BlockTypes[Index]); ASSERT(Handler != NULL); // Happenned on server restart, FS #243 - Handler->OnUpdate(*this, m_BlockTickX, m_BlockTickY, m_BlockTickZ); + Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, m_BlockTickX, m_BlockTickY, m_BlockTickZ); } // for i - tickblocks } |