2014-02-02 09:59:36 -05:00
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
|
|
|
|
#include "ChunkInterface.h"
|
|
|
|
#include "BlockHandler.h"
|
2014-09-27 15:37:36 -04:00
|
|
|
#include "WorldInterface.h"
|
2018-08-28 20:51:25 -04:00
|
|
|
#include "../ChunkMap.h"
|
2019-10-16 04:06:34 -04:00
|
|
|
#include "../World.h"
|
2014-02-02 09:59:36 -05:00
|
|
|
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-29 14:30:38 -04:00
|
|
|
bool cChunkInterface::DoWithChunkAt(Vector3i a_BlockPos, cChunkCallback a_Callback)
|
|
|
|
{
|
|
|
|
return m_ChunkMap->DoWithChunkAt(a_BlockPos, a_Callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-20 06:13:11 -05:00
|
|
|
BLOCKTYPE cChunkInterface::GetBlock(Vector3i a_Pos)
|
2014-09-17 13:40:10 -04:00
|
|
|
{
|
2019-10-11 05:02:53 -04:00
|
|
|
return m_ChunkMap->GetBlock(a_Pos);
|
2014-09-17 13:40:10 -04:00
|
|
|
}
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-20 06:13:11 -05:00
|
|
|
NIBBLETYPE cChunkInterface::GetBlockMeta(Vector3i a_Pos)
|
2014-09-17 13:40:10 -04:00
|
|
|
{
|
2019-10-11 05:02:53 -04:00
|
|
|
return m_ChunkMap->GetBlockMeta(a_Pos);
|
2014-09-17 13:40:10 -04:00
|
|
|
}
|
|
|
|
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-20 06:13:11 -05:00
|
|
|
bool cChunkInterface::GetBlockTypeMeta(Vector3i a_Pos, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
|
2014-09-17 13:40:10 -04:00
|
|
|
{
|
2019-10-16 04:06:34 -04:00
|
|
|
return m_ChunkMap->GetBlockTypeMeta(a_Pos, a_BlockType, a_BlockMeta);
|
2014-09-17 13:40:10 -04:00
|
|
|
}
|
|
|
|
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
void cChunkInterface::SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
2014-09-17 13:40:10 -04:00
|
|
|
{
|
2019-10-16 04:06:34 -04:00
|
|
|
m_ChunkMap->SetBlock(a_BlockPos, a_BlockType, a_BlockMeta);
|
2014-09-17 13:40:10 -04:00
|
|
|
}
|
|
|
|
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-26 16:45:13 -04:00
|
|
|
void cChunkInterface::SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_MetaData)
|
2014-09-17 13:40:10 -04:00
|
|
|
{
|
2020-08-26 16:45:13 -04:00
|
|
|
m_ChunkMap->SetBlockMeta(a_BlockPos, a_MetaData);
|
2014-09-17 13:40:10 -04:00
|
|
|
}
|
|
|
|
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-10-11 05:02:53 -04:00
|
|
|
void cChunkInterface::FastSetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
2014-09-17 13:40:10 -04:00
|
|
|
{
|
2019-10-11 05:02:53 -04:00
|
|
|
m_ChunkMap->FastSetBlock(a_BlockPos, a_BlockType, a_BlockMeta);
|
2014-09-17 13:40:10 -04:00
|
|
|
}
|
|
|
|
|
2014-09-25 10:45:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-12-01 17:12:44 -05:00
|
|
|
bool cChunkInterface::UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
|
2014-09-17 13:40:10 -04:00
|
|
|
{
|
2015-12-01 17:12:44 -05:00
|
|
|
return m_ChunkMap->UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ);
|
2014-09-17 13:40:10 -04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-08 15:13:44 -04:00
|
|
|
bool cChunkInterface::DigBlock(cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, cEntity * a_Digger)
|
2014-02-02 09:59:36 -05:00
|
|
|
{
|
2020-07-29 14:30:38 -04:00
|
|
|
BLOCKTYPE BlockType;
|
|
|
|
NIBBLETYPE BlockMeta;
|
|
|
|
GetBlockTypeMeta(a_BlockPos, BlockType, BlockMeta);
|
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
if (!m_ChunkMap->DigBlock(a_BlockPos))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2020-07-29 14:30:38 -04:00
|
|
|
|
2020-10-08 15:13:44 -04:00
|
|
|
cBlockHandler::For(BlockType).OnBroken(*this, a_WorldInterface, a_BlockPos, BlockType, BlockMeta, a_Digger);
|
2019-10-16 04:06:34 -04:00
|
|
|
return true;
|
2014-02-02 09:59:36 -05:00
|
|
|
}
|
2014-09-25 10:45:39 -04:00
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cChunkInterface::DropBlockAsPickups(Vector3i a_BlockPos, const cEntity * a_Digger, const cItem * a_Tool)
|
|
|
|
{
|
|
|
|
m_ChunkMap->GetWorld()->DropBlockAsPickups(a_BlockPos, a_Digger, a_Tool);
|
|
|
|
}
|