Entity: Switched detection of ground to use g_BlockIsSolid global variable.

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1499 0a769ca7-a7f5-676a-18bf-c427514a06d6
master
keyboard.osh@gmail.com 2013-05-21 05:51:38 +00:00
parent 088a79211b
commit 8519ff4db9
1 changed files with 16 additions and 16 deletions

View File

@ -225,25 +225,18 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
int RelBlockX = BlockX - (NextChunk->GetPosX() * cChunkDef::Width); int RelBlockX = BlockX - (NextChunk->GetPosX() * cChunkDef::Width);
int RelBlockZ = BlockZ - (NextChunk->GetPosZ() * cChunkDef::Width); int RelBlockZ = BlockZ - (NextChunk->GetPosZ() * cChunkDef::Width);
BLOCKTYPE BlockIn = NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ ); BLOCKTYPE BlockIn = NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ );
if( BlockIn == E_BLOCK_AIR || IsBlockWater(BlockIn) || BlockIn == E_BLOCK_FIRE || IsBlockLava(BlockIn) ) // If not in ground itself or in water or in fire or in lava if(!g_BlockIsSolid[BlockIn]) // Making sure we are not inside a solid block
{ {
if( m_bOnGround ) // check if it's still on the ground if( m_bOnGround ) // check if it's still on the ground
{ {
BLOCKTYPE BlockBelow = NextChunk->GetBlock( RelBlockX, BlockY - 1, RelBlockZ ); BLOCKTYPE BlockBelow = NextChunk->GetBlock( RelBlockX, BlockY - 1, RelBlockZ );
if(BlockBelow == E_BLOCK_AIR || IsBlockWater(BlockBelow) || BlockBelow == E_BLOCK_FIRE || IsBlockLava(BlockBelow)) //Check if block below is air or water. if(!g_BlockIsSolid[BlockBelow]) //Check if block below is air or water.
{ {
m_bOnGround = false; m_bOnGround = false;
} }
} }
} }
else else
{
if (BlockIn == E_BLOCK_COBWEB)
{
NextSpeed.x *= 0.25;
NextSpeed.z *= 0.25;
}
else
{ {
//Push out entity. //Push out entity.
m_bOnGround = true; m_bOnGround = true;
@ -251,7 +244,6 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
LOGD("Entity #%d (%s) is inside a block at {%d,%d,%d}", LOGD("Entity #%d (%s) is inside a block at {%d,%d,%d}",
m_UniqueID, GetClass(), BlockX, BlockY, BlockZ); m_UniqueID, GetClass(), BlockX, BlockY, BlockZ);
} }
}
if (!m_bOnGround) if (!m_bOnGround)
{ {
@ -284,6 +276,14 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
} }
} }
//Adjust X and Z speed for COBWEB temporary. This speed modification should be handled inside block handlers since we
//might have different speed modifiers according to terrain.
if (BlockIn == E_BLOCK_COBWEB)
{
NextSpeed.x *= 0.25;
NextSpeed.z *= 0.25;
}
//Get water direction //Get water direction
Direction WaterDir = m_World->GetWaterSimulator()->GetFlowingDirection(BlockX, BlockY, BlockZ); Direction WaterDir = m_World->GetWaterSimulator()->GetFlowingDirection(BlockX, BlockY, BlockZ);