import { Entity, Vector3, world } from "@minecraft/server"; import { Vector3Add, vector3 } from "./vectorUtils"; import { mindKeeper } from "../../main"; //Make a facing with 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 { const facing2 = Vector3Add(position, facing); world .getDimension("overworld") .runCommand( `/execute as @a run tp @e[type=agent] ${position.x} ${position.y} ${position.z} facing ${facing2.x} ${facing2.y} ${facing2.z}` ); } } function isAgentAt(position: Vector3): boolean { let isAgentAt: boolean = false; world .getDimension("overworld") .getEntitiesAtBlockLocation(position) .forEach((entity) => { if (!entity.isValid()) { world.sendMessage("INVALID ENTITY"); return; } if (entity.typeId == "minecraft:agent") { isAgentAt = true; } }); return isAgentAt; } function getAgent(): Entity { const agent = world.getEntity(mindKeeper.get("agentid") as string); return agent!; } function getAgentLocation(): Vector3 { let agentLocation: Vector3 = vector3(0, 0, 0); const agent = world.getEntity(mindKeeper.get("agentid") as string); agentLocation = agent!.location; return agentLocation; } export { teleportAgent, isAgentAt, getAgentLocation, getAgent };