From 1cca9b13b3d320ff767cfc552413265b2ef6e0d6 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Wed, 6 Jun 2012 20:18:50 +0000 Subject: Item-dropping code rewritten and centralized - now there's only one place to modify if we want to split or merge same-item drops: cWorld:SpawnItemPickups(). Also, mined blocks can now drop more items, and they recognize if they're being mined by the correct tool. git-svn-id: http://mc-server.googlecode.com/svn/trunk@561 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cChunk.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'source/cChunk.cpp') diff --git a/source/cChunk.cpp b/source/cChunk.cpp index c918c589e..6d260e5b1 100644 --- a/source/cChunk.cpp +++ b/source/cChunk.cpp @@ -419,7 +419,8 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom) unsigned int index = (*itr); Vector3i BlockPos = IndexToCoordinate( index ); - char BlockID = GetBlock( index ); + BLOCKTYPE BlockID = GetBlock( index ); + NIBBLETYPE BlockMeta = GetMeta(index); switch ( BlockID ) { case E_BLOCK_REDSTONE_REPEATER_OFF: @@ -443,16 +444,17 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom) case E_BLOCK_RED_MUSHROOM: case E_BLOCK_BROWN_MUSHROOM: // Stuff that drops when block below is destroyed { - if( GetBlock( BlockPos.x, BlockPos.y-1, BlockPos.z ) == E_BLOCK_AIR ) + if (GetBlock(BlockPos.x, BlockPos.y - 1, BlockPos.z) == E_BLOCK_AIR) { SetBlock( BlockPos, E_BLOCK_AIR, 0 ); Vector3i WorldPos = PositionToWorldPosition( BlockPos ); m_World->GetSimulatorManager()->WakeUp(WorldPos.x, WorldPos.y, WorldPos.z); - - cPickup* Pickup = new cPickup( WorldPos.x * 32 + 16, WorldPos.y * 32 + 16, WorldPos.z * 32 + 16, cItem( cBlockToPickup::ToPickup( (ENUM_ITEM_ID)BlockID, E_ITEM_EMPTY) , 1 ) ); - Pickup->Initialize( m_World ); + + cItems Pickups; + cBlockToPickup::ToPickup(BlockID, BlockMeta, E_ITEM_EMPTY, Pickups); + m_World->SpawnItemPickups(Pickups, WorldPos.x, WorldPos.y, WorldPos.z); } break; } @@ -477,8 +479,9 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom) m_World->GetSimulatorManager()->WakeUp(WorldPos.x, WorldPos.y, WorldPos.z); - cPickup* Pickup = new cPickup( WorldPos.x * 32 + 16, WorldPos.y * 32 + 16, WorldPos.z * 32 + 16, cItem( cBlockToPickup::ToPickup( (ENUM_ITEM_ID)BlockID, E_ITEM_EMPTY) , 1 ) ); - Pickup->Initialize( m_World ); + cItems Pickups; + cBlockToPickup::ToPickup(BlockID, BlockMeta, E_ITEM_EMPTY, Pickups); + m_World->SpawnItemPickups(Pickups, WorldPos.x, WorldPos.y, WorldPos.z); } break; } @@ -492,8 +495,9 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom) if( m_World->GetBlock( AttachedTo ) == E_BLOCK_AIR ) { SetBlock( BlockPos, E_BLOCK_AIR, 0 ); - cPickup* Pickup = new cPickup( WorldPos.x * 32 + 16, WorldPos.y * 32 + 16, WorldPos.z * 32 + 16, cItem( (ENUM_ITEM_ID)BlockID, 1 ) ); - Pickup->Initialize( m_World ); + cItems Pickups; + cBlockToPickup::ToPickup(BlockID, BlockMeta, E_ITEM_EMPTY, Pickups); + m_World->SpawnItemPickups(Pickups, WorldPos.x, WorldPos.y, WorldPos.z); } break; } -- cgit v1.2.3