summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/cChunk.cpp1
-rw-r--r--source/cClientHandle.cpp54
-rw-r--r--source/cFluidSimulator.cpp36
-rw-r--r--source/cFluidSimulator.h2
4 files changed, 89 insertions, 4 deletions
diff --git a/source/cChunk.cpp b/source/cChunk.cpp
index 3af1b0ff3..7eb296abb 100644
--- a/source/cChunk.cpp
+++ b/source/cChunk.cpp
@@ -268,6 +268,7 @@ void cChunk::Tick(float a_Dt)
{
isRedstone = true;
}
+ case E_BLOCK_CACTUS:
case E_BLOCK_REEDS:
case E_BLOCK_WOODEN_PRESSURE_PLATE:
case E_BLOCK_STONE_PRESSURE_PLATE:
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 ))
diff --git a/source/cFluidSimulator.cpp b/source/cFluidSimulator.cpp
index 55a3f549b..318ecfd5c 100644
--- a/source/cFluidSimulator.cpp
+++ b/source/cFluidSimulator.cpp
@@ -4,6 +4,8 @@
#include "BlockID.h"
#include "Defines.h"
#include <vector>
+#include "cPickup.h"
+#include "cItem.h"
class cFluidSimulator::FluidData
{
@@ -170,8 +172,15 @@ void cFluidSimulator::Simulate( float a_Dt )
if( bIsFed )
{
char DownID = m_World->GetBlock( pos.x, pos.y-1, pos.z );
- if( IsPassableForFluid(DownID) ) // free for fluid
+ bool bWashedAwayItem = CanWashAway( DownID );
+ if( IsPassableForFluid(DownID) || bWashedAwayItem ) // free for fluid
{
+ if( bWashedAwayItem )
+ {
+ cPickup* Pickup = new cPickup( pos.x * 32 + 16, (pos.y-1) * 32 + 16, pos.z * 32 + 16, cItem( (ENUM_ITEM_ID)DownID, 1, m_World->GetBlockMeta( pos.x, pos.y-1, pos.z ) ) );
+ Pickup->Initialize( m_World );
+ }
+
m_World->FastSetBlock( pos.x, pos.y-1, pos.z, m_FluidBlock, 8 ); // falling
AddBlock( pos.x, pos.y-1, pos.z );
}
@@ -189,8 +198,15 @@ void cFluidSimulator::Simulate( float a_Dt )
{
Vector3i & p = *itr;
char BlockID = m_World->GetBlock( p.x, p.y, p.z );
+ bool bWashedAwayItem = CanWashAway( BlockID );
if( !IsAllowedBlock( BlockID ) )
{
+ if( bWashedAwayItem )
+ {
+ cPickup* Pickup = new cPickup( p.x * 32 + 16, p.y * 32 + 16, p.z * 32 + 16, cItem( (ENUM_ITEM_ID)BlockID, 1, m_World->GetBlockMeta( p.x, p.y, p.z ) ) );
+ Pickup->Initialize( m_World );
+ }
+
if( p.y == pos.y )
m_World->FastSetBlock(p.x, p.y, p.z, m_FluidBlock, Meta + m_FlowReduction);
else
@@ -223,7 +239,23 @@ bool cFluidSimulator::IsPassableForFluid(char a_BlockID)
{
return a_BlockID == E_BLOCK_AIR
|| a_BlockID == E_BLOCK_FIRE
- || IsAllowedBlock(a_BlockID);
+ || IsAllowedBlock(a_BlockID)
+ || CanWashAway(a_BlockID);
+}
+
+bool cFluidSimulator::CanWashAway( char a_BlockID )
+{
+ switch( a_BlockID )
+ {
+ case E_BLOCK_YELLOW_FLOWER:
+ case E_BLOCK_RED_ROSE:
+ case E_BLOCK_RED_MUSHROOM:
+ case E_BLOCK_BROWN_MUSHROOM:
+ case E_BLOCK_CACTUS:
+ return true;
+ default:
+ return false;
+ };
}
//TODO Not working very well yet :s
diff --git a/source/cFluidSimulator.h b/source/cFluidSimulator.h
index 73c76762e..af05da2dd 100644
--- a/source/cFluidSimulator.h
+++ b/source/cFluidSimulator.h
@@ -30,7 +30,7 @@ public:
virtual inline bool IsAllowedBlock( char a_BlockID ) = 0;
virtual inline bool IsPassableForFluid( char a_BlockID );
-
+ bool CanWashAway( char a_BlockID );
protected:
virtual void AddBlock( int a_X, int a_Y, int a_Z);
char GetHighestLevelAround( int a_X, int a_Y, int a_Z );