Remove duplicate code
This commit is contained in:
@@ -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)));
|
||||
|
||||
Reference in New Issue
Block a user