g_BlockXXX => cBlockInfo::XXX
This commit is contained in:
parent
5c5502be9e
commit
d73cdba1f6
@ -7,13 +7,13 @@
|
||||
|
||||
|
||||
|
||||
BlockInfo BlockInfo::ms_Info[256];
|
||||
cBlockInfo cBlockInfo::ms_Info[256];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BlockInfo::BlockInfo()
|
||||
cBlockInfo::cBlockInfo()
|
||||
: m_LightValue(0x00)
|
||||
, m_SpreadLightFalloff(0x0f)
|
||||
, m_Transparent(false)
|
||||
@ -29,7 +29,7 @@ BlockInfo::BlockInfo()
|
||||
|
||||
|
||||
|
||||
BlockInfo & BlockInfo::GetById(unsigned int a_ID)
|
||||
cBlockInfo & cBlockInfo::GetById(unsigned int a_ID)
|
||||
{
|
||||
ASSERT(a_ID < 256);
|
||||
|
||||
@ -40,7 +40,7 @@ BlockInfo & BlockInfo::GetById(unsigned int a_ID)
|
||||
|
||||
|
||||
|
||||
void BlockInfo::Initialize(void)
|
||||
void cBlockInfo::Initialize(void)
|
||||
{
|
||||
// Emissive blocks
|
||||
ms_Info[E_BLOCK_FIRE ].m_LightValue = 15;
|
||||
@ -413,7 +413,7 @@ class cBlockInfoInitializer
|
||||
public:
|
||||
cBlockInfoInitializer(void)
|
||||
{
|
||||
BlockInfo::Initialize();
|
||||
cBlockInfo::Initialize();
|
||||
}
|
||||
} BlockInfoInitializer;
|
||||
|
||||
|
@ -6,27 +6,44 @@
|
||||
|
||||
|
||||
|
||||
class BlockInfo
|
||||
class cBlockInfo
|
||||
{
|
||||
public:
|
||||
|
||||
BlockInfo();
|
||||
cBlockInfo();
|
||||
|
||||
/** (Re-)Initializes the internal BlockInfo structures. */
|
||||
static void Initialize(void);
|
||||
|
||||
/** Returns the associated BlockInfo structure. */
|
||||
static BlockInfo & GetById(unsigned int a_ID);
|
||||
static cBlockInfo & GetById(unsigned int a_ID);
|
||||
|
||||
|
||||
/** How much light do the blocks emit on their own? */
|
||||
NIBBLETYPE m_LightValue;
|
||||
|
||||
/** How much light do the blocks consume? */
|
||||
NIBBLETYPE m_SpreadLightFalloff;
|
||||
|
||||
/** Is a block completely transparent? (light doesn't get decreased(?)) */
|
||||
bool m_Transparent;
|
||||
|
||||
/** Is a block destroyed after a single hit? */
|
||||
bool m_OneHitDig;
|
||||
|
||||
/** Can a piston break this block? */
|
||||
bool m_PistonBreakable;
|
||||
|
||||
/** Can this block hold snow atop? */
|
||||
bool m_IsSnowable;
|
||||
|
||||
/** Does this block require a tool to drop? */
|
||||
bool m_RequiresSpecialTool;
|
||||
|
||||
/** Is this block solid (player cannot walk through)? */
|
||||
bool m_IsSolid;
|
||||
|
||||
/** Does this block fully occupy it's voxel - is it a 'full' block? */
|
||||
bool m_FullyOccupiesVoxel;
|
||||
|
||||
|
||||
@ -34,7 +51,7 @@ public:
|
||||
inline static NIBBLETYPE GetSpreadLightFalloff(unsigned int a_ID) { return GetById(a_ID).m_SpreadLightFalloff; }
|
||||
inline static bool IsTransparent (unsigned int a_ID) { return GetById(a_ID).m_Transparent; }
|
||||
inline static bool IsOneHitDig (unsigned int a_ID) { return GetById(a_ID).m_OneHitDig; }
|
||||
inline static bool IsPistoneBreakable (unsigned int a_ID) { return GetById(a_ID).m_PistonBreakable; }
|
||||
inline static bool IsPistonBreakable (unsigned int a_ID) { return GetById(a_ID).m_PistonBreakable; }
|
||||
inline static bool IsSnowable (unsigned int a_ID) { return GetById(a_ID).m_IsSnowable; }
|
||||
inline static bool RequiresSpecialTool (unsigned int a_ID) { return GetById(a_ID).m_RequiresSpecialTool; }
|
||||
inline static bool IsSolid (unsigned int a_ID) { return GetById(a_ID).m_IsSolid; }
|
||||
@ -44,7 +61,7 @@ public:
|
||||
protected:
|
||||
|
||||
// TODO xdot: Change to std::vector to support dynamic block IDs
|
||||
static BlockInfo ms_Info[256];
|
||||
static cBlockInfo ms_Info[256];
|
||||
|
||||
|
||||
};
|
||||
|
@ -101,7 +101,7 @@ public:
|
||||
AddFaceDirection(a_RelX, a_RelY, a_RelZ, BlockMetaDataToBlockFace(Meta), true);
|
||||
BLOCKTYPE BlockIsOn; a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, BlockIsOn);
|
||||
|
||||
return (a_RelY > 0) && (g_BlockIsSolid[BlockIsOn]);
|
||||
return (a_RelY > 0) && (cBlockInfo::IsSolid(BlockIsOn));
|
||||
}
|
||||
} ;
|
||||
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
NIBBLETYPE BlockMeta;
|
||||
if (
|
||||
a_Chunk.UnboundedRelGetBlock(a_RelX + Coords[i].x, a_RelY, a_RelZ + Coords[i].z, BlockType, BlockMeta) &&
|
||||
(g_BlockIsSolid[BlockType])
|
||||
cBlockInfo::IsSolid(BlockType)
|
||||
)
|
||||
{
|
||||
return false;
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
if (a_RelY < cChunkDef::Height - 1)
|
||||
{
|
||||
BLOCKTYPE Above = a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ);
|
||||
if ((!g_BlockTransparent[Above] && !g_BlockOneHitDig[Above]) || IsBlockWater(Above))
|
||||
if ((!cBlockInfo::IsTransparent(Above) && !cBlockInfo::IsOneHitDig(Above)) || IsBlockWater(Above))
|
||||
{
|
||||
a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_DIRT, E_META_DIRT_NORMAL);
|
||||
return;
|
||||
@ -77,7 +77,7 @@ public:
|
||||
BLOCKTYPE AboveDest;
|
||||
NIBBLETYPE AboveMeta;
|
||||
Chunk->GetBlockTypeMeta(BlockX, BlockY + 1, BlockZ, AboveDest, AboveMeta);
|
||||
if ((g_BlockOneHitDig[AboveDest] || g_BlockTransparent[AboveDest]) && !IsBlockWater(AboveDest))
|
||||
if ((cBlockInfo::IsOneHitDig(AboveDest) || cBlockInfo::IsTransparent(AboveDest)) && !IsBlockWater(AboveDest))
|
||||
{
|
||||
Chunk->FastSetBlock(BlockX, BlockY, BlockZ, E_BLOCK_GRASS, 0);
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public:
|
||||
|
||||
AddFaceDirection( a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, true);
|
||||
|
||||
return g_BlockIsSolid[a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ)];
|
||||
return cBlockInfo::IsSolid(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ));
|
||||
}
|
||||
|
||||
|
||||
|
@ -102,7 +102,7 @@ public:
|
||||
AddFaceDirection(a_RelX, a_RelY, a_RelZ, BlockMetaDataToBlockFace(Meta), true);
|
||||
BLOCKTYPE BlockIsOn; a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, BlockIsOn);
|
||||
|
||||
return (a_RelY > 0) && (g_BlockIsSolid[BlockIsOn]);
|
||||
return (a_RelY > 0) && cBlockInfo::IsSolid(BlockIsOn);
|
||||
}
|
||||
} ;
|
||||
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!g_BlockIsSolid[a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)])
|
||||
if (!cBlockInfo::IsSolid(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -130,7 +130,7 @@ public:
|
||||
// Too close to the edge, cannot simulate
|
||||
return true;
|
||||
}
|
||||
return g_BlockIsSolid[BlockType];
|
||||
return cBlockInfo::IsSolid(BlockType);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
|
||||
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
|
||||
{
|
||||
return ((a_RelY > 0) && g_BlockFullyOccupiesVoxel[a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)]);
|
||||
return ((a_RelY > 0) && cBlockInfo::FullyOccupiesVoxel(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
BLOCKTYPE BlockBelow = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ);
|
||||
NIBBLETYPE MetaBelow = a_Chunk.GetMeta(a_RelX, a_RelY - 1, a_RelZ);
|
||||
|
||||
if (g_BlockIsSnowable[BlockBelow] || ((BlockBelow == E_BLOCK_SNOW) && (MetaBelow == 7)))
|
||||
if (cBlockInfo::IsSnowable(BlockBelow) || ((BlockBelow == E_BLOCK_SNOW) && (MetaBelow == 7)))
|
||||
{
|
||||
// If block below is snowable, or it is a thin slow block and has a meta of 7 (full thin snow block), say yay
|
||||
return true;
|
||||
|
@ -99,7 +99,7 @@ public:
|
||||
|
||||
static bool CanBePlacedOn(BLOCKTYPE a_BlockType, eBlockFace a_BlockFace)
|
||||
{
|
||||
if ( !g_BlockFullyOccupiesVoxel[a_BlockType] )
|
||||
if ( !cBlockInfo::FullyOccupiesVoxel(a_BlockType) )
|
||||
{
|
||||
return (a_BlockFace == BLOCK_FACE_TOP); // Allow placement only when torch upright (for glass, etc.); exceptions won't even be sent by client, no need to handle
|
||||
}
|
||||
@ -129,7 +129,7 @@ public:
|
||||
{
|
||||
return Face;
|
||||
}
|
||||
else if ((g_BlockFullyOccupiesVoxel[BlockInQuestion]) && (i != BLOCK_FACE_BOTTOM))
|
||||
else if (cBlockInfo::FullyOccupiesVoxel(BlockInQuestion) && (i != BLOCK_FACE_BOTTOM))
|
||||
{
|
||||
// Otherwise, if block in that direction is torch placeable and we haven't gotten to it via the bottom face, return that face
|
||||
return Face;
|
||||
@ -163,7 +163,7 @@ public:
|
||||
// No need to check for upright orientation, it was done when the torch was placed
|
||||
return true;
|
||||
}
|
||||
else if ( !g_BlockFullyOccupiesVoxel[BlockInQuestion] )
|
||||
else if ( !cBlockInfo::FullyOccupiesVoxel(BlockInQuestion) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public:
|
||||
AddFaceDirection(a_RelX, a_RelY, a_RelZ, BlockMetaDataToBlockFace(Meta), true);
|
||||
BLOCKTYPE BlockIsOn; a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, BlockIsOn);
|
||||
|
||||
return (a_RelY > 0) && (g_BlockIsSolid[BlockIsOn]);
|
||||
return (a_RelY > 0) && cBlockInfo::IsSolid(BlockIsOn);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
/// Returns true if the specified block type is good for vines to attach to
|
||||
static bool IsBlockAttachable(BLOCKTYPE a_BlockType)
|
||||
{
|
||||
return (a_BlockType == E_BLOCK_LEAVES) || g_BlockIsSolid[a_BlockType];
|
||||
return (a_BlockType == E_BLOCK_LEAVES) || cBlockInfo::IsSolid(a_BlockType);
|
||||
}
|
||||
|
||||
|
||||
|
@ -883,7 +883,7 @@ void cChunk::ApplyWeatherToTop()
|
||||
FastSetBlock(X, Height, Z, E_BLOCK_SNOW, TopMeta - 1);
|
||||
}
|
||||
}
|
||||
else if (g_BlockIsSnowable[TopBlock])
|
||||
else if (cBlockInfo::IsSnowable(TopBlock))
|
||||
{
|
||||
SetBlock(X, Height + 1, Z, E_BLOCK_SNOW, 0);
|
||||
}
|
||||
@ -1540,10 +1540,10 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT
|
||||
SetNibble(m_BlockMeta, index, a_BlockMeta);
|
||||
|
||||
// ONLY recalculate lighting if it's necessary!
|
||||
if(
|
||||
(g_BlockLightValue[OldBlockType ] != g_BlockLightValue[a_BlockType]) ||
|
||||
(g_BlockSpreadLightFalloff[OldBlockType] != g_BlockSpreadLightFalloff[a_BlockType]) ||
|
||||
(g_BlockTransparent[OldBlockType] != g_BlockTransparent[a_BlockType])
|
||||
if (
|
||||
(cBlockInfo::GetLightValue (OldBlockType) != cBlockInfo::GetLightValue (a_BlockType)) ||
|
||||
(cBlockInfo::GetSpreadLightFalloff(OldBlockType) != cBlockInfo::GetSpreadLightFalloff(a_BlockType)) ||
|
||||
(cBlockInfo::IsTransparent (OldBlockType) != cBlockInfo::IsTransparent (a_BlockType))
|
||||
)
|
||||
{
|
||||
m_IsLightValid = false;
|
||||
|
@ -819,7 +819,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc
|
||||
|
||||
if (
|
||||
(m_Player->IsGameModeCreative()) || // In creative mode, digging is done immediately
|
||||
g_BlockOneHitDig[a_OldBlock] // One-hit blocks get destroyed immediately, too
|
||||
cBlockInfo::IsOneHitDig(a_OldBlock) // One-hit blocks get destroyed immediately, too
|
||||
)
|
||||
{
|
||||
HandleBlockDigFinished(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_OldBlock, a_OldMeta);
|
||||
|
@ -654,7 +654,7 @@ namespace ItemCategory
|
||||
inline bool BlockRequiresSpecialTool(BLOCKTYPE a_BlockType)
|
||||
{
|
||||
if(!IsValidBlock(a_BlockType)) return false;
|
||||
return g_BlockRequiresSpecialTool[a_BlockType];
|
||||
return cBlockInfo::RequiresSpecialTool(a_BlockType);
|
||||
}
|
||||
|
||||
|
||||
|
@ -582,11 +582,11 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
||||
int RelBlockZ = BlockZ - (NextChunk->GetPosZ() * cChunkDef::Width);
|
||||
BLOCKTYPE BlockIn = NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ );
|
||||
BLOCKTYPE BlockBelow = (BlockY > 0) ? NextChunk->GetBlock(RelBlockX, BlockY - 1, RelBlockZ) : E_BLOCK_AIR;
|
||||
if (!g_BlockIsSolid[BlockIn]) // Making sure we are not inside a solid block
|
||||
if (!cBlockInfo::IsSolid(BlockIn)) // Making sure we are not inside a solid block
|
||||
{
|
||||
if (m_bOnGround) // check if it's still on the ground
|
||||
{
|
||||
if (!g_BlockIsSolid[BlockBelow]) // Check if block below is air or water.
|
||||
if (!cBlockInfo::IsSolid(BlockBelow)) // Check if block below is air or water.
|
||||
{
|
||||
m_bOnGround = false;
|
||||
}
|
||||
@ -616,7 +616,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
||||
// The pickup is too close to an unloaded chunk, bail out of any physics handling
|
||||
return;
|
||||
}
|
||||
if (!g_BlockIsSolid[GotBlock])
|
||||
if (!cBlockInfo::IsSolid(GotBlock))
|
||||
{
|
||||
NextPos.x += gCrossCoords[i].x;
|
||||
NextPos.z += gCrossCoords[i].z;
|
||||
|
@ -720,7 +720,7 @@ bool cMinecart::TestBlockCollision(NIBBLETYPE a_RailMeta)
|
||||
if (GetSpeedZ() > 0)
|
||||
{
|
||||
BLOCKTYPE Block = m_World->GetBlock((int)floor(GetPosX()), (int)floor(GetPosY()), (int)ceil(GetPosZ()));
|
||||
if (!IsBlockRail(Block) && g_BlockIsSolid[Block])
|
||||
if (!IsBlockRail(Block) && cBlockInfo::IsSolid(Block))
|
||||
{
|
||||
// We could try to detect a block in front based purely on coordinates, but xoft made a bounding box system - why not use? :P
|
||||
cBoundingBox bbBlock(Vector3d((int)floor(GetPosX()), (int)floor(GetPosY()), (int)ceil(GetPosZ())), 0.5, 1);
|
||||
@ -737,7 +737,7 @@ bool cMinecart::TestBlockCollision(NIBBLETYPE a_RailMeta)
|
||||
else if (GetSpeedZ() < 0)
|
||||
{
|
||||
BLOCKTYPE Block = m_World->GetBlock((int)floor(GetPosX()), (int)floor(GetPosY()), (int)floor(GetPosZ()) - 1);
|
||||
if (!IsBlockRail(Block) && g_BlockIsSolid[Block])
|
||||
if (!IsBlockRail(Block) && cBlockInfo::IsSolid(Block))
|
||||
{
|
||||
cBoundingBox bbBlock(Vector3d((int)floor(GetPosX()), (int)floor(GetPosY()), (int)floor(GetPosZ()) - 1), 0.5, 1);
|
||||
cBoundingBox bbMinecart(Vector3d(GetPosX(), floor(GetPosY()), GetPosZ() - 1), GetWidth() / 2, GetHeight());
|
||||
@ -757,7 +757,7 @@ bool cMinecart::TestBlockCollision(NIBBLETYPE a_RailMeta)
|
||||
if (GetSpeedX() > 0)
|
||||
{
|
||||
BLOCKTYPE Block = m_World->GetBlock((int)ceil(GetPosX()), (int)floor(GetPosY()), (int)floor(GetPosZ()));
|
||||
if (!IsBlockRail(Block) && g_BlockIsSolid[Block])
|
||||
if (!IsBlockRail(Block) && cBlockInfo::IsSolid(Block))
|
||||
{
|
||||
cBoundingBox bbBlock(Vector3d((int)ceil(GetPosX()), (int)floor(GetPosY()), (int)floor(GetPosZ())), 0.5, 1);
|
||||
cBoundingBox bbMinecart(Vector3d(GetPosX(), floor(GetPosY()), GetPosZ()), GetWidth() / 2, GetHeight());
|
||||
@ -773,7 +773,7 @@ bool cMinecart::TestBlockCollision(NIBBLETYPE a_RailMeta)
|
||||
else if (GetSpeedX() < 0)
|
||||
{
|
||||
BLOCKTYPE Block = m_World->GetBlock((int)floor(GetPosX()) - 1, (int)floor(GetPosY()), (int)floor(GetPosZ()));
|
||||
if (!IsBlockRail(Block) && g_BlockIsSolid[Block])
|
||||
if (!IsBlockRail(Block) && cBlockInfo::IsSolid(Block))
|
||||
{
|
||||
cBoundingBox bbBlock(Vector3d((int)floor(GetPosX()) - 1, (int)floor(GetPosY()), (int)floor(GetPosZ())), 0.5, 1);
|
||||
cBoundingBox bbMinecart(Vector3d(GetPosX() - 1, floor(GetPosY()), GetPosZ()), GetWidth() / 2, GetHeight());
|
||||
@ -798,10 +798,10 @@ bool cMinecart::TestBlockCollision(NIBBLETYPE a_RailMeta)
|
||||
BLOCKTYPE BlockZM = m_World->GetBlock((int)floor(GetPosX()), (int)floor(GetPosY()), (int)floor(GetPosZ()) + 1);
|
||||
BLOCKTYPE BlockZP = m_World->GetBlock((int)floor(GetPosX()), (int)floor(GetPosY()), (int)floor(GetPosZ()) + 1);
|
||||
if (
|
||||
(!IsBlockRail(BlockXM) && g_BlockIsSolid[BlockXM]) ||
|
||||
(!IsBlockRail(BlockXP) && g_BlockIsSolid[BlockXP]) ||
|
||||
(!IsBlockRail(BlockZM) && g_BlockIsSolid[BlockZM]) ||
|
||||
(!IsBlockRail(BlockZP) && g_BlockIsSolid[BlockZP])
|
||||
(!IsBlockRail(BlockXM) && cBlockInfo::IsSolid(BlockXM)) ||
|
||||
(!IsBlockRail(BlockXP) && cBlockInfo::IsSolid(BlockXP)) ||
|
||||
(!IsBlockRail(BlockZM) && cBlockInfo::IsSolid(BlockZM)) ||
|
||||
(!IsBlockRail(BlockZP) && cBlockInfo::IsSolid(BlockZP))
|
||||
)
|
||||
{
|
||||
SetSpeed(0, 0, 0);
|
||||
|
@ -1904,7 +1904,7 @@ void cPlayer::Detach()
|
||||
{
|
||||
for (int z = PosZ - 2; z <= (PosZ + 2); ++z)
|
||||
{
|
||||
if (!g_BlockIsSolid[m_World->GetBlock(x, y, z)] && g_BlockIsSolid[m_World->GetBlock(x, y - 1, z)])
|
||||
if (!cBlockInfo::IsSolid(m_World->GetBlock(x, y, z)) && cBlockInfo::IsSolid(m_World->GetBlock(x, y - 1, z)))
|
||||
{
|
||||
TeleportToCoords(x, y, z);
|
||||
return;
|
||||
|
@ -50,12 +50,12 @@ protected:
|
||||
LOGD("Hit block %d:%d at {%d, %d, %d} face %d, %s (%s)",
|
||||
a_BlockType, a_BlockMeta,
|
||||
a_BlockX, a_BlockY, a_BlockZ, a_EntryFace,
|
||||
g_BlockIsSolid[a_BlockType] ? "solid" : "non-solid",
|
||||
cBlockInfo::IsSolid(a_BlockType) ? "solid" : "non-solid",
|
||||
ItemToString(cItem(a_BlockType, 1, a_BlockMeta)).c_str()
|
||||
);
|
||||
*/
|
||||
|
||||
if (g_BlockIsSolid[a_BlockType])
|
||||
if (cBlockInfo::IsSolid(a_BlockType))
|
||||
{
|
||||
// The projectile hit a solid block
|
||||
// Calculate the exact hit coords:
|
||||
|
@ -88,7 +88,7 @@ void cFinishGenNetherClumpFoliage::GenFinish(cChunkDesc & a_ChunkDesc)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!g_BlockIsSolid[a_ChunkDesc.GetBlockType(PosX, y - 1, PosZ)]) // Only place on solid blocks
|
||||
if (!cBlockInfo::IsSolid(a_ChunkDesc.GetBlockType(PosX, y - 1, PosZ))) // Only place on solid blocks
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -131,7 +131,7 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a
|
||||
}
|
||||
|
||||
BLOCKTYPE BlockBelow = a_ChunkDesc.GetBlockType(x, y - 1, z);
|
||||
if (!g_BlockIsSolid[BlockBelow]) // Only place on solid blocks
|
||||
if (!cBlockInfo::IsSolid(BlockBelow)) // Only place on solid blocks
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -329,7 +329,7 @@ void cFinishGenSnow::GenFinish(cChunkDesc & a_ChunkDesc)
|
||||
case biFrozenOcean:
|
||||
{
|
||||
int Height = a_ChunkDesc.GetHeight(x, z);
|
||||
if (g_BlockIsSnowable[a_ChunkDesc.GetBlockType(x, Height, z)])
|
||||
if (cBlockInfo::IsSnowable(a_ChunkDesc.GetBlockType(x, Height, z)))
|
||||
{
|
||||
a_ChunkDesc.SetBlockType(x, Height + 1, z, E_BLOCK_SNOW);
|
||||
a_ChunkDesc.SetHeight(x, z, Height + 1);
|
||||
|
@ -250,6 +250,7 @@ T Clamp(T a_Value, T a_Min, T a_Max)
|
||||
#include "ChunkDef.h"
|
||||
#include "BiomeDef.h"
|
||||
#include "BlockID.h"
|
||||
#include "BlockInfo.h"
|
||||
#include "Entities/Effects.h"
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
{
|
||||
if (!g_BlockFullyOccupiesVoxel[a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ)]) // Some solid blocks, such as cocoa beans, are not suitable for dust
|
||||
if (!cBlockInfo::FullyOccupiesVoxel(a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ))) // Some solid blocks, such as cocoa beans, are not suitable for dust
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ void cLightingThread::PrepareBlockLight(void)
|
||||
int idx = BaseZ + x;
|
||||
for (int y = m_HeightMap[idx], Index = idx + y * BlocksPerYLayer; y >= 0; y--, Index -= BlocksPerYLayer)
|
||||
{
|
||||
if (g_BlockLightValue[m_BlockTypes[Index]] == 0)
|
||||
if (cBlockInfo::GetLightValue(m_BlockTypes[Index]) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -401,7 +401,7 @@ void cLightingThread::PrepareBlockLight(void)
|
||||
m_SeedIdx1[m_NumSeeds++] = Index;
|
||||
|
||||
// Light it up:
|
||||
m_BlockLight[Index] = g_BlockLightValue[m_BlockTypes[Index]];
|
||||
m_BlockLight[Index] = cBlockInfo::GetLightValue(m_BlockTypes[Index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -169,13 +169,13 @@ protected:
|
||||
ASSERT(a_DstIdx >= 0);
|
||||
ASSERT(a_DstIdx < (int)ARRAYCOUNT(m_BlockTypes));
|
||||
|
||||
if (a_Light[a_SrcIdx] <= a_Light[a_DstIdx] + g_BlockSpreadLightFalloff[m_BlockTypes[a_DstIdx]])
|
||||
if (a_Light[a_SrcIdx] <= a_Light[a_DstIdx] + cBlockInfo::GetSpreadLightFalloff(m_BlockTypes[a_DstIdx]))
|
||||
{
|
||||
// We're not offering more light than the dest block already has
|
||||
return;
|
||||
}
|
||||
|
||||
a_Light[a_DstIdx] = a_Light[a_SrcIdx] - g_BlockSpreadLightFalloff[m_BlockTypes[a_DstIdx]];
|
||||
a_Light[a_DstIdx] = a_Light[a_SrcIdx] - cBlockInfo::GetSpreadLightFalloff(m_BlockTypes[a_DstIdx]);
|
||||
if (!a_IsSeedOut[a_DstIdx])
|
||||
{
|
||||
a_IsSeedOut[a_DstIdx] = true;
|
||||
|
@ -145,7 +145,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
||||
|
||||
case cMonster::mtBat:
|
||||
{
|
||||
return (a_RelY <= 63) && (BlockLight <= 4) && (SkyLight <= 4) && (TargetBlock == E_BLOCK_AIR) && (!g_BlockTransparent[BlockAbove]);
|
||||
return (a_RelY <= 63) && (BlockLight <= 4) && (SkyLight <= 4) && (TargetBlock == E_BLOCK_AIR) && !cBlockInfo::IsTransparent(BlockAbove);
|
||||
}
|
||||
|
||||
case cMonster::mtChicken:
|
||||
@ -157,7 +157,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
||||
return (
|
||||
(TargetBlock == E_BLOCK_AIR) &&
|
||||
(BlockAbove == E_BLOCK_AIR) &&
|
||||
(!g_BlockTransparent[BlockBelow]) &&
|
||||
(!cBlockInfo::IsTransparent(BlockBelow)) &&
|
||||
(BlockBelow == E_BLOCK_GRASS) &&
|
||||
(SkyLight >= 9)
|
||||
);
|
||||
@ -188,7 +188,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
||||
(TargetBlock == E_BLOCK_AIR) &&
|
||||
(BlockAbove == E_BLOCK_AIR) &&
|
||||
(BlockTop == E_BLOCK_AIR) &&
|
||||
(!g_BlockTransparent[BlockBelow]) &&
|
||||
(!cBlockInfo::IsTransparent(BlockBelow)) &&
|
||||
(SkyLight <= 7) &&
|
||||
(BlockLight <= 7)
|
||||
);
|
||||
@ -215,7 +215,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
||||
HaveFloor ||
|
||||
(
|
||||
a_Chunk->UnboundedRelGetBlockType(a_RelX + x, a_RelY - 1, a_RelZ + z, TargetBlock) &&
|
||||
!g_BlockTransparent[TargetBlock]
|
||||
!cBlockInfo::IsTransparent(TargetBlock)
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -230,7 +230,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
||||
return (
|
||||
(TargetBlock == E_BLOCK_AIR) &&
|
||||
(BlockAbove == E_BLOCK_AIR) &&
|
||||
(!g_BlockTransparent[BlockBelow]) &&
|
||||
(!cBlockInfo::IsTransparent(BlockBelow)) &&
|
||||
(SkyLight <= 7) &&
|
||||
(BlockLight <= 7) &&
|
||||
(m_Random.NextInt(2, a_Biome) == 0)
|
||||
@ -242,7 +242,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
||||
return (
|
||||
(TargetBlock == E_BLOCK_AIR) &&
|
||||
(BlockAbove == E_BLOCK_AIR) &&
|
||||
(!g_BlockTransparent[BlockBelow]) &&
|
||||
(!cBlockInfo::IsTransparent(BlockBelow)) &&
|
||||
(
|
||||
(a_RelY <= 40) || (a_Biome == biSwampland)
|
||||
)
|
||||
@ -255,7 +255,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
||||
return (
|
||||
(TargetBlock == E_BLOCK_AIR) &&
|
||||
(BlockAbove == E_BLOCK_AIR) &&
|
||||
(!g_BlockTransparent[BlockBelow]) &&
|
||||
(!cBlockInfo::IsTransparent(BlockBelow)) &&
|
||||
(m_Random.NextInt(20, a_Biome) == 0)
|
||||
);
|
||||
}
|
||||
|
@ -148,11 +148,11 @@ void cMonster::TickPathFinding()
|
||||
BLOCKTYPE BlockAtYPP = m_World->GetBlock(gCrossCoords[i].x + PosX, PosY + 2, gCrossCoords[i].z + PosZ);
|
||||
BLOCKTYPE BlockAtYM = m_World->GetBlock(gCrossCoords[i].x + PosX, PosY - 1, gCrossCoords[i].z + PosZ);
|
||||
|
||||
if ((!g_BlockIsSolid[BlockAtY]) && (!g_BlockIsSolid[BlockAtYP]) && (!IsBlockLava(BlockAtYM)) && (BlockAtY != E_BLOCK_FENCE) && (BlockAtY != E_BLOCK_FENCE_GATE))
|
||||
if ((!cBlockInfo::IsSolid(BlockAtY)) && (!cBlockInfo::IsSolid(BlockAtYP)) && (!IsBlockLava(BlockAtYM)) && (BlockAtY != E_BLOCK_FENCE) && (BlockAtY != E_BLOCK_FENCE_GATE))
|
||||
{
|
||||
m_PotentialCoordinates.push_back(Vector3d((gCrossCoords[i].x + PosX), PosY, gCrossCoords[i].z + PosZ));
|
||||
}
|
||||
else if ((g_BlockIsSolid[BlockAtY]) && (!g_BlockIsSolid[BlockAtYP]) && (!g_BlockIsSolid[BlockAtYPP]) && (!IsBlockLava(BlockAtYM)) && (BlockAtY != E_BLOCK_FENCE) && (BlockAtY != E_BLOCK_FENCE_GATE))
|
||||
else if ((cBlockInfo::IsSolid(BlockAtY)) && (!cBlockInfo::IsSolid(BlockAtYP)) && (!cBlockInfo::IsSolid(BlockAtYPP)) && (!IsBlockLava(BlockAtYM)) && (BlockAtY != E_BLOCK_FENCE) && (BlockAtY != E_BLOCK_FENCE_GATE))
|
||||
{
|
||||
m_PotentialCoordinates.push_back(Vector3d((gCrossCoords[i].x + PosX), PosY + 1, gCrossCoords[i].z + PosZ));
|
||||
}
|
||||
@ -416,9 +416,9 @@ int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ)
|
||||
else if (PosY > cChunkDef::Height)
|
||||
PosY = cChunkDef::Height;
|
||||
|
||||
if (!g_BlockIsSolid[m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ))])
|
||||
if (!cBlockInfo::IsSolid(m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ))))
|
||||
{
|
||||
while (!g_BlockIsSolid[m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ))] && (PosY > 0))
|
||||
while (!cBlockInfo::IsSolid(m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ))) && (PosY > 0))
|
||||
{
|
||||
PosY--;
|
||||
}
|
||||
@ -427,7 +427,7 @@ int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ)
|
||||
}
|
||||
else
|
||||
{
|
||||
while (g_BlockIsSolid[m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ))] && (PosY < cChunkDef::Height))
|
||||
while (cBlockInfo::IsSolid(m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ))) && (PosY < cChunkDef::Height))
|
||||
{
|
||||
PosY++;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ void cSnowGolem::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
{
|
||||
BLOCKTYPE BlockBelow = m_World->GetBlock((int) floor(GetPosX()), (int) floor(GetPosY()) - 1, (int) floor(GetPosZ()));
|
||||
BLOCKTYPE Block = m_World->GetBlock((int) floor(GetPosX()), (int) floor(GetPosY()), (int) floor(GetPosZ()));
|
||||
if (Block == E_BLOCK_AIR && g_BlockIsSolid[BlockBelow])
|
||||
if (Block == E_BLOCK_AIR && cBlockInfo::IsSolid(BlockBelow))
|
||||
{
|
||||
m_World->SetBlock((int) floor(GetPosX()), (int) floor(GetPosY()), (int) floor(GetPosZ()), E_BLOCK_SNOW, 0);
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ bool cPiston::CanPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
||||
bool cPiston::CanBreakPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
||||
{
|
||||
UNUSED(a_BlockMeta);
|
||||
return g_BlockPistonBreakable[a_BlockType];
|
||||
return cBlockInfo::IsPistonBreakable(a_BlockType);
|
||||
}
|
||||
|
||||
|
||||
|
@ -239,7 +239,7 @@ int cFireSimulator::GetBurnStepTime(cChunk * a_Chunk, int a_RelX, int a_RelY, in
|
||||
{
|
||||
return m_BurnStepTimeFuel;
|
||||
}
|
||||
IsBlockBelowSolid = g_BlockIsSolid[BlockBelow];
|
||||
IsBlockBelowSolid = cBlockInfo::IsSolid(BlockBelow);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++)
|
||||
|
@ -566,14 +566,14 @@ void cIncrementalRedstoneSimulator::HandleRedstoneWire(int a_BlockX, int a_Block
|
||||
{
|
||||
if ((i >= 4) && (i <= 7)) // If we are currently checking for wire surrounding ourself one block above...
|
||||
{
|
||||
if (g_BlockIsSolid[m_World.GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ)]) // If there is something solid above us (wire cut off)...
|
||||
if (cBlockInfo::IsSolid(m_World.GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ))) // If there is something solid above us (wire cut off)...
|
||||
{
|
||||
continue; // We don't receive power from that wire
|
||||
}
|
||||
}
|
||||
else if ((i >= 8) && (i <= 11)) // See above, but this is for wire below us
|
||||
{
|
||||
if (g_BlockIsSolid[m_World.GetBlock(a_BlockX + gCrossCoords[i].x, a_BlockY + gCrossCoords[i].y + 1, a_BlockZ + gCrossCoords[i].z)])
|
||||
if (cBlockInfo::IsSolid(m_World.GetBlock(a_BlockX + gCrossCoords[i].x, a_BlockY + gCrossCoords[i].y + 1, a_BlockZ + gCrossCoords[i].z)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ private:
|
||||
|
||||
/* ====== Misc Functions ====== */
|
||||
/** Returns if a block is viable to be the MiddleBlock of a SetLinkedPowered operation */
|
||||
inline static bool IsViableMiddleBlock(BLOCKTYPE Block) { return g_BlockFullyOccupiesVoxel[Block]; }
|
||||
inline static bool IsViableMiddleBlock(BLOCKTYPE Block) { return cBlockInfo::FullyOccupiesVoxel(Block); }
|
||||
|
||||
/** Returns if a block is a mechanism (something that accepts power and does something) */
|
||||
inline static bool IsMechanism(BLOCKTYPE Block)
|
||||
|
@ -226,7 +226,7 @@ bool cTracer::Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int
|
||||
BLOCKTYPE BlockID = m_World->GetBlock(pos.x, pos.y, pos.z);
|
||||
// Block is counted as a collision if we are not doing a line of sight and it is solid,
|
||||
// or if the block is not air and not water. That way mobs can still see underwater.
|
||||
if ((!a_LineOfSight && g_BlockIsSolid[BlockID]) || (a_LineOfSight && (BlockID != E_BLOCK_AIR) && !IsBlockWater(BlockID)))
|
||||
if ((!a_LineOfSight && cBlockInfo::IsSolid(BlockID)) || (a_LineOfSight && (BlockID != E_BLOCK_AIR) && !IsBlockWater(BlockID)))
|
||||
{
|
||||
BlockHitPosition = pos;
|
||||
int Normal = GetHitNormal(a_Start, End, pos );
|
||||
|
Loading…
Reference in New Issue
Block a user