NPCs included, finishing touches zijn nog nodig

This commit is contained in:
2024-09-11 16:54:16 +02:00
parent 283f95e00a
commit c323e98bcd
25 changed files with 1665 additions and 891 deletions

View File

@@ -1,7 +1,9 @@
import { BlockType, Vector3, World } from "@minecraft/server";
import { Vector3, world, World } from "@minecraft/server";
import { MinecraftBlockTypes } from "../../vanilla-data/mojang-block";
import { vector3 } from "../utils/vectorUtils";
export type blockCondition = {
block: string;
block: (string | MinecraftBlockTypes)[];
position: Vector3;
};
@@ -14,7 +16,7 @@ export type blockCondition = {
* @throws Throws an error if there is no lever at the specified position.
*/
export function leverOn(world: World, position: Vector3): boolean {
let lever = world.getDimension("overworld").getBlock(position);
const lever = world.getDimension("overworld").getBlock(position);
if (!(lever?.typeId == "minecraft:lever")) {
throw new Error(`No lever at ${position}`);
}
@@ -42,3 +44,14 @@ export type AgentNoGoZone = {
export type LevelNoGoZone = {
zones: AgentNoGoZone[];
};
export const checkBlockCondition = (condition: LevelBlockCondition): boolean => {
let isComplete: boolean = true;
condition.conditions.forEach((condition) => {
const block = world.getDimension("overworld").getBlock(condition.position);
if (condition.block.indexOf(block!.typeId) === -1) {
isComplete = false;
}
});
return isComplete;
};