From b26e74c3827b14a11466d9e2ada28d673ac5dace Mon Sep 17 00:00:00 2001 From: p2r3 Date: Thu, 28 Aug 2025 01:50:12 +0300 Subject: [PATCH] add option to disable fluid calculation --- include/globals.h | 2 ++ src/procedures.c | 24 ++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/include/globals.h b/include/globals.h index c45295b..2caac1e 100644 --- a/include/globals.h +++ b/include/globals.h @@ -39,6 +39,8 @@ // broadcast based on the amount of players, reducing overhead for higher // player counts. For very many players, makes movement look jittery. #define SCALE_MOVEMENT_UPDATES_TO_PLAYER_COUNT +// If defined, calculates fluid flow when blocks are updated near fluids +#define DO_FLUID_FLOW // If defined, logs unrecognized packet IDs // #define DEV_LOG_UNKNOWN_PACKETS diff --git a/src/procedures.c b/src/procedures.c index a2b0544..5b13ae2 100644 --- a/src/procedures.c +++ b/src/procedures.c @@ -768,11 +768,13 @@ void handlePlayerAction (PlayerData *player, int action, short x, short y, short // Update nearby fluids uint8_t block_above = getBlockAt(x, y + 1, z); - checkFluidUpdate(x, y + 1, z, block_above); - checkFluidUpdate(x - 1, y, z, getBlockAt(x - 1, y, z)); - checkFluidUpdate(x + 1, y, z, getBlockAt(x + 1, y, z)); - checkFluidUpdate(x, y, z - 1, getBlockAt(x, y, z - 1)); - checkFluidUpdate(x, y, z + 1, getBlockAt(x, y, z + 1)); + #ifdef DO_FLUID_FLOW + checkFluidUpdate(x, y + 1, z, block_above); + checkFluidUpdate(x - 1, y, z, getBlockAt(x - 1, y, z)); + checkFluidUpdate(x + 1, y, z, getBlockAt(x + 1, y, z)); + checkFluidUpdate(x, y, z - 1, getBlockAt(x, y, z - 1)); + checkFluidUpdate(x, y, z + 1, getBlockAt(x, y, z + 1)); + #endif // Check if any blocks above this should break, and if so, // iterate upward over all blocks in the column and break them @@ -885,11 +887,13 @@ void handlePlayerUseItem (PlayerData *player, short x, short y, short z, uint8_t // Apply server-side block change makeBlockChange(x, y, z, block); // Calculate fluid flow - checkFluidUpdate(x, y + 1, z, getBlockAt(x, y + 1, z)); - checkFluidUpdate(x - 1, y, z, getBlockAt(x - 1, y, z)); - checkFluidUpdate(x + 1, y, z, getBlockAt(x + 1, y, z)); - checkFluidUpdate(x, y, z - 1, getBlockAt(x, y, z - 1)); - checkFluidUpdate(x, y, z + 1, getBlockAt(x, y, z + 1)); + #ifdef DO_FLUID_FLOW + checkFluidUpdate(x, y + 1, z, getBlockAt(x, y + 1, z)); + checkFluidUpdate(x - 1, y, z, getBlockAt(x - 1, y, z)); + checkFluidUpdate(x + 1, y, z, getBlockAt(x + 1, y, z)); + checkFluidUpdate(x, y, z - 1, getBlockAt(x, y, z - 1)); + checkFluidUpdate(x, y, z + 1, getBlockAt(x, y, z + 1)); + #endif } // Sync hotbar contents to player