Буфер бега/ходьбы
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);
}
});При нажатии на блок
import { system, world } from '@minecraft/server';
world.afterEvents.playerInteractWithBlock.subscribe(eventData => {
const block = eventData.block;
if (block.typeId === "minecraft:chest") {
if (eventData.blockFace) {
eventData.player.runCommand("title @a actionbar да");
}
}
});Показатель сердец
import { world, system, Player } from "@minecraft/server";
const previousHearts = new Map();
function her() {
const players = world.getPlayers();
for (const player of players) {
const health = player.getComponent('health').currentValue;
const currentHearts = health / 2;
const playerId = player.id;
const prevHearts = previousHearts.get(playerId) || currentHearts;
player.runCommandAsync(`title @s actionbar ❤ ${currentHearts.toFixed(1)}`);
if (prevHearts > 6.0 && currentHearts <= 6.0) {
player.runCommandAsync(`tellraw @s {"rawtext":[{"text":"§cВнимание! Жизней становится меньше (6.0 сердец)"}]}`);
}
else if (prevHearts > 3.0 && currentHearts <= 3.0) {
player.runCommandAsync(`tellraw @s {"rawtext":[{"text":"§4Тревога! Сердец осталось мало (3.0 сердца)"}]}`);
}
else if (prevHearts > 1.0 && currentHearts <= 1.0) {
player.runCommandAsync(`tellraw @s {"rawtext":[{"text":"§4§lКРИТИЧЕСКИ! Осталось всего 1.0 сердце!"}]}`);
}
previousHearts.set(playerId, currentHearts);
}
}
system.runInterval(her);This media is not supported in your browser
VIEW IN TELEGRAM
Пример спавна поверхности блока
Спавн блоков на поверхности земли
import { world, system } from "@minecraft/server";
let active = false;
const block = "minecraft:gold_block";
const radius = 10;
const tag = "replace";
function checkMob() {
const mobs = world.getDimension("overworld").getEntities({ tags: [tag] });
return mobs.length > 0;
}
function placeBlocks() {
if (!checkMob()) {
active = false;
return;
}
const dimension = world.getDimension("overworld");
const players = world.getAllPlayers();
const mobs = dimension.getEntities({ tags: [tag] });
const targets = [...players, ...mobs];
for (const target of targets) {
const { x, z } = target.location;
const angle = Math.random() * Math.PI * 2;
const distance = Math.random() * radius;
const targetX = x + Math.cos(angle) * distance;
const targetZ = z + Math.sin(angle) * distance;
for (let y = 320; y >= -64; y--) {
const ground = dimension.getBlock({ x: targetX, y, z: targetZ });
if (ground?.typeId === "minecraft:grass_block" || ground?.typeId === "minecraft:dirt") {
const air = dimension.getBlock({ x: targetX, y: y + 1, z: targetZ });
if (air?.typeId === "minecraft:air") {
air.setType(block);
break;
}
}
}
}
}
system.runInterval(() => {
if (checkMob() && !active) {
active = true;
system.runInterval(placeBlocks, 1 * 20);
}
else if (!checkMob() && active) {
active = false;
}
}, 20);Скрипт удар по определенному мобу
import { world, system } from "@minecraft/server";
const mobcom = {
"minecraft:cow": "title @a title муу",
"minecraft:chicken": "title @a title чикен, банано",
"minecraft:cat": "title @a title мур",
"minecraft:pig": "title @a title свинота",
};
world.afterEvents.entityHitEntity.subscribe((event) => {
const { hitEntity, damagingEntity } = event;
if (damagingEntity?.typeId === "minecraft:player" && mobcom[hitEntity.typeId]) {
try {
damagingEntity.runCommandAsync(mobcom[hitEntity.typeId]);
} catch (error) {
console.error("Ошибка выполнения команды:", error);
}
}
});This media is not supported in your browser
VIEW IN TELEGRAM
Пример воспроизведения команды при ударе по определенному мобу
🔥1
Описание канала BOTIK
Взаимная реклама: https://t.me/Bots180
Канал моих модов: https://t.me/modsbotik
Все проекты: https://sites.google.com/view/projectvsebotikbitob
Ютуб канал: https://youtube.com/@botik.?si=JFD9fg-CzeM6Q3Lq
Взаимная реклама: https://t.me/Bots180
Канал моих модов: https://t.me/modsbotik
Все проекты: https://sites.google.com/view/projectvsebotikbitob
Ютуб канал: https://youtube.com/@botik.?si=JFD9fg-CzeM6Q3Lq
{
"format_version": "1.20.60",
"minecraft:block": {
"description": {
"identifier": "custom:block",
"menu_category": {
"category": "construction"
}
},
"components": {
"minecraft:destructible_by_mining": {
"seconds_to_destroy": 3.0
},
"minecraft:destructible_by_explosion": {
"explosion_resistance": 3.0
},
"minecraft:friction": 0.4,
"minecraft:map_color": "#FFFFFF",
"minecraft:light_dampening": 0,
"minecraft:light_emission": 4,
"minecraft:loot": "loot_tables/blocks/custom_block.json",
"minecraft:collision_box": {
"origin": [
-8.0,
0.0,
-8.0
],
"size": [
16.0,
16.0,
16.0
]
},
"minecraft:selection_box": {
"origin": [
-8.0,
0.0,
-8.0
],
"size": [
16.0,
16.0,
16.0
]
},
"minecraft:material_instances": {
"*": {
"texture": "custom_block",
"render_method": "opaque"
}
},
"tags": [
"wood"
],
"minecraft:custom_components": [
"custom_block:trigger"
]
},
"events": {
},
"permutations": [
]
}
}This media is not supported in your browser
VIEW IN TELEGRAM
Пример появления кнопки при тега
Буфер появления кнопки
import { world, system } from "@minecraft/server";
import { ActionFormData } from "@minecraft/server-ui";
function UI(player) {
const form = new ActionFormData();
form.title("меню");
form.body(`чтобы появилась кнопка, выдайте себе тег "custom" и кнопка появится в меню`);
form.button("кнопка без тега");
if (player.hasTag("custom")) {
form.button("кнопка с тегом №1");
}
if (player.hasTag("cus")) {
form.button("кнопка с тегом №2");
}
form.show(player).then(result => {
if (result.selection === undefined) return;
if (result.selection === 0) {
player.sendMessage("Вы нажали кнопку без тега");
} else if (result.selection === 1 && player.hasTag("custom")) {
player.sendMessage("Вы нажали кнопку с тегом №1");
} else if (result.selection === 2 && player.hasTag("cus")) {
player.sendMessage("Вы нажали кнопку с тегом №2");
}
});
}
world.beforeEvents.itemUse.subscribe((eventData) => {
if (eventData.itemStack?.typeId === "minecraft:stick") {
let player = eventData.source;
system.run(() => {
UI(player);
});
}
});Скрипт - проверка шифта
import { world, system } from "@minecraft/server";
function scriptik() {
const players = world.getPlayers();
for (const player of players) {
if (player.isSneaking) { //проверка шифта
player.runCommandAsync("title @a actionbar Вы сидите");
} else { //если игрок не сидит, то. . .
player.runCommandAsync("title @a actionbar Вы стоите");
}
}
system.runTimeout(scriptik, 1);
}
system.runTimeout(scriptik, 1);😢2