mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-12-03 21:48:53 -05:00
Possible fix for tick watchdog hang
This commit is contained in:
1 parent
28fc273b26
commit
6ff4befb04
1 file changed
+9
-1
@@ -612,7 +612,7 @@ open class Pokemon : ShowdownIdentifiable {
|
||||
if (owner is LivingEntity) {
|
||||
owner.swing(InteractionHand.MAIN_HAND, true)
|
||||
val spawnDirection: Vec3
|
||||
val spawnYaw: Double
|
||||
var spawnYaw: Double
|
||||
if (battleId != null) {
|
||||
// Look for an opposing opponent to face
|
||||
val battle = Cobblemon.battleRegistry.getBattle(battleId)
|
||||
@@ -640,6 +640,14 @@ open class Pokemon : ShowdownIdentifiable {
|
||||
spawnDirection = position.subtract(owner.position())
|
||||
spawnYaw = atan2(spawnDirection.z, spawnDirection.x) * 180.0 / PI + 102.5
|
||||
}
|
||||
|
||||
// In some edge cases, I suspect we are producing NaN's here. This actually leads into a really big problem.
|
||||
// Why? Because on tick, LivingEntity tries to bring rotations back within one loop around 0-360 using while loops.
|
||||
// NaN resists arithmetic, so the while loops run forever and the server thread will hang trying to normalize
|
||||
// this angle. Better to catch it here and correct it. Y'know. If this is actually the problem. I believe!
|
||||
if (!spawnYaw.isFinite()) {
|
||||
spawnYaw = 0.0
|
||||
}
|
||||
it.entityData.set(PokemonEntity.SPAWN_DIRECTION, spawnYaw.toFloat())
|
||||
}
|
||||
if (owner != null) {
|
||||
|
||||
Reference in new issue
Block a user