forked from EXTERNAL/bareiron
fix mobs failing to find a valid spawn position
This commit is contained in:
@@ -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);
|
short mob_z = (_z + dz * VIEW_DISTANCE) * 16 + ((r >> 8) & 15);
|
||||||
// Start at the Y coordinate of the spawning player and move upward
|
// Start at the Y coordinate of the spawning player and move upward
|
||||||
// until a valid space is found
|
// 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_low = getBlockAt(mob_x, mob_y - 1, mob_z);
|
||||||
uint8_t b_mid = getBlockAt(mob_x, mob_y, 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);
|
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);
|
b_top = getBlockAt(mob_x, mob_y + 2, mob_z);
|
||||||
mob_y ++;
|
mob_y ++;
|
||||||
}
|
}
|
||||||
|
if (mob_y != 255) {
|
||||||
// Spawn passive mobs during the day, hostiles during the night
|
// Spawn passive mobs during the day, hostiles during the night
|
||||||
if (world_time < 13000) {
|
if (world_time < 13000) {
|
||||||
uint32_t mob_choice = (r >> 12) & 3;
|
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
|
spawnMob(145, mob_x, mob_y, mob_z, 20); // Zombie
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (dx != 0) {
|
while (dx != 0) {
|
||||||
sc_chunkDataAndUpdateLight(client_fd, _x + dx * VIEW_DISTANCE, _z);
|
sc_chunkDataAndUpdateLight(client_fd, _x + dx * VIEW_DISTANCE, _z);
|
||||||
|
Reference in New Issue
Block a user