This commit is contained in:
2024-08-21 16:15:22 +02:00
parent cd5f473460
commit 35af9ffc97
38 changed files with 1122 additions and 1090 deletions

View File

@@ -1,10 +1,22 @@
import { Entity, Vector3, world } from "@minecraft/server";
import { Vector3ToString, vector3 } from "./vectorUtils";
import { mindKeeper } from "../../main";
function teleportAgent(position: Vector3) {
world
.getDimension("overworld")
.runCommand(`/execute as @a run tp @e[type=agent] ${position.x} ${position.y} ${position.z}`);
//Make a facing with vector3
type Facing = Vector3;
function teleportAgent(position: Vector3, facing: Vector3 = vector3(0, 0, 0)): void {
if (facing == vector3(0, 0, 0)) {
world
.getDimension("overworld")
.runCommand(`/execute as @a run tp @e[type=agent] ${position.x} ${position.y} ${position.z}`);
} else {
world
.getDimension("overworld")
.runCommand(
`/execute as @a run tp @e[type=agent] ${position.x} ${position.y} ${position.z} facing ${facing.x} ${facing.y} ${facing.z}`
);
}
}
function isAgentAt(position: Vector3): boolean {

View File

@@ -0,0 +1,15 @@
import { system, world } from "@minecraft/server";
function runEntityEventOnTag(tag: string, event: string) {
system.run(() => {
world.getDimension("overworld").runCommand(`/event entity @e[tag=${tag}] ${event}`);
});
}
function setNPCDialog(npcTag: string, dialogId: string) {
system.run(() => {
world.getDimension("overworld").runCommand(`/dialogue change @e[tag=${npcTag}] ${dialogId} @a`);
});
}
export { runEntityEventOnTag, setNPCDialog };

View File

@@ -11,7 +11,7 @@ function clearWall(wall: Wall) {
world.getDimension("overworld").fillBlocks(volume, MinecraftBlockTypes.Air);
}
function fillWall(wall: Wall, block: BlockType) {
function fillWall(wall: Wall, block: string) {
let volume: BlockVolume = new BlockVolume(wall.startPos, wall.endPos);
world.getDimension("overworld").fillBlocks(volume, block);
}

View File

@@ -1,5 +1,31 @@
import { Vector3 } from "@minecraft/server";
enum Direction {
North = 0,
East = 1,
South = 2,
West = 3,
Up = 4,
Down = 5,
}
function directionToVector3(direction: Direction): Vector3 {
switch (direction) {
case Direction.North:
return vector3(0, 0, -1);
case Direction.East:
return vector3(1, 0, 0);
case Direction.South:
return vector3(0, 0, 1);
case Direction.West:
return vector3(-1, 0, 0);
case Direction.Up:
return vector3(0, 1, 0);
case Direction.Down:
return vector3(0, -1, 0);
}
}
function vector3(x: number, y: number, z: number): Vector3 {
return { x: x, y: y, z: z };
}
@@ -55,6 +81,8 @@ function vector3Distance(vector1: Vector3, vector2: Vector3): number {
}
export {
Direction,
directionToVector3,
Vector3ToString,
Vector3ToFancyString,
Vector3Add,