This commit is contained in:
2025-09-27 19:02:15 +02:00
parent 04c2d03675
commit 6f8888bd34

View File

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