init
This commit is contained in:
69
scripts/levels/level1/mission1.ts
Normal file
69
scripts/levels/level1/mission1.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import { BlockType, BlockTypes, 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 { level1Conditions } from "../../levelConditions/level1";
|
||||
import { mindKeeper, CURRENT_LEVEL } from "../../main";
|
||||
import { MinecraftBlockTypes } from "../../vanilla-data/mojang-block";
|
||||
const Level1CommandBlockPos: Vector3 = vector3(-73, 71, 283);
|
||||
|
||||
const level1StartPosition: Vector3 = vector3(-73, 69, 267);
|
||||
const Level1EndPosition: Vector3 = vector3(-82, 69, 265);
|
||||
|
||||
const level1ResetCommandBlockPos: Vector3 = vector3(56, 68, 211);
|
||||
const level1: Level = new Level(
|
||||
() => {
|
||||
pupeteer.sendWorldMessage("%message.level1.started");
|
||||
pupeteer.setTitleTimed("%message.level1.name", 2.5);
|
||||
startLevel(Level1CommandBlockPos);
|
||||
teleportAgent(level1StartPosition);
|
||||
},
|
||||
() => {
|
||||
pupeteer.setActionBar("%message.level1.make");
|
||||
},
|
||||
() => {
|
||||
pupeteer.clearActionBar();
|
||||
pupeteer.sendWorldMessage("%message.level1.complete");
|
||||
pupeteer.setTitleTimed("%message.level1.complete", 2.5);
|
||||
|
||||
mindKeeper.increment(CURRENT_LEVEL);
|
||||
},
|
||||
() => {
|
||||
let isComplete = false;
|
||||
let isOutOfBounds = false;
|
||||
let hasAllTools = 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(Level1EndPosition) && hasAllTools) {
|
||||
isComplete = true;
|
||||
}
|
||||
|
||||
// world.sendMessage(`isComplete: ${isComplete}`);
|
||||
// world.sendMessage(`isOutOfBounds: ${isOutOfBounds}`);
|
||||
|
||||
if (isOutOfBounds) {
|
||||
pupeteer.sendWorldMessage("%message.level1.outOfBounds");
|
||||
pupeteer.setTitleTimed("%message.level1.outOfBounds", 2.5);
|
||||
// world.getDimension("overworld").runCommand("/kill @e[type=agent]");
|
||||
world.getDimension("overworld").runCommand("execute as @p run codebuilder runtime stop @s");
|
||||
|
||||
teleportAgent(level1StartPosition);
|
||||
return false;
|
||||
} else if (isComplete) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
export default level1;
|
||||
Reference in New Issue
Block a user