working version without custom blocks/textures
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Vector3, world } from "@minecraft/server";
|
||||
import { BlockVolume, 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";
|
||||
@@ -6,6 +6,7 @@ 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";
|
||||
import level5 from "../level3/mission1";
|
||||
const Level4CommandBlockPos: Vector3 = vector3(-161, 68, 291);
|
||||
const level4StartPosition: Vector3 = vector3(-161, 62, 261);
|
||||
const level4EndPosition: Vector3 = vector3(-174, 62, 268);
|
||||
@@ -16,7 +17,7 @@ const level4: Level = new Level(
|
||||
pupeteer.sendWorldMessage("%message.level4.started");
|
||||
pupeteer.setTitleTimed("%message.level4.name", 2.5);
|
||||
startLevel(Level4CommandBlockPos);
|
||||
teleportAgent(level4StartPosition);
|
||||
teleportAndFaceAgent(level4StartPosition, vector3(-175, 62, 261));
|
||||
},
|
||||
() => {
|
||||
pupeteer.setActionBar("%message.level4.make");
|
||||
@@ -25,25 +26,18 @@ const level4: Level = new Level(
|
||||
pupeteer.clearActionBar();
|
||||
pupeteer.sendWorldMessage("%message.level4.complete");
|
||||
pupeteer.setTitleTimed("%message.level4.complete", 2.5);
|
||||
|
||||
world.getDimension("Overworld").runCommand("/fill -182 69 255 -182 74 276 air replace barrier");
|
||||
mindKeeper.increment(CURRENT_LEVEL);
|
||||
level5.reset();
|
||||
},
|
||||
() => {
|
||||
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
|
||||
) {
|
||||
if (blockAir && blockAir.type.id === MinecraftBlockTypes.Air) {
|
||||
isOutOfBounds = true;
|
||||
}
|
||||
|
||||
@@ -51,16 +45,14 @@ const level4: Level = new Level(
|
||||
isComplete = true;
|
||||
}
|
||||
|
||||
// world.sendMessage(`isComplete: ${isComplete}`);
|
||||
// world.sendMessage(`isOutOfBounds: ${isOutOfBounds}`);
|
||||
|
||||
if (isOutOfBounds) {
|
||||
pupeteer.sendWorldMessage("%message.level4.outOfBounds");
|
||||
pupeteer.setTitleTimed("%message.level4.outOfBounds", 2.5);
|
||||
// world.getDimension("overworld").runCommand("/kill @e[type=agent]");
|
||||
world.getDimension("overworld").runCommand("execute as @p run codebuilder runtime stop @s");
|
||||
let volume: BlockVolume = new BlockVolume(vector3(-163, 67, 291), vector3(-163, 67, 291));
|
||||
world.getDimension("overworld").fillBlocks(volume, MinecraftBlockTypes.RedstoneBlock);
|
||||
|
||||
teleportAgent(level4StartPosition);
|
||||
teleportAndFaceAgent(level4StartPosition, vector3(-175, 62, 261));
|
||||
return false;
|
||||
} else if (isComplete) {
|
||||
return true;
|
||||
@@ -69,4 +61,18 @@ const level4: Level = new Level(
|
||||
}
|
||||
);
|
||||
|
||||
function teleportAndFaceAgent(position: Vector3, facing: Vector3 = vector3(0, 0, 0)): void {
|
||||
if (facing == vector3(-175, 62, 261)) {
|
||||
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 level4;
|
||||
|
||||
Reference in New Issue
Block a user