NPCs included, finishing touches zijn nog nodig
This commit is contained in:
@@ -2,18 +2,22 @@ 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 { startLevel, teleportAndFaceAgent } 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";
|
||||
import level3 from "./mission2";
|
||||
const level2CommandBlockPos: Vector3 = vector3(-111, 70, 282);
|
||||
import { checkBlockCondition } from "../../Commandeer/level/levelTypes";
|
||||
import { level2Conditions } from "../../levelConditions/level2";
|
||||
|
||||
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);
|
||||
let isComplete = false;
|
||||
let isOutOfBounds = false;
|
||||
|
||||
const level2: Level = new Level(
|
||||
() => {
|
||||
pupeteer.sendWorldMessage("%message.level2.started");
|
||||
@@ -28,15 +32,10 @@ const level2: Level = new Level(
|
||||
pupeteer.clearActionBar();
|
||||
pupeteer.sendWorldMessage("%message.level2.complete");
|
||||
pupeteer.setTitleTimed("%message.level2.complete", 2.5);
|
||||
world.getDimension("Overworld").runCommand("/fill -128 71 255 -128 74 276 air replace barrier");
|
||||
mindKeeper.increment(CURRENT_LEVEL);
|
||||
level3.reset();
|
||||
world.getDimension("Overworld").runCommand("/fill -154 69 255 -154 74 276 barrier replace air");
|
||||
},
|
||||
() => {
|
||||
let isComplete = false;
|
||||
let isOutOfBounds = false;
|
||||
|
||||
let agentPos = getAgentLocation();
|
||||
let blockAir = world.getDimension("overworld").getBlock(Vector3Add(agentPos, vector3(0, -1, 0)));
|
||||
|
||||
@@ -44,15 +43,20 @@ const level2: Level = new Level(
|
||||
isOutOfBounds = true;
|
||||
}
|
||||
|
||||
if (isAgentAt(level2EndPosition)) {
|
||||
const isCorrect = checkBlockCondition(level2Conditions);
|
||||
if (isAgentAt(level2EndPosition) && isCorrect) {
|
||||
isComplete = true;
|
||||
}
|
||||
|
||||
if (isOutOfBounds) {
|
||||
if (isOutOfBounds || (isAgentAt(level2EndPosition) && !isCorrect)) {
|
||||
teleportAndFaceAgent(level2StartPosition, vector3(-125, 69, 272));
|
||||
if (!isCorrect) {
|
||||
pupeteer.sendWorldMessage("%message.level.inCorrect");
|
||||
} else {
|
||||
pupeteer.sendWorldMessage("%message.level2.outOfBounds");
|
||||
pupeteer.setTitleTimed("%message.level2.outOfBounds", 2.5);
|
||||
}
|
||||
|
||||
pupeteer.sendWorldMessage("%message.level2.outOfBounds");
|
||||
pupeteer.setTitleTimed("%message.level2.outOfBounds", 2.5);
|
||||
world.getDimension("overworld").runCommand("execute as @p run codebuilder runtime stop @s");
|
||||
world.getDimension("Overworld").runCommand("/fill -111 69 272 -124 69 258 air replace sweet_berry_bush");
|
||||
world.getDimension("Overworld").runCommand("/fill -111 69 272 -124 69 258 air replace jungle_sapling");
|
||||
@@ -64,23 +68,10 @@ const level2: Level = new Level(
|
||||
return false;
|
||||
},
|
||||
() => {
|
||||
isComplete = false;
|
||||
world.getDimension("Overworld").runCommand("/fill -111 69 272 -124 69 258 air replace sweet_berry_bush");
|
||||
world.getDimension("Overworld").runCommand("/fill -111 69 272 -124 69 258 air replace jungle_sapling");
|
||||
}
|
||||
);
|
||||
|
||||
function teleportAndFaceAgent(position: Vector3, facing: Vector3 = vector3(0, 0, 0)): void {
|
||||
if (facing == vector3(-125, 69, 272)) {
|
||||
world
|
||||
.getDimension("overworld")
|
||||
.runCommand(`/execute as @a run tp @e[type=agent] ${position.x} ${position.y} ${position.z}`);
|
||||
} else {
|
||||
world
|
||||
.getDimension("overworld")
|
||||
.runCommand(
|
||||
`/execute as @a run tp @e[type=agent] ${position.x} ${position.y} ${position.z} facing ${facing.x} ${facing.y} ${facing.z}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default level2;
|
||||
|
||||
Reference in New Issue
Block a user