summaryrefslogtreecommitdiffstats
path: root/source/cClientHandle.cpp
diff options
context:
space:
mode:
authorlapayo94@gmail.com <lapayo94@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-12-25 02:40:31 +0100
committerlapayo94@gmail.com <lapayo94@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-12-25 02:40:31 +0100
commitf419ec2fe783ddf4252f50f475c2a5cf9e70038e (patch)
tree901c83eef4027c90c768df2de7cbae2f4e84e1e5 /source/cClientHandle.cpp
parentChunks are generated in a separate thread allowing players to keep on playing and chatting while chunks are generated. This means, however, that cWorld::GetChunk() does not always return a chunk and is something you need to be aware of. I am not entirely sure if all this is completely stable, but I think so :O (diff)
downloadcuberite-f419ec2fe783ddf4252f50f475c2a5cf9e70038e.tar
cuberite-f419ec2fe783ddf4252f50f475c2a5cf9e70038e.tar.gz
cuberite-f419ec2fe783ddf4252f50f475c2a5cf9e70038e.tar.bz2
cuberite-f419ec2fe783ddf4252f50f475c2a5cf9e70038e.tar.lz
cuberite-f419ec2fe783ddf4252f50f475c2a5cf9e70038e.tar.xz
cuberite-f419ec2fe783ddf4252f50f475c2a5cf9e70038e.tar.zst
cuberite-f419ec2fe783ddf4252f50f475c2a5cf9e70038e.zip
Diffstat (limited to 'source/cClientHandle.cpp')
-rw-r--r--source/cClientHandle.cpp51
1 files changed, 25 insertions, 26 deletions
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
index 6725a2156..3d54dc4d9 100644
--- a/source/cClientHandle.cpp
+++ b/source/cClientHandle.cpp
@@ -546,22 +546,26 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
bool bBroken = (PacketData->m_Status == 0x02) || g_BlockOneHitDig[(int)OldBlock] || ( (PacketData->m_Status == 0x00) && (m_Player->GetGameMode() == 1) );
if(bBroken == false) bBroken = (m_Player->GetInventory().GetEquippedItem().m_ItemID == E_ITEM_SHEARS && OldBlock == E_BLOCK_LEAVES);
+ if(OldBlock == E_BLOCK_WOODEN_DOOR && !bBroken)
+ {
+ cDoors::ChangeDoor(m_Player->GetWorld(), PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ);
+ }
+
cItem PickupItem;
if( bBroken && !(m_Player->GetGameMode() == 1) ) // broken
{
+
ENUM_ITEM_ID PickupID = cBlockToPickup::ToPickup( (ENUM_BLOCK_ID)OldBlock, m_Player->GetInventory().GetEquippedItem().m_ItemID );
PickupItem.m_ItemID = PickupID;
PickupItem.m_ItemHealth = MetaData;
- PickupItem.m_ItemCount = 1;
- if( OldBlock == E_BLOCK_LAPIS_ORE ) {
+ PickupItem.m_ItemCount = cBlockToPickup::PickupCount(OldBlock);
+ if( OldBlock == E_BLOCK_LAPIS_ORE )
+ {
PickupItem.m_ItemHealth = 4;
- PickupItem.m_ItemCount = rand()%5+4;
}
- if( OldBlock == E_BLOCK_REDSTONE_ORE || OldBlock == E_BLOCK_REDSTONE_ORE_GLOWING ) {
- PickupItem.m_ItemCount = rand()%2+4;
- }
- if( OldBlock == E_BLOCK_MELON ) {
- PickupItem.m_ItemCount = rand()%8+3;
+ if(cDoors::IsDoor(OldBlock))
+ {
+ PickupItem.m_ItemHealth = 1; //For a complete door this works :D
}
}
if(!cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_BLOCK_DIG, 2, PacketData, m_Player, &PickupItem ) )
@@ -592,6 +596,18 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
}
}
+ if(cDoors::IsDoor(OldBlock)) //Special actions for destroyed door (Destroy second part)
+ {
+ if(MetaData & 8) //was Upper part of door
+ {
+ if(cDoors::IsDoor(World->GetBlock(PacketData->m_PosX, PacketData->m_PosY - 1, PacketData->m_PosZ)))
+ World->SetBlock(PacketData->m_PosX, PacketData->m_PosY - 1, PacketData->m_PosZ, E_BLOCK_AIR, 0);
+ }else{ //Was lower part
+ if(cDoors::IsDoor(World->GetBlock(PacketData->m_PosX, PacketData->m_PosY + 1, PacketData->m_PosZ)))
+ World->SetBlock(PacketData->m_PosX, PacketData->m_PosY + 1, PacketData->m_PosZ, E_BLOCK_AIR, 0);
+ }
+ }
+
int helditem = m_Player->GetInventory().GetEquippedItem().m_ItemID;
bool itemhasdur = false;
switch(helditem)
@@ -752,24 +768,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
case E_BLOCK_WOODEN_DOOR:
{
bPlaceBlock = false;
- char OldMetaData = cRoot::Get()->GetWorld()->GetBlockMeta(PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ);
- char NewMetaData = cDoors::ChangeStateMetaData ( OldMetaData );
- cRoot::Get()->GetWorld()->FastSetBlock(PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ, E_BLOCK_WOODEN_DOOR, NewMetaData );
- if ( (int)OldMetaData > 7 ) { //top of door
- char BottomBlock = cRoot::Get()->GetWorld()->GetBlock(PacketData->m_PosX, PacketData->m_PosY-1, PacketData->m_PosZ);
- char BottomMeta = cRoot::Get()->GetWorld()->GetBlockMeta(PacketData->m_PosX, PacketData->m_PosY-1, PacketData->m_PosZ);
- if ( ( (int)BottomBlock == E_BLOCK_WOODEN_DOOR ) && ( (int)BottomMeta < 8 ) ) {
- char NewBottomMeta = cDoors::ChangeStateMetaData ( BottomMeta );
- cRoot::Get()->GetWorld()->FastSetBlock(PacketData->m_PosX, PacketData->m_PosY-1, PacketData->m_PosZ, E_BLOCK_WOODEN_DOOR, NewBottomMeta );
- }
- } else if ( (int)OldMetaData < 8 ) { //bottom of door
- char TopBlock = cRoot::Get()->GetWorld()->GetBlock(PacketData->m_PosX, PacketData->m_PosY+1, PacketData->m_PosZ);
- char TopMeta = cRoot::Get()->GetWorld()->GetBlockMeta(PacketData->m_PosX, PacketData->m_PosY+1, PacketData->m_PosZ);
- if ( ( (int)TopBlock == E_BLOCK_WOODEN_DOOR ) && ( (int)TopMeta > 7 ) ) {
- char NewTopMeta = cDoors::ChangeStateMetaData ( TopMeta );
- cRoot::Get()->GetWorld()->FastSetBlock(PacketData->m_PosX, PacketData->m_PosY+1, PacketData->m_PosZ, E_BLOCK_WOODEN_DOOR, NewTopMeta );
- }
- }
+ cDoors::ChangeDoor(m_Player->GetWorld(), PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ);
}
break;
default: