summaryrefslogtreecommitdiffstats
path: root/source/cFluidSimulator.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/cFluidSimulator.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/cFluidSimulator.cpp36
1 files changed, 34 insertions, 2 deletions
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