commit a631de77b5c5dad4a23107a30e1aa5f49cd76d37 from: p2r3 date: Thu Sep 18 23:12:00 2025 UTC fix wrong expression order in mob movement commit - 3bde6929768adf802fbe57b27d1ef99204bad8cc commit + a631de77b5c5dad4a23107a30e1aa5f49cd76d37 blob - 7bc5d9d1280909b40a64044118715539d0e40972 blob + 372d2fb60f8cc950409c849890eb63a02cbad61e --- src/procedures.c +++ src/procedures.c @@ -1813,39 +1813,38 @@ void handleServerTick (int64_t time_since_last_tick) { // Holds the block above the target block, i.e. the "head" block uint8_t block_above = getBlockAt(new_x, new_y + 1, new_z); - if ( // Validate movement on X axis - new_x != old_x && + // Validate movement on X axis + if (new_x != old_x && ( !isPassableBlock(getBlockAt(new_x, new_y + 1, old_z)) || ( !isPassableBlock(getBlockAt(new_x, new_y, old_z)) && !isPassableBlock(getBlockAt(new_x, new_y + 2, old_z)) ) - ) { + )) { new_x = old_x; block = getBlockAt(old_x, new_y, new_z); block_above = getBlockAt(old_x, new_y + 1, new_z); } - if ( // Validate movement on Z axis - new_z != old_z && + // Validate movement on Z axis + if (new_z != old_z && ( !isPassableBlock(getBlockAt(old_x, new_y + 1, new_z)) || ( !isPassableBlock(getBlockAt(old_x, new_y, new_z)) && !isPassableBlock(getBlockAt(old_x, new_y + 2, new_z)) ) - ) { + )) { new_z = old_z; block = getBlockAt(new_x, new_y, old_z); block_above = getBlockAt(new_x, new_y + 1, old_z); } - - if ( // Validate diagonal movement - new_x != old_x && new_z != old_z && + // Validate diagonal movement + if (new_x != old_x && new_z != old_z && ( !isPassableBlock(block_above) || ( !isPassableBlock(block) && !isPassableBlock(getBlockAt(new_x, new_y + 2, new_z)) ) - ) { + )) { // We know that movement along just one axis is fine thanks to the // checks above, pick one based on proximity. int dist_x = abs(old_x - closest_player->x);