Add Alot
This commit is contained in:
73
scripts/levels/level1/mission1.ts
Normal file
73
scripts/levels/level1/mission1.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import { MinecraftBlockTypes, 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";
|
||||
const Level1CommandBlockPos: Vector3 = vector3(2439, 0, 36);
|
||||
|
||||
const level1StartPosition: Vector3 = vector3(2451, -2, 57);
|
||||
const Level1EndPosition: Vector3 = vector3(2451, -2, 41);
|
||||
|
||||
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;
|
||||
|
||||
//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 === MinecraftBlockTypes.lava &&
|
||||
blockAir &&
|
||||
blockAir.type === MinecraftBlockTypes.air
|
||||
) {
|
||||
isOutOfBounds = true;
|
||||
}
|
||||
|
||||
if (isAgentAt(Level1EndPosition)) {
|
||||
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;
|
||||
72
scripts/levels/level1/mission2.ts
Normal file
72
scripts/levels/level1/mission2.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import { MinecraftBlockTypes, 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";
|
||||
const Level2CommandBlockPos: Vector3 = vector3(2439, 0, 35);
|
||||
|
||||
const level2StartPosition: Vector3 = vector3(2446, -2, 40);
|
||||
const Level2EndPosition: Vector3 = vector3(2446, -2, 30);
|
||||
|
||||
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 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 === MinecraftBlockTypes.lava &&
|
||||
blockAir &&
|
||||
blockAir.type === 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;
|
||||
71
scripts/levels/level1/mission3.ts
Normal file
71
scripts/levels/level1/mission3.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import { MinecraftBlockTypes, 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";
|
||||
const Level3CommandBlockPos: Vector3 = vector3(2439, 0, 34);
|
||||
const level3StartPosition: Vector3 = vector3(2447, -2, 30);
|
||||
const level3EndPosition: Vector3 = vector3(2451, -2, 18);
|
||||
|
||||
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 === MinecraftBlockTypes.lava &&
|
||||
blockAir &&
|
||||
blockAir.type === 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;
|
||||
73
scripts/levels/level2/mission1.ts
Normal file
73
scripts/levels/level2/mission1.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import { MinecraftBlockTypes, 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 { level4Conditions } from "../../levelConditions/level4";
|
||||
import { mindKeeper, CURRENT_LEVEL } from "../../main";
|
||||
const level4CommandBlockPos: Vector3 = vector3(2439, 0, 36);
|
||||
|
||||
const level4StartPosition: Vector3 = vector3(2451, -2, 57);
|
||||
const level4EndPosition: Vector3 = vector3(2451, -2, 41);
|
||||
|
||||
const level4ResetCommandBlockPos: Vector3 = vector3(56, 68, 211);
|
||||
const level4: Level = new Level(
|
||||
() => {
|
||||
pupeteer.sendWorldMessage("%message.level4.started");
|
||||
pupeteer.setTitleTimed("%message.level4.name", 2.5);
|
||||
startLevel(level4CommandBlockPos);
|
||||
teleportAgent(level4StartPosition);
|
||||
},
|
||||
() => {
|
||||
pupeteer.setActionBar("%message.level4.make");
|
||||
},
|
||||
() => {
|
||||
pupeteer.clearActionBar();
|
||||
pupeteer.sendWorldMessage("%message.level4.complete");
|
||||
pupeteer.setTitleTimed("%message.level4.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 === MinecraftBlockTypes.lava &&
|
||||
blockAir &&
|
||||
blockAir.type === MinecraftBlockTypes.air
|
||||
) {
|
||||
isOutOfBounds = true;
|
||||
}
|
||||
|
||||
if (isAgentAt(level4EndPosition)) {
|
||||
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");
|
||||
|
||||
teleportAgent(level4StartPosition);
|
||||
return false;
|
||||
} else if (isComplete) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
export default level4;
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Vector3, world } from "@minecraft/server";
|
||||
import { BlockType, MinecraftBlockTypes, Vector3, world } from "@minecraft/server";
|
||||
import Level from "../Commandeer/level/level";
|
||||
import { leverOn } from "../Commandeer/level/levelTypes";
|
||||
import { teleportAgent, isAgentAt } from "../Commandeer/utils/agentUtils";
|
||||
@@ -11,15 +11,72 @@ import Pupeteer from "../Commandeer/pupeteer";
|
||||
// const levelIntroCommandBlockPos: Vector3 = vector3(58, 66, 276);
|
||||
// const levelIntroStartPosition: Vector3 = vector3(28, 70, 269);
|
||||
// const levelIntroEndPosition: Vector3 = vector3(39, 70, 269);
|
||||
const buttonPositions: Vector3[] = [
|
||||
vector3(2471, 11, 106),
|
||||
vector3(2469, 11, 106),
|
||||
vector3(2468, 11, 106),
|
||||
vector3(2464, 11, 106),
|
||||
];
|
||||
|
||||
const blockPositions: Vector3[] = [
|
||||
vector3(2471, 12, 108),
|
||||
vector3(2469, 12, 108),
|
||||
vector3(2468, 12, 108),
|
||||
vector3(2464, 12, 108),
|
||||
];
|
||||
|
||||
let currentBlockSequence: BlockType[] = [];
|
||||
let currentBlockSeuqenceIndex: number[] = [];
|
||||
|
||||
const blockCycle: BlockType[] = [
|
||||
MinecraftBlockTypes.redstoneBlock,
|
||||
MinecraftBlockTypes.goldBlock,
|
||||
MinecraftBlockTypes.diamondBlock,
|
||||
MinecraftBlockTypes.emeraldBlock,
|
||||
MinecraftBlockTypes.lapisBlock,
|
||||
];
|
||||
|
||||
let buttonPressed: boolean[] = buttonPositions.map(() => false);
|
||||
|
||||
const levelIntro: Level = new Level(
|
||||
() => {
|
||||
Pupeteer.sendWorldMessage("%message.intro.started");
|
||||
Pupeteer.setTitleTimed("%message.intro.started", 2.5);
|
||||
// startLevel(levelIntroCommandBlockPos);
|
||||
// teleportAgent(levelIntroStartPosition);
|
||||
blockPositions.forEach((pos) => {
|
||||
let block = world.getDimension("overworld").getBlock(pos);
|
||||
let index = blockPositions.indexOf(pos);
|
||||
let blockType = block!.type;
|
||||
currentBlockSequence[index] = blockType;
|
||||
});
|
||||
},
|
||||
() => {
|
||||
Pupeteer.setActionBar("%message.intro.make");
|
||||
|
||||
buttonPositions.forEach((pos) => {
|
||||
let block = world.getDimension("overworld").getBlock(pos);
|
||||
if (!block) return;
|
||||
let index = buttonPositions.indexOf(pos);
|
||||
let prevState = buttonPressed[index];
|
||||
let currentState = block!.getRedstonePower()! > 0;
|
||||
|
||||
if (currentState && !prevState) {
|
||||
buttonPressed[index] = true;
|
||||
//NextBlock
|
||||
let nextBlock = currentBlockSequence[index];
|
||||
let nextIndex = blockCycle.indexOf(nextBlock);
|
||||
nextIndex = (nextIndex + 1) % blockCycle.length;
|
||||
currentBlockSequence[index] = blockCycle[nextIndex];
|
||||
//Update the block
|
||||
let blockPos = blockPositions[index];
|
||||
world.getDimension("overworld").getBlock(blockPos)!.setType(blockCycle[nextIndex]);
|
||||
}
|
||||
|
||||
if (!currentState && prevState) {
|
||||
buttonPressed[index] = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
() => {
|
||||
Pupeteer.clearActionBar();
|
||||
@@ -29,17 +86,28 @@ const levelIntro: Level = new Level(
|
||||
mindKeeper.increment(CURRENT_LEVEL);
|
||||
},
|
||||
() => {
|
||||
let counter = 0;
|
||||
let isComplete = true;
|
||||
levelIntroConditions.conditions.forEach((condition) => {
|
||||
let blockInworld = world.getDimension("overworld").getBlock(condition.position);
|
||||
if (blockInworld?.type !== condition.block) {
|
||||
isComplete = false;
|
||||
counter++;
|
||||
}
|
||||
});
|
||||
world.sendMessage(`%message.intro.progress ${counter}/${levelIntroConditions.conditions.length}`);
|
||||
world.sendMessage(`isComplete: ${isComplete}`);
|
||||
if (isComplete) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
() => {
|
||||
blockPositions.forEach((pos) => {
|
||||
let block = world.getDimension("overworld").getBlock(pos);
|
||||
let randomBlock = blockCycle[Math.floor(Math.random() * blockCycle.length)];
|
||||
block!.setType(randomBlock);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user