summaryrefslogtreecommitdiffstats
path: root/source/cClientHandle.cpp
diff options
context:
space:
mode:
authorfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-01-23 16:11:45 +0100
committerfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-01-23 16:11:45 +0100
commitce11c6b2bd56f976664e7b416204b9128ca780b1 (patch)
treec4f121de68e12e530548362e867019e17071de24 /source/cClientHandle.cpp
parentFixed the  sign bug (diff)
downloadcuberite-ce11c6b2bd56f976664e7b416204b9128ca780b1.tar
cuberite-ce11c6b2bd56f976664e7b416204b9128ca780b1.tar.gz
cuberite-ce11c6b2bd56f976664e7b416204b9128ca780b1.tar.bz2
cuberite-ce11c6b2bd56f976664e7b416204b9128ca780b1.tar.lz
cuberite-ce11c6b2bd56f976664e7b416204b9128ca780b1.tar.xz
cuberite-ce11c6b2bd56f976664e7b416204b9128ca780b1.tar.zst
cuberite-ce11c6b2bd56f976664e7b416204b9128ca780b1.zip
Diffstat (limited to '')
-rw-r--r--source/cClientHandle.cpp54
1 files changed, 53 insertions, 1 deletions
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
index 6e029e14a..9aef2021e 100644
--- a/source/cClientHandle.cpp
+++ b/source/cClientHandle.cpp
@@ -496,7 +496,6 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
Kick("Login Username does not match Handshake username!");
return;
}
- //m_Password = PacketData->m_Password;
if( cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_LOGIN, 1, PacketData ) )
{
@@ -1083,6 +1082,59 @@ void cClientHandle::HandlePacket( cPacket* a_Packet )
break; //happens when you place a block aiming at side of block like torch or stem
}
+ // Check whether selected item is allowed to be placed on specific surface
+ bool bIllegalSurface = false;
+ ENUM_BLOCK_ID SurfaceBlock = (ENUM_BLOCK_ID)m_Player->GetWorld()->GetBlock( X, Y-1, Z );
+ switch( PacketData->m_ItemType )
+ {
+ case E_BLOCK_YELLOW_FLOWER: // Can ONLY be placed on dirt/grass
+ case E_BLOCK_RED_ROSE:
+ case E_BLOCK_SAPLING:
+ switch( SurfaceBlock )
+ {
+ case E_BLOCK_DIRT:
+ case E_BLOCK_GRASS:
+ bIllegalSurface = false;
+ break;
+ default:
+ bIllegalSurface = true;
+ break;
+ };
+ break;
+ case E_BLOCK_BROWN_MUSHROOM: // Can be placed on pretty much anything, with exceptions
+ case E_BLOCK_RED_MUSHROOM:
+ switch( SurfaceBlock )
+ {
+ case E_BLOCK_GLASS:
+ case E_BLOCK_YELLOW_FLOWER:
+ case E_BLOCK_RED_ROSE:
+ case E_BLOCK_BROWN_MUSHROOM:
+ case E_BLOCK_RED_MUSHROOM:
+ case E_BLOCK_CACTUS:
+ bIllegalSurface = true;
+ break;
+ }
+ break;
+ case E_BLOCK_CACTUS:
+ if( SurfaceBlock != E_BLOCK_SAND && SurfaceBlock != E_BLOCK_CACTUS ) // Cactus can only be placed on sand and itself
+ bIllegalSurface = true;
+
+ // Check surroundings. Cacti may ONLY be surrounded by air
+ cWorld* World = m_Player->GetWorld();
+ if( World->GetBlock( X-1, Y, Z ) != E_BLOCK_AIR
+ || World->GetBlock( X+1, Y, Z ) != E_BLOCK_AIR
+ || World->GetBlock( X, Y, Z-1 ) != E_BLOCK_AIR
+ || World->GetBlock( X, Y, Z+1 ) != E_BLOCK_AIR
+ )
+ {
+ bIllegalSurface = true;
+ }
+ break;
+ };
+
+ if( bIllegalSurface )
+ break;
+
if(bRemoveItem)
{
if((m_Player->GetGameMode() != 1) && !m_Player->GetInventory().RemoveItem( Item ))