1
0
mirror of https://github.com/p2r3/bareiron.git synced 2025-10-02 07:35:08 +02:00
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 // TODO: if below block breaks sand
if (isReplaceableBlock(below)) { if (isReplaceableBlock(below)) {
// TODO: drop item of below block // TODO: drop item of below block
makeBlockChange(x, y, z, 0); makeBlockChange(x, y, z, B_air);
makeBlockChange(x, y - 1, z, 0); makeBlockChange(x, y - 1, z, B_air);
makeBlockChange(x, y - 1, z, block); makeBlockChange(x, y - 1, z, block);
// update this now moved block at the sand fall speed // update this now moved block at the sand fall speed
deferBlockUpdate(x, y - 1, z, 15); deferBlockUpdate(x, y - 1, z, 15);
@@ -1214,20 +1214,19 @@ void handlePlayerAction (PlayerData *player, int action, short x, short y, short
// Ignore further actions not pertaining to mining blocks // Ignore further actions not pertaining to mining blocks
if (action != 0 && action != 2) return; if (action != 0 && action != 2) return;
uint8_t block = getBlockAt(x, y, z);
// In creative, only the "start mining" action is sent // In creative, only the "start mining" action is sent
// No additional verification is performed, the block is simply removed // No additional verification is performed, the block is simply removed
if (action == 0 && GAMEMODE == 1) { if (action == 0 && GAMEMODE == 1) {
makeBlockChange(x, y, z, 0); makeBlockChange(x, y, z, B_air);
return;
} }
else {
uint8_t block = getBlockAt(x, y, z);
// If this is a "start mining" packet, the block must be instamine // If this is a "start mining" packet, the block must be instamine
if (action == 0 && !isInstantlyMined(player, block)) return; if (action == 0 && !isInstantlyMined(player, block)) return;
// Don't continue if the block change failed // Don't continue if the block change failed
if (makeBlockChange(x, y, z, 0)) return; if (makeBlockChange(x, y, z, B_air)) return;
uint16_t held_item = player->inventory_items[player->hotbar]; uint16_t held_item = player->inventory_items[player->hotbar];
uint16_t item = getMiningResult(held_item, block); uint16_t item = getMiningResult(held_item, block);
@@ -1239,6 +1238,7 @@ void handlePlayerAction (PlayerData *player, int action, short x, short y, short
#endif #endif
givePlayerItem(player, item, 1); givePlayerItem(player, item, 1);
} }
}
// Update nearby blocks // Update nearby blocks
uint8_t block_above = getBlockAt(x, y + 1, z); uint8_t block_above = getBlockAt(x, y + 1, z);
@@ -1391,14 +1391,13 @@ void handlePlayerUseItem (PlayerData *player, short x, short y, short z, uint8_t
*count -= 1; *count -= 1;
// Clear item id in slot if amount is zero // Clear item id in slot if amount is zero
if (*count == 0) *item = 0; if (*count == 0) *item = 0;
// Calculate fluid flow // Send updates
#ifdef DO_FLUID_FLOW processBlockUpdate(x, y, z, block);
processBlockUpdate(x, y + 1, z, getBlockAt(x, y + 1, z)); 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 + 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));
processBlockUpdate(x, y, z + 1, getBlockAt(x, y, z + 1)); processBlockUpdate(x, y, z + 1, getBlockAt(x, y, z + 1));
#endif
} }
// Sync hotbar contents to player // Sync hotbar contents to player