69 lines
2.4 KiB
TypeScript
69 lines
2.4 KiB
TypeScript
import { Vector3, world } from "@minecraft/server";
|
|
import Level from "../../Commandeer/level/level";
|
|
import pupeteer from "../../Commandeer/pupeteer";
|
|
import { teleportAgent, isAgentAt, getAgentLocation, getAgent } from "../../Commandeer/utils/agentUtils";
|
|
import { startLevel } from "../../Commandeer/utils/levelUtils";
|
|
import { vector3, Vector3Add, Vector3ToCommandString } from "../../Commandeer/utils/vectorUtils";
|
|
// import { level2Conditions } from "../../levelConditions/level2";
|
|
import { mindKeeper, CURRENT_LEVEL } from "../../main";
|
|
import { MinecraftBlockTypes } from "../../vanilla-data/mojang-block";
|
|
const level2CommandBlockPos: Vector3 = vector3(-111, 70, 282);
|
|
|
|
const level2StartPosition: Vector3 = vector3(-111, 69, 272);
|
|
const level2EndPosition: Vector3 = vector3(-124, 69, 258);
|
|
|
|
const level2ResetCommandBlockPos: Vector3 = vector3(56, 68, 211);
|
|
const level2: Level = new Level(
|
|
() => {
|
|
pupeteer.sendWorldMessage("%message.level2.started");
|
|
pupeteer.setTitleTimed("%message.level2.name", 2.5);
|
|
startLevel(level2CommandBlockPos);
|
|
teleportAgent(level2StartPosition);
|
|
},
|
|
() => {
|
|
pupeteer.setActionBar("%message.level2.make");
|
|
},
|
|
() => {
|
|
pupeteer.clearActionBar();
|
|
pupeteer.sendWorldMessage("%message.level2.complete");
|
|
pupeteer.setTitleTimed("%message.level2.complete", 2.5);
|
|
|
|
mindKeeper.increment(CURRENT_LEVEL);
|
|
},
|
|
() => {
|
|
let isComplete = false;
|
|
let isOutOfBounds = false;
|
|
|
|
//6 blocks lower is lava
|
|
|
|
let agentPos = getAgentLocation();
|
|
let blockAir = world.getDimension("overworld").getBlock(Vector3Add(agentPos, vector3(0, -1, 0)));
|
|
|
|
if (blockAir && blockAir.type.id === MinecraftBlockTypes.Air) {
|
|
isOutOfBounds = true;
|
|
}
|
|
|
|
if (isAgentAt(level2EndPosition)) {
|
|
isComplete = true;
|
|
}
|
|
|
|
// world.sendMessage(`isComplete: ${isComplete}`);
|
|
// world.sendMessage(`isOutOfBounds: ${isOutOfBounds}`);
|
|
|
|
if (isOutOfBounds) {
|
|
pupeteer.sendWorldMessage("%message.level2.outOfBounds");
|
|
pupeteer.setTitleTimed("%message.level2.outOfBounds", 2.5);
|
|
// world.getDimension("overworld").runCommand("/kill @e[type=agent]");
|
|
world.getDimension("overworld").runCommand("execute as @p run codebuilder runtime stop @s");
|
|
|
|
teleportAgent(level2StartPosition);
|
|
return false;
|
|
} else if (isComplete) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
);
|
|
|
|
export default level2;
|