From 6f8888bd34f855deead57dbc2df55f993db60859 Mon Sep 17 00:00:00 2001 From: Alexander Nutz Date: Sat, 27 Sep 2025 19:02:15 +0200 Subject: [PATCH] fixes --- src/procedures.c | 53 ++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/src/procedures.c b/src/procedures.c index a0ac832..61d6fae 100644 --- a/src/procedures.c +++ b/src/procedures.c @@ -1167,8 +1167,8 @@ void processBlockUpdate (short x, uint8_t y, short z, uint8_t block) { // TODO: if below block breaks sand if (isReplaceableBlock(below)) { // TODO: drop item of below block - makeBlockChange(x, y, z, 0); - makeBlockChange(x, y - 1, z, 0); + makeBlockChange(x, y, z, B_air); + makeBlockChange(x, y - 1, z, B_air); makeBlockChange(x, y - 1, z, block); // update this now moved block at the sand fall speed deferBlockUpdate(x, y - 1, z, 15); @@ -1214,30 +1214,30 @@ void handlePlayerAction (PlayerData *player, int action, short x, short y, short // Ignore further actions not pertaining to mining blocks if (action != 0 && action != 2) return; + uint8_t block = getBlockAt(x, y, z); + // In creative, only the "start mining" action is sent // No additional verification is performed, the block is simply removed if (action == 0 && GAMEMODE == 1) { - makeBlockChange(x, y, z, 0); - return; + makeBlockChange(x, y, z, B_air); } + else { + // If this is a "start mining" packet, the block must be instamine + if (action == 0 && !isInstantlyMined(player, block)) return; - uint8_t block = getBlockAt(x, y, z); + // Don't continue if the block change failed + if (makeBlockChange(x, y, z, B_air)) return; - // If this is a "start mining" packet, the block must be instamine - if (action == 0 && !isInstantlyMined(player, block)) return; + uint16_t held_item = player->inventory_items[player->hotbar]; + uint16_t item = getMiningResult(held_item, block); + bumpToolDurability(player); - // Don't continue if the block change failed - if (makeBlockChange(x, y, z, 0)) return; - - uint16_t held_item = player->inventory_items[player->hotbar]; - uint16_t item = getMiningResult(held_item, block); - bumpToolDurability(player); - - if (item) { - #ifdef ENABLE_PICKUP_ANIMATION - playPickupAnimation(player, item, x, y, z); - #endif - givePlayerItem(player, item, 1); + if (item) { + #ifdef ENABLE_PICKUP_ANIMATION + playPickupAnimation(player, item, x, y, z); + #endif + givePlayerItem(player, item, 1); + } } // Update nearby blocks @@ -1391,14 +1391,13 @@ void handlePlayerUseItem (PlayerData *player, short x, short y, short z, uint8_t *count -= 1; // Clear item id in slot if amount is zero if (*count == 0) *item = 0; - // Calculate fluid flow - #ifdef DO_FLUID_FLOW - processBlockUpdate(x, y + 1, z, getBlockAt(x, y + 1, z)); - processBlockUpdate(x - 1, y, z, getBlockAt(x - 1, y, z)); - processBlockUpdate(x + 1, y, z, getBlockAt(x + 1, y, z)); - processBlockUpdate(x, y, z - 1, getBlockAt(x, y, z - 1)); - processBlockUpdate(x, y, z + 1, getBlockAt(x, y, z + 1)); - #endif + // Send updates + processBlockUpdate(x, y, z, block); + processBlockUpdate(x, y + 1, z, getBlockAt(x, y + 1, z)); + processBlockUpdate(x - 1, y, z, getBlockAt(x - 1, y, z)); + processBlockUpdate(x + 1, y, z, getBlockAt(x + 1, y, z)); + processBlockUpdate(x, y, z - 1, getBlockAt(x, y, z - 1)); + processBlockUpdate(x, y, z + 1, getBlockAt(x, y, z + 1)); } // Sync hotbar contents to player