fix wrong expression order in mob movement

This commit is contained in:
p2r3
2025-09-19 02:12:00 +03:00
parent 3bde692976
commit a631de77b5

View File

@@ -1813,39 +1813,38 @@ void handleServerTick (int64_t time_since_last_tick) {
// Holds the block above the target block, i.e. the "head" block // Holds the block above the target block, i.e. the "head" block
uint8_t block_above = getBlockAt(new_x, new_y + 1, new_z); uint8_t block_above = getBlockAt(new_x, new_y + 1, new_z);
if ( // Validate movement on X axis // Validate movement on X axis
new_x != old_x && if (new_x != old_x && (
!isPassableBlock(getBlockAt(new_x, new_y + 1, old_z)) || !isPassableBlock(getBlockAt(new_x, new_y + 1, old_z)) ||
( (
!isPassableBlock(getBlockAt(new_x, new_y, old_z)) && !isPassableBlock(getBlockAt(new_x, new_y, old_z)) &&
!isPassableBlock(getBlockAt(new_x, new_y + 2, old_z)) !isPassableBlock(getBlockAt(new_x, new_y + 2, old_z))
) )
) { )) {
new_x = old_x; new_x = old_x;
block = getBlockAt(old_x, new_y, new_z); block = getBlockAt(old_x, new_y, new_z);
block_above = getBlockAt(old_x, new_y + 1, new_z); block_above = getBlockAt(old_x, new_y + 1, new_z);
} }
if ( // Validate movement on Z axis // Validate movement on Z axis
new_z != old_z && if (new_z != old_z && (
!isPassableBlock(getBlockAt(old_x, new_y + 1, new_z)) || !isPassableBlock(getBlockAt(old_x, new_y + 1, new_z)) ||
( (
!isPassableBlock(getBlockAt(old_x, new_y, new_z)) && !isPassableBlock(getBlockAt(old_x, new_y, new_z)) &&
!isPassableBlock(getBlockAt(old_x, new_y + 2, new_z)) !isPassableBlock(getBlockAt(old_x, new_y + 2, new_z))
) )
) { )) {
new_z = old_z; new_z = old_z;
block = getBlockAt(new_x, new_y, old_z); block = getBlockAt(new_x, new_y, old_z);
block_above = getBlockAt(new_x, new_y + 1, old_z); block_above = getBlockAt(new_x, new_y + 1, old_z);
} }
// Validate diagonal movement
if ( // Validate diagonal movement if (new_x != old_x && new_z != old_z && (
new_x != old_x && new_z != old_z &&
!isPassableBlock(block_above) || !isPassableBlock(block_above) ||
( (
!isPassableBlock(block) && !isPassableBlock(block) &&
!isPassableBlock(getBlockAt(new_x, new_y + 2, new_z)) !isPassableBlock(getBlockAt(new_x, new_y + 2, new_z))
) )
) { )) {
// We know that movement along just one axis is fine thanks to the // We know that movement along just one axis is fine thanks to the
// checks above, pick one based on proximity. // checks above, pick one based on proximity.
int dist_x = abs(old_x - closest_player->x); int dist_x = abs(old_x - closest_player->x);