This commit is contained in:
Bram Verhulst
2024-07-04 14:42:38 +02:00
commit 67af73c6b5
60 changed files with 13407 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
import { World } from "@minecraft/server";
class Level {
levelCompleteCallback: Function;
levelCheckCallback: Function;
levelSetupCallback: Function;
levelUpdateCallback: Function;
isCompleted: boolean = false;
isSetup: boolean = false;
constructor(
levelSetupCallback: Function,
levelUpdateCallback: Function,
levelCompleteCallback: Function,
levelCheckCallback: Function
) {
this.levelSetupCallback = levelSetupCallback;
this.levelCompleteCallback = levelCompleteCallback;
this.levelCheckCallback = levelCheckCallback;
this.levelUpdateCallback = levelUpdateCallback;
}
setup() {
this.levelSetupCallback();
}
update() {
if (!this.isSetup) {
this.setup();
this.isSetup = true;
}
this.levelUpdateCallback();
if (this.levelCheckCallback() && !this.isCompleted) {
this.levelCompleteCallback();
this.isCompleted = true;
}
}
reset() {
this.isCompleted = false;
}
}
//nextlevel
//mindkeeper
//pupeteer
export default Level;

View File

@@ -0,0 +1,44 @@
import { BlockType, MinecraftBlockTypes, Vector3, World } from "@minecraft/server";
export type blockCondition = {
block: BlockType;
position: Vector3;
};
/**
* Checks if there is a lever at the specified position in the world.
*
* @param world - The world object.
* @param position - The position of the lever.
* @returns Returns true if there is a lever at the specified position and it has a redstone power of 15, otherwise returns false.
* @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);
if (!(lever?.typeId == "minecraft:lever")) {
throw new Error(`No lever at ${position}`);
}
return lever.getRedstonePower() == 15;
}
export type LeverCondition = {
position: Vector3;
state: boolean;
};
export type LevelBlockCondition = {
conditions: blockCondition[];
};
export type LevelLeverCondition = {
conditions: LeverCondition[];
};
export type AgentNoGoZone = {
//Reason for needing to use is because the Agent can't be queried for its location in minecraft
position: Vector3;
};
export type LevelNoGoZone = {
zones: AgentNoGoZone[];
};