From 66a164a9a75a2d48763520aab3aeb8eeda85c92d Mon Sep 17 00:00:00 2001 From: Mattes D Date: Wed, 1 Jul 2015 10:40:16 +0200 Subject: Added neighbor specification in the OnNeighborChanged() block callback. Fixes the OnNeighborChanged endless recursion with large melon / pumpkin fields. Fixes #2213. --- src/Blocks/BlockHandler.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/Blocks/BlockHandler.h') diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index a71c70e8b..1b357c3f1 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -56,13 +56,19 @@ public: /// Called before a block gets destroyed / replaced with air virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ); - /// Called when a direct neighbor of this block has been changed (The position is the own position, not the neighbor position) - virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) {} - - /// Notifies all neighbors of the given block about a change - static void NeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ); - - /// Called while the player diggs the block. + /** Called when a direct neighbor of this block has been changed (The position is the block's own position, not the changing neighbor's position) + a_WhichNeighbor indicates which neighbor has changed. For example, BLOCK_FACE_YP meant the neighbor above has changed. + BLOCK_FACE_NONE means that it is a neighbor not directly adjacent (diagonal, etc.) */ + virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_WhichNeighbor) {} + + /** Notifies the specified neighbor that the current block has changed. + a_NeighborXYZ coords are the coords of the neighbor + a_WhichNeighbor specifies which neighbor (relative to a_NeighborXYZ) has changed. + For example BLOCK_FACE_YP means that the block at {a_NeighborX, a_NeighborY + 1, a_NeighborZ} has changed. + BLOCK_FACE_NONE means that it is a neighbor not directly adjacent (diagonal, etc.) */ + static void NeighborChanged(cChunkInterface & a_ChunkInterface, int a_NeighborX, int a_NeighborY, int a_NeighborZ, eBlockFace a_WhichNeighbor); + + /** Called when the player starts digging the block. */ virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) {} /// Called if the user right clicks the block and the block is useable -- cgit v1.2.3