74 lines
2.5 KiB
TypeScript
74 lines
2.5 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 { mindKeeper, CURRENT_LEVEL } from "../../main";
|
|
import { MinecraftBlockTypes } from "../../vanilla-data/mojang-block";
|
|
const Level3CommandBlockPos: Vector3 = vector3(-133, 68, 281);
|
|
|
|
const level3StartPosition: Vector3 = vector3(-133, 68, 265);
|
|
const Level3EndPosition: Vector3 = vector3(-148, 68, 265);
|
|
|
|
const level3ResetCommandBlockPos: Vector3 = vector3(56, 68, 211);
|
|
const level3: Level = new Level(
|
|
() => {
|
|
pupeteer.sendWorldMessage("%message.level3.started");
|
|
pupeteer.setTitleTimed("%message.level3.name", 2.5);
|
|
startLevel(Level3CommandBlockPos);
|
|
teleportAgent(level3StartPosition);
|
|
},
|
|
() => {
|
|
pupeteer.setActionBar("%message.level3.make");
|
|
},
|
|
() => {
|
|
pupeteer.clearActionBar();
|
|
pupeteer.sendWorldMessage("%message.level3.complete");
|
|
pupeteer.setTitleTimed("%message.level3.complete", 2.5);
|
|
|
|
mindKeeper.increment(CURRENT_LEVEL);
|
|
},
|
|
() => {
|
|
let isComplete = false;
|
|
let isOutOfBounds = false;
|
|
|
|
//6 blocks lower is lava
|
|
|
|
let agentPos = getAgentLocation();
|
|
let blockLava = world.getDimension("overworld").getBlock(Vector3Add(agentPos, vector3(0, -7, 0)));
|
|
let blockAir = world.getDimension("overworld").getBlock(Vector3Add(agentPos, vector3(0, -1, 0)));
|
|
|
|
if (
|
|
blockLava &&
|
|
blockLava.type.id === MinecraftBlockTypes.Lava &&
|
|
blockAir &&
|
|
blockAir.type.id === MinecraftBlockTypes.Air
|
|
) {
|
|
isOutOfBounds = true;
|
|
}
|
|
|
|
if (isAgentAt(Level3EndPosition)) {
|
|
isComplete = true;
|
|
}
|
|
|
|
// world.sendMessage(`isComplete: ${isComplete}`);
|
|
// world.sendMessage(`isOutOfBounds: ${isOutOfBounds}`);
|
|
|
|
if (isOutOfBounds) {
|
|
pupeteer.sendWorldMessage("%message.level3.outOfBounds");
|
|
pupeteer.setTitleTimed("%message.level3.outOfBounds", 2.5);
|
|
// world.getDimension("overworld").runCommand("/kill @e[type=agent]");
|
|
world.getDimension("overworld").runCommand("execute as @p run codebuilder runtime stop @s");
|
|
|
|
teleportAgent(level3StartPosition);
|
|
return false;
|
|
} else if (isComplete) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
);
|
|
|
|
export default level3;
|