1
0
mirror of https://github.com/p2r3/bareiron.git synced 2025-10-02 07:35:08 +02:00

fix mob behavior on low tickrate

This commit is contained in:
p2r3
2025-08-27 14:50:36 +03:00
parent b46f5927a2
commit fcb214cc4c

View File

@@ -1059,6 +1059,7 @@ void handleServerTick (int64_t time_since_last_tick) {
uint32_t r = fast_rand(); uint32_t r = fast_rand();
if ((unsigned int)TICKS_PER_SECOND >= 1) {
if (passive) { if (passive) {
// Update passive mobs once per 4 seconds on average // Update passive mobs once per 4 seconds on average
if (r % (4 * (unsigned int)TICKS_PER_SECOND)) continue; if (r % (4 * (unsigned int)TICKS_PER_SECOND)) continue;
@@ -1066,6 +1067,7 @@ void handleServerTick (int64_t time_since_last_tick) {
// Update hostile mobs once per second on average // Update hostile mobs once per second on average
if (r % (unsigned int)TICKS_PER_SECOND) continue; if (r % (unsigned int)TICKS_PER_SECOND) continue;
} }
}
// Find the player closest to this mob // Find the player closest to this mob
PlayerData* closest_player; PlayerData* closest_player;
@@ -1102,8 +1104,6 @@ void handleServerTick (int64_t time_since_last_tick) {
if ((r >> 1) & 1) { new_z += 1; yaw = 0; } if ((r >> 1) & 1) { new_z += 1; yaw = 0; }
else { new_z -= 1; yaw = 128; } else { new_z -= 1; yaw = 128; }
} }
// Vary the yaw angle to look just a little less robotic
yaw += ((r >> 7) & 31) - 16;
} else { // Hostile mob movement handling } else { // Hostile mob movement handling