fix mobs failing to find a valid spawn position

This commit is contained in:
p2r3
2025-08-23 14:42:52 +03:00
parent ee69d3ab9b
commit da2e99bd08

View File

@@ -278,7 +278,7 @@ void handlePacket (int client_fd, int length, int packet_id) {
short mob_z = (_z + dz * VIEW_DISTANCE) * 16 + ((r >> 8) & 15);
// Start at the Y coordinate of the spawning player and move upward
// until a valid space is found
uint8_t mob_y = cy;
uint8_t mob_y = cy - 8;
uint8_t b_low = getBlockAt(mob_x, mob_y - 1, mob_z);
uint8_t b_mid = getBlockAt(mob_x, mob_y, mob_z);
uint8_t b_top = getBlockAt(mob_x, mob_y + 1, mob_z);
@@ -293,6 +293,7 @@ void handlePacket (int client_fd, int length, int packet_id) {
b_top = getBlockAt(mob_x, mob_y + 2, mob_z);
mob_y ++;
}
if (mob_y != 255) {
// Spawn passive mobs during the day, hostiles during the night
if (world_time < 13000) {
uint32_t mob_choice = (r >> 12) & 3;
@@ -304,6 +305,7 @@ void handlePacket (int client_fd, int length, int packet_id) {
spawnMob(145, mob_x, mob_y, mob_z, 20); // Zombie
}
}
}
while (dx != 0) {
sc_chunkDataAndUpdateLight(client_fd, _x + dx * VIEW_DISTANCE, _z);