add option to disable fluid calculation

This commit is contained in:
p2r3
2025-08-28 01:50:12 +03:00
parent b5d72f852e
commit b26e74c382
2 changed files with 16 additions and 10 deletions

View File

@@ -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

View File

@@ -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