2014-02-02 09:59:36 -05:00
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
|
|
|
|
#include "ChunkInterface.h"
|
2014-09-17 13:40:10 -04:00
|
|
|
#include "ChunkMap.h"
|
2014-02-02 09:59:36 -05:00
|
|
|
#include "BlockHandler.h"
|
2014-09-27 15:37:36 -04:00
|
|
|
#include "WorldInterface.h"
|
2014-02-02 09:59:36 -05:00
|
|
|
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-17 13:40:10 -04:00
|
|
|
BLOCKTYPE cChunkInterface::GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
|
|
|
|
{
|
|
|
|
return m_ChunkMap->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
|
|
|
|
}
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-17 13:40:10 -04:00
|
|
|
BLOCKTYPE cChunkInterface::GetBlock(const Vector3i & a_Pos)
|
|
|
|
{
|
|
|
|
return GetBlock(a_Pos.x, a_Pos.y, a_Pos.z);
|
|
|
|
}
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-17 13:40:10 -04:00
|
|
|
NIBBLETYPE cChunkInterface::GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ)
|
|
|
|
{
|
|
|
|
return m_ChunkMap->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
|
|
|
}
|
|
|
|
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-17 13:40:10 -04:00
|
|
|
bool cChunkInterface::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
|
|
|
|
{
|
|
|
|
return m_ChunkMap->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
|
|
|
|
}
|
|
|
|
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-17 13:40:10 -04:00
|
|
|
/** Sets the block at the specified coords to the specified value.
|
|
|
|
Full processing, incl. updating neighbors, is performed.
|
|
|
|
*/
|
2014-09-17 13:47:33 -04:00
|
|
|
void cChunkInterface::SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
2014-09-17 13:40:10 -04:00
|
|
|
{
|
2014-09-17 13:47:33 -04:00
|
|
|
m_ChunkMap->SetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
|
2014-09-17 13:40:10 -04:00
|
|
|
}
|
|
|
|
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-17 13:40:10 -04:00
|
|
|
void cChunkInterface::SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData)
|
|
|
|
{
|
|
|
|
m_ChunkMap->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, a_MetaData);
|
|
|
|
}
|
|
|
|
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-17 13:40:10 -04:00
|
|
|
void cChunkInterface::QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_TickDelay, BLOCKTYPE a_PreviousBlockType, cWorldInterface & a_WorldInterface)
|
|
|
|
{
|
|
|
|
m_ChunkMap->QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_WorldInterface.GetWorldAge() + a_TickDelay, a_PreviousBlockType);
|
|
|
|
}
|
|
|
|
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-17 13:40:10 -04:00
|
|
|
/** Sets the block at the specified coords to the specified value.
|
|
|
|
The replacement doesn't trigger block updates.
|
|
|
|
The replaced blocks aren't checked for block entities (block entity is leaked if it exists at this block)
|
|
|
|
*/
|
|
|
|
void cChunkInterface::FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
|
|
|
{
|
|
|
|
m_ChunkMap->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
|
|
|
|
}
|
|
|
|
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-17 13:40:10 -04:00
|
|
|
void cChunkInterface::FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
|
|
|
{
|
|
|
|
FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta);
|
|
|
|
}
|
|
|
|
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-17 13:40:10 -04:00
|
|
|
void cChunkInterface::UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
|
|
|
|
{
|
|
|
|
m_ChunkMap->UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ);
|
|
|
|
}
|
|
|
|
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-17 13:40:10 -04:00
|
|
|
bool cChunkInterface::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback)
|
|
|
|
{
|
|
|
|
return m_ChunkMap->ForEachChunkInRect(a_MinChunkX, a_MaxChunkX, a_MinChunkZ, a_MaxChunkZ, a_Callback);
|
|
|
|
}
|
|
|
|
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-17 13:40:10 -04:00
|
|
|
bool cChunkInterface::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes)
|
|
|
|
{
|
|
|
|
return m_ChunkMap->WriteBlockArea(a_Area, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes);
|
|
|
|
}
|
|
|
|
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-02 09:59:36 -05:00
|
|
|
bool cChunkInterface::DigBlock(cWorldInterface & a_WorldInterface, int a_X, int a_Y, int a_Z)
|
|
|
|
{
|
2014-03-02 14:25:05 -05:00
|
|
|
cBlockHandler * Handler = cBlockInfo::GetHandler(GetBlock(a_X, a_Y, a_Z));
|
2014-02-02 09:59:36 -05:00
|
|
|
Handler->OnDestroyed(*this, a_WorldInterface, a_X, a_Y, a_Z);
|
|
|
|
return m_ChunkMap->DigBlock(a_X, a_Y, a_Z);
|
|
|
|
}
|
2014-09-25 10:45:39 -04:00
|
|
|
|