import { world, system } from "@minecraft/server";
function isPlayerMoving(player) {
const playerVelocity = player.getVelocity();
const playerRotation = player.getRotation();
const rotationRadians = playerRotation.y * Math.PI / 180;
const forwardX = -Math.sin(rotationRadians);
const forwardZ = Math.cos(rotationRadians);
const thresholdRun = 0.25;
const thresholdWalk = 0.1;
const thresholdStop = 0.01;
const dotProduct = playerVelocity.x * forwardX + playerVelocity.z * forwardZ;
if (dotProduct > thresholdRun) {
player.runCommandAsync("title @a actionbar Бежит");
} else if (dotProduct > thresholdWalk) {
player.runCommandAsync("title @a actionbar идет");
} else if (dotProduct < thresholdStop) {
player.runCommandAsync("title @a actionbar Стоит на месте");
}
}
system.runInterval(() => {
const players = world.getAllPlayers();
for (const player of players) {
isPlayerMoving(player);
}
}); Post #47
148
Буфер бега/ходьбы