Remove duplicate code

This commit is contained in:
2026-10-13 11:57:43 -03:00
parent dfc6a6d77b
commit 5165698fe3
50 changed files with 307 additions and 812 deletions
+1 -8
View File
@@ -10,6 +10,7 @@ import { ItemEntity } from "./item_entity.ts";
import { EQUIPMENT_SLOTS, type EquipmentSlot, LivingEntity, type SavedLivingEntity } from "./living_entity.ts";
import type { EntityData } from "$/common/protocol.ts";
import type { ItemStack } from "$/common/inventory.ts";
import { wrap_angle } from "$/common/utils.ts";
// minecraft's despawning distances: gone at once past the first, maybe after a while past the second
const DESPAWN_DISTANCE = 128;
@@ -401,14 +402,6 @@ export class JumpControl {
}
}
// -pi to pi
export function wrap_angle(angle: number) {
angle %= Math.PI * 2;
if (angle >= Math.PI) angle -= Math.PI * 2;
if (angle < -Math.PI) angle += Math.PI * 2;
return angle;
}
// from one angle towards another the short way round, at most max
export function approach_angle(from: number, to: number, max: number) {
const difference = Math.max(-max, Math.min(max, wrap_angle(to - from)));