diff options
Diffstat (limited to 'source/Blocks')
-rw-r--r-- | source/Blocks/BlockFluid.h | 21 | ||||
-rw-r--r-- | source/Blocks/BlockHandler.cpp | 22 | ||||
-rw-r--r-- | source/Blocks/BlockHandler.h | 6 |
3 files changed, 48 insertions, 1 deletions
diff --git a/source/Blocks/BlockFluid.h b/source/Blocks/BlockFluid.h index 40ff621e4..a8cd9c497 100644 --- a/source/Blocks/BlockFluid.h +++ b/source/Blocks/BlockFluid.h @@ -10,6 +10,8 @@ class cBlockFluidHandler :
public cBlockHandler
{
+ typedef cBlockHandler super;
+
public:
cBlockFluidHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType)
@@ -23,7 +25,24 @@ public: return true;
}
- // TODO: Implement proper fluid physics here
+
+ virtual void Check(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ switch (m_BlockType)
+ {
+ case E_BLOCK_STATIONARY_LAVA:
+ {
+ a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_LAVA, a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ));
+ break;
+ }
+ case E_BLOCK_STATIONARY_WATER:
+ {
+ a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_WATER, a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ));
+ break;
+ }
+ }
+ super::Check(a_World, a_BlockX, a_BlockY, a_BlockZ);
+ }
} ;
diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp index 977bff87f..eb7a40d62 100644 --- a/source/Blocks/BlockHandler.cpp +++ b/source/Blocks/BlockHandler.cpp @@ -387,3 +387,25 @@ bool cBlockHandler::DoesDropOnUnsuitable(void) +
+void cBlockHandler::Check(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
+{
+ if (!CanBeAt(a_World, a_BlockX, a_BlockY, a_BlockZ))
+ {
+ if (DoesDropOnUnsuitable())
+ {
+ DropBlock(a_World, a_BlockX, a_BlockY, a_BlockZ);
+ }
+
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
+ }
+ else
+ {
+ // Wake up the simulators:
+ a_World->GetSimulatorManager()->WakeUp(a_BlockX, a_BlockY, a_BlockZ);
+ }
+}
+
+
+
+
diff --git a/source/Blocks/BlockHandler.h b/source/Blocks/BlockHandler.h index bfe92b676..c2884fe7d 100644 --- a/source/Blocks/BlockHandler.h +++ b/source/Blocks/BlockHandler.h @@ -91,6 +91,12 @@ public: /// Does this block drop if it gets destroyed by an unsuitable situation? Default: true
virtual bool DoesDropOnUnsuitable(void);
+ /** Called when one of the neighbors gets set; equivalent to MC block update.
+ By default drops if position no more suitable (CanBeAt(), DoesDropOnUnsuitable(), Drop()),
+ and wakes up all simulators on the block.
+ */
+ virtual void Check(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ);
+
/// Get the blockhandler for a specific block id
static cBlockHandler * GetBlockHandler(BLOCKTYPE a_BlockType);
|