feat: Add cracked glass block and texture
Added the cracked glass block and its corresponding texture to the resource packs. Also made changes to the maker.ts file to include a save operation. Additionally, added a new behavior pack for the cracked glass block with specific properties. Updated the vectorUtils.ts file to include a new function for converting a Vector3 object to a command string. Finally, made changes to the triggers.ts file to register new triggers and update existing ones.
This commit is contained in:
20
behavior_packs/blocks/cracked_glass.json
Normal file
20
behavior_packs/blocks/cracked_glass.json
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"format_version": "1.20.13",
|
||||||
|
"minecraft:block": {
|
||||||
|
"description": {
|
||||||
|
"identifier": "cc:cracked_glass",
|
||||||
|
"menu_category": {
|
||||||
|
"category": "construction",
|
||||||
|
"is_hidden_in_commands": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"components": {
|
||||||
|
"minecraft:light_dampening": 0,
|
||||||
|
"minecraft:material_instances": {
|
||||||
|
"*": {
|
||||||
|
"render_method": "blend"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
7
resource_packs/blocks.json
Normal file
7
resource_packs/blocks.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"format_version": [1, 1, 0],
|
||||||
|
"cc:cracked_glass": {
|
||||||
|
"textures": "cracked_glass",
|
||||||
|
"sound": "glass"
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
resource_packs/textures/blocks/cracked_glass.png
Normal file
BIN
resource_packs/textures/blocks/cracked_glass.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 392 B |
11
resource_packs/textures/terrain_texture.json
Normal file
11
resource_packs/textures/terrain_texture.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"texture_name": "atlas.terrain",
|
||||||
|
"resource_pack_name": "cc",
|
||||||
|
"padding": 8,
|
||||||
|
"num_mip_levels": 4,
|
||||||
|
"texture_data": {
|
||||||
|
"cracked_glass": {
|
||||||
|
"textures": "textures/blocks/cracked_glass"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
import {
|
|
||||||
Block,
|
|
||||||
ChatSendAfterEvent,
|
|
||||||
ItemStack,
|
|
||||||
ItemUseOnBeforeEvent,
|
|
||||||
MolangVariableMap,
|
|
||||||
Player,
|
|
||||||
world,
|
|
||||||
} from "@minecraft/server";
|
|
||||||
import { Vector3 } from "@minecraft/server";
|
|
||||||
import { Vector3Add, Vector3ToString, vector3 } from "../utils/vectorUtils";
|
|
||||||
import { spawnParticle } from "../utils/particleUtils";
|
|
||||||
|
|
||||||
export namespace TrailMaker {
|
|
||||||
export class Maker {
|
|
||||||
currentTrail: Trail;
|
|
||||||
log: Map<string, number> = new Map();
|
|
||||||
selectedIndex: number = 0;
|
|
||||||
|
|
||||||
OnChat(event: ChatSendAfterEvent) {}
|
|
||||||
OnItemUse(event: ItemUseOnBeforeEvent) {
|
|
||||||
const currentItemHeld: ItemStack = event.itemStack;
|
|
||||||
const blockInteracted: Block = event.block;
|
|
||||||
const player: Player = event.source as Player;
|
|
||||||
const oldLog = this.log.get(player.name)!;
|
|
||||||
this.log.set(player.name, Date.now());
|
|
||||||
if (oldLog + 150 >= Date.now()) return;
|
|
||||||
|
|
||||||
if (event.itemStack.typeId == "minecraft:stick" && event.itemStack.nameTag == "AddPoint") {
|
|
||||||
let pos = vector3(event.block.location.x, event.block.location.y, event.block.location.z);
|
|
||||||
pos = Vector3Add(pos, vector3(0.5, 0, 0.5));
|
|
||||||
pos = Vector3Add(pos, vector3(0, 1.1, 0));
|
|
||||||
this.currentTrail.points.push(new Point(pos, this.currentTrail.currentPoint));
|
|
||||||
//offset by half a block
|
|
||||||
|
|
||||||
this.currentTrail.currentPoint++;
|
|
||||||
world.sendMessage(`Added point ${this.currentTrail.currentPoint}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Update() {
|
|
||||||
this.currentTrail.points.forEach((point) => {
|
|
||||||
spawnParticle(point.position, "minecraft:balloon_gas_particle", new MolangVariableMap());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Export() {}
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.currentTrail = new Trail();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Trail {
|
|
||||||
points: Point[] = [];
|
|
||||||
currentPoint: number = 0;
|
|
||||||
nextParticleTimer: number = 0;
|
|
||||||
currentParticleCounter: number = 0;
|
|
||||||
|
|
||||||
constructor() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Point {
|
|
||||||
position: Vector3;
|
|
||||||
index: number;
|
|
||||||
|
|
||||||
constructor(position: Vector3, index: number) {
|
|
||||||
this.position = position;
|
|
||||||
this.index = index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -54,6 +54,7 @@ export class Maker {
|
|||||||
} else {
|
} else {
|
||||||
world.sendMessage("No trigger to delete");
|
world.sendMessage("No trigger to delete");
|
||||||
}
|
}
|
||||||
|
this.manager.Save();
|
||||||
}
|
}
|
||||||
const command = event.message.split(" ")[0];
|
const command = event.message.split(" ")[0];
|
||||||
if (command == "!setFunction") {
|
if (command == "!setFunction") {
|
||||||
|
|||||||
70
scripts/Commandeer/chalk.ts
Normal file
70
scripts/Commandeer/chalk.ts
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
class Chalk {
|
||||||
|
static red(text: string): string {
|
||||||
|
return "§c" + text + "§r";
|
||||||
|
}
|
||||||
|
static yellow(text: string): string {
|
||||||
|
return "§e" + text + "§r";
|
||||||
|
}
|
||||||
|
static green(text: string): string {
|
||||||
|
return "§a" + text + "§r";
|
||||||
|
}
|
||||||
|
static blue(text: string): string {
|
||||||
|
return "§9" + text + "§r";
|
||||||
|
}
|
||||||
|
static aqua(text: string): string {
|
||||||
|
return "§b" + text + "§r";
|
||||||
|
}
|
||||||
|
static white(text: string): string {
|
||||||
|
return "§f" + text + "§r";
|
||||||
|
}
|
||||||
|
static black(text: string): string {
|
||||||
|
return "§0" + text + "§r";
|
||||||
|
}
|
||||||
|
static gold(text: string): string {
|
||||||
|
return "§6" + text + "§r";
|
||||||
|
}
|
||||||
|
static gray(text: string): string {
|
||||||
|
return "§7" + text + "§r";
|
||||||
|
}
|
||||||
|
static darkRed(text: string): string {
|
||||||
|
return "§4" + text + "§r";
|
||||||
|
}
|
||||||
|
static darkGreen(text: string): string {
|
||||||
|
return "§2" + text + "§r";
|
||||||
|
}
|
||||||
|
static darkBlue(text: string): string {
|
||||||
|
return "§1" + text + "§r";
|
||||||
|
}
|
||||||
|
static darkAqua(text: string): string {
|
||||||
|
return "§3" + text + "§r";
|
||||||
|
}
|
||||||
|
static darkPurple(text: string): string {
|
||||||
|
return "§5" + text + "§r";
|
||||||
|
}
|
||||||
|
static darkGray(text: string): string {
|
||||||
|
return "§8" + text + "§r";
|
||||||
|
}
|
||||||
|
static lightPurple(text: string): string {
|
||||||
|
return "§d" + text + "§r";
|
||||||
|
}
|
||||||
|
static bold(text: string): string {
|
||||||
|
return "§l" + text + "§r";
|
||||||
|
}
|
||||||
|
static italic(text: string): string {
|
||||||
|
return "§o" + text + "§r";
|
||||||
|
}
|
||||||
|
static underline(text: string): string {
|
||||||
|
return "§n" + text + "§r";
|
||||||
|
}
|
||||||
|
static strikethrough(text: string): string {
|
||||||
|
return "§m" + text + "§r";
|
||||||
|
}
|
||||||
|
static obfuscated(text: string): string {
|
||||||
|
return "§k" + text + "§r";
|
||||||
|
}
|
||||||
|
static reset(text: string): string {
|
||||||
|
return "§r" + text + "§r";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Chalk;
|
||||||
@@ -1,14 +1,19 @@
|
|||||||
import { RawText, TicksPerSecond, TitleDisplayOptions, Vector3, World, system } from "@minecraft/server";
|
import {
|
||||||
|
EntityInventoryComponent,
|
||||||
|
ItemStack,
|
||||||
|
Player,
|
||||||
|
RawText,
|
||||||
|
TicksPerSecond,
|
||||||
|
TitleDisplayOptions,
|
||||||
|
Vector3,
|
||||||
|
World,
|
||||||
|
system,
|
||||||
|
world,
|
||||||
|
} from "@minecraft/server";
|
||||||
import { delayedRun } from "./utils/waitUtil";
|
import { delayedRun } from "./utils/waitUtil";
|
||||||
|
|
||||||
class Pupeteer {
|
class Pupeteer {
|
||||||
world: World;
|
private static getActualString(message: string): string | RawText {
|
||||||
|
|
||||||
constructor(world: World) {
|
|
||||||
this.world = world;
|
|
||||||
}
|
|
||||||
|
|
||||||
private getActualString(message: string): string | RawText {
|
|
||||||
if (message.startsWith("%")) {
|
if (message.startsWith("%")) {
|
||||||
const key = message.substring(1);
|
const key = message.substring(1);
|
||||||
return { rawtext: [{ translate: key }] };
|
return { rawtext: [{ translate: key }] };
|
||||||
@@ -16,27 +21,31 @@ class Pupeteer {
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
setActionBarTimed(message: string, duration: number): void {
|
static setActionBarTimed(message: string, duration: number): void {
|
||||||
this.world.getPlayers().forEach((player) => {
|
world.getPlayers().forEach((player) => {
|
||||||
player.onScreenDisplay.setActionBar(this.getActualString(message));
|
system.run(() => {
|
||||||
|
player.onScreenDisplay.setActionBar(this.getActualString(message));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
delayedRun(() => {
|
delayedRun(() => {
|
||||||
this.clearActionBar();
|
this.clearActionBar();
|
||||||
}, duration * TicksPerSecond);
|
}, duration * TicksPerSecond);
|
||||||
}
|
}
|
||||||
|
|
||||||
setActionBar(message: string): void {
|
static setActionBar(message: string): void {
|
||||||
this.world.getPlayers().forEach((player) => {
|
world.getPlayers().forEach((player) => {
|
||||||
player.onScreenDisplay.setActionBar(this.getActualString(message));
|
system.run(() => {
|
||||||
|
player.onScreenDisplay.setActionBar(this.getActualString(message));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sendWorldMessage(message: string): void {
|
static sendWorldMessage(message: string): void {
|
||||||
this.world.sendMessage(this.getActualString(message));
|
world.sendMessage(this.getActualString(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
setTitleTimed(message: string, duration: number): void {
|
static setTitleTimed(message: string, duration: number): void {
|
||||||
this.world.getPlayers().forEach((player) => {
|
world.getPlayers().forEach((player) => {
|
||||||
let options: TitleDisplayOptions = {
|
let options: TitleDisplayOptions = {
|
||||||
fadeInDuration: 20,
|
fadeInDuration: 20,
|
||||||
fadeOutDuration: 20,
|
fadeOutDuration: 20,
|
||||||
@@ -46,39 +55,39 @@ class Pupeteer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setTitle(message: string): void {
|
static setTitle(message: string): void {
|
||||||
this.world.getPlayers().forEach((player) => {
|
world.getPlayers().forEach((player) => {
|
||||||
player.onScreenDisplay.setTitle(message);
|
player.onScreenDisplay.setTitle(message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSubtitle(message: string): void {
|
static updateSubtitle(message: string): void {
|
||||||
this.world.getPlayers().forEach((player) => {
|
world.getPlayers().forEach((player) => {
|
||||||
player.onScreenDisplay.updateSubtitle(this.getActualString(message));
|
player.onScreenDisplay.updateSubtitle(this.getActualString(message));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
clearTitle(): void {
|
static clearTitle(): void {
|
||||||
this.world.getPlayers().forEach((player) => {
|
world.getPlayers().forEach((player) => {
|
||||||
player.onScreenDisplay.setTitle("");
|
player.onScreenDisplay.setTitle("");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
clearSubtitle(): void {
|
static clearSubtitle(): void {
|
||||||
this.world.getPlayers().forEach((player) => {
|
world.getPlayers().forEach((player) => {
|
||||||
player.onScreenDisplay.updateSubtitle("");
|
player.onScreenDisplay.updateSubtitle("");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
clearActionBar(): void {
|
static clearActionBar(): void {
|
||||||
this.world.getPlayers().forEach((player) => {
|
world.getPlayers().forEach((player) => {
|
||||||
player.onScreenDisplay.setActionBar("");
|
player.onScreenDisplay.setActionBar("");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
testForLocation(location: Vector3, radius: number): boolean {
|
static testForLocation(location: Vector3, radius: number): boolean {
|
||||||
let isPlayerInArea = false;
|
let isPlayerInArea = false;
|
||||||
this.world.getPlayers().forEach((player) => {
|
world.getPlayers().forEach((player) => {
|
||||||
let dx = location.x - player.location.x;
|
let dx = location.x - player.location.x;
|
||||||
let dy = location.y - player.location.y;
|
let dy = location.y - player.location.y;
|
||||||
let dz = location.z - player.location.z;
|
let dz = location.z - player.location.z;
|
||||||
@@ -91,8 +100,12 @@ class Pupeteer {
|
|||||||
return isPlayerInArea;
|
return isPlayerInArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
setNpcText(npcTag: string, sceneName: string) {
|
static setNpcText(npcTag: string, sceneName: string) {
|
||||||
this.world.getDimension("overworld").runCommand(`/dialogue change @e[tag=${npcTag}] ${sceneName} @a`);
|
world.getDimension("overworld").runCommand(`/dialogue change @e[tag=${npcTag}] ${sceneName} @a`);
|
||||||
|
}
|
||||||
|
|
||||||
|
static givePlayerItem(player: Player, item: ItemStack) {
|
||||||
|
(player.getComponent("inventory") as EntityInventoryComponent).container.addItem(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
211
scripts/Commandeer/trail/trailMaker.ts
Normal file
211
scripts/Commandeer/trail/trailMaker.ts
Normal file
@@ -0,0 +1,211 @@
|
|||||||
|
import {
|
||||||
|
Block,
|
||||||
|
ChatSendAfterEvent,
|
||||||
|
EntityInventoryComponent,
|
||||||
|
ItemStack,
|
||||||
|
ItemUseOnBeforeEvent,
|
||||||
|
MolangVariableMap,
|
||||||
|
Player,
|
||||||
|
world,
|
||||||
|
} from "@minecraft/server";
|
||||||
|
import { Vector3 } from "@minecraft/server";
|
||||||
|
import { Vector3Add, Vector3ToString, vector3 } from "../utils/vectorUtils";
|
||||||
|
import { spawnParticle } from "../utils/particleUtils";
|
||||||
|
import Pupeteer from "../pupeteer";
|
||||||
|
import Chalk from "../chalk";
|
||||||
|
|
||||||
|
export namespace TrailMaker {
|
||||||
|
export class Maker {
|
||||||
|
currentTrail: Trail;
|
||||||
|
log: Map<string, number> = new Map();
|
||||||
|
selectedIndex: number = 0;
|
||||||
|
|
||||||
|
//Line
|
||||||
|
point1: Vector3 = vector3(0, 0, 0);
|
||||||
|
point2: Vector3 = vector3(0, 0, 0);
|
||||||
|
|
||||||
|
waitingForPoint2: boolean = false;
|
||||||
|
|
||||||
|
OnChat(event: ChatSendAfterEvent) {
|
||||||
|
if (event.message == "!trailWand") {
|
||||||
|
let item: ItemStack = new ItemStack("minecraft:stick");
|
||||||
|
item.nameTag = "AddPoint";
|
||||||
|
Pupeteer.givePlayerItem(event.sender as Player, item);
|
||||||
|
world.sendMessage("Thou shall have the Trailing Powah");
|
||||||
|
}
|
||||||
|
if (event.message == "!trailDeleteWand") {
|
||||||
|
let item: ItemStack = new ItemStack("minecraft:stick");
|
||||||
|
item.nameTag = "DeletePoint";
|
||||||
|
Pupeteer.givePlayerItem(event.sender as Player, item);
|
||||||
|
world.sendMessage("Luke, i'm NOT your father");
|
||||||
|
}
|
||||||
|
if (event.message == "!trailLineWand") {
|
||||||
|
let item: ItemStack = new ItemStack("minecraft:stick");
|
||||||
|
item.nameTag = "AddLine";
|
||||||
|
Pupeteer.givePlayerItem(event.sender as Player, item);
|
||||||
|
world.sendMessage(`This is where i draw the ${Chalk.red("Line")} >:(`);
|
||||||
|
}
|
||||||
|
if (event.message == "!trailExport") {
|
||||||
|
this.Export();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
OnItemUse(event: ItemUseOnBeforeEvent) {
|
||||||
|
const currentItemHeld: ItemStack = event.itemStack;
|
||||||
|
const blockInteracted: Block = event.block;
|
||||||
|
const player: Player = event.source as Player;
|
||||||
|
const oldLog = this.log.get(player.name)!;
|
||||||
|
this.log.set(player.name, Date.now());
|
||||||
|
if (oldLog + 150 >= Date.now()) return;
|
||||||
|
|
||||||
|
if (event.itemStack.typeId == "minecraft:stick" && event.itemStack.nameTag == "AddPoint") {
|
||||||
|
let block = event.block;
|
||||||
|
let pos = this.BlockToParticlePosition(block);
|
||||||
|
this.currentTrail.points.push(new Point(pos, this.currentTrail.currentPoint));
|
||||||
|
|
||||||
|
this.currentTrail.currentPoint++;
|
||||||
|
Pupeteer.setActionBarTimed(`Added point ${this.currentTrail.currentPoint}`, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.itemStack.typeId == "minecraft:stick" && event.itemStack.nameTag == "DeletePoint") {
|
||||||
|
let block = event.block;
|
||||||
|
let pos = this.BlockToParticlePosition(block);
|
||||||
|
|
||||||
|
let point = this.currentTrail.points.find((point) => Vector3ToString(point.position) == Vector3ToString(pos));
|
||||||
|
if (point) {
|
||||||
|
this.currentTrail.points.splice(this.currentTrail.points.indexOf(point), 1);
|
||||||
|
Pupeteer.setActionBarTimed(`Deleted point ${point.index}`, 3);
|
||||||
|
} else {
|
||||||
|
Pupeteer.setActionBarTimed(`No point found`, 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.itemStack.typeId == "minecraft:stick" && event.itemStack.nameTag == "AddLine") {
|
||||||
|
if (!this.waitingForPoint2) {
|
||||||
|
this.point1 = vector3(blockInteracted.location.x, blockInteracted.location.y, blockInteracted.location.z);
|
||||||
|
this.point1 = Vector3Add(this.point1, vector3(0.5, 0, 0.5));
|
||||||
|
let isHalfBlock = blockInteracted.typeId.includes("slab") || blockInteracted.typeId.includes("stair");
|
||||||
|
if (isHalfBlock) {
|
||||||
|
this.point1 = Vector3Add(this.point1, vector3(0, 0.5, 0));
|
||||||
|
} else {
|
||||||
|
this.point1 = Vector3Add(this.point1, vector3(0, 1.1, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.waitingForPoint2 = true;
|
||||||
|
Pupeteer.setActionBar("Select a second point");
|
||||||
|
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
this.point2 = this.BlockToParticlePosition(blockInteracted);
|
||||||
|
|
||||||
|
//Calculate the blocks between these 2 points, andd add them to the trail
|
||||||
|
//Assume point1 is the start, and point2 is the end
|
||||||
|
let x1 = this.point1.x;
|
||||||
|
let x2 = this.point2.x;
|
||||||
|
let y1 = this.point1.y;
|
||||||
|
let y2 = this.point2.y;
|
||||||
|
let z1 = this.point1.z;
|
||||||
|
let z2 = this.point2.z;
|
||||||
|
|
||||||
|
//Find out what axis is the movement on, throw an error if it's on more than one axis
|
||||||
|
|
||||||
|
let xDiff = Math.abs(x2 - x1);
|
||||||
|
let yDiff = Math.abs(y2 - y1);
|
||||||
|
let zDiff = Math.abs(z2 - z1);
|
||||||
|
|
||||||
|
let axis = "";
|
||||||
|
|
||||||
|
if (xDiff > 0 && yDiff == 0 && zDiff == 0) {
|
||||||
|
axis = "x";
|
||||||
|
} else if (xDiff == 0 && yDiff > 0 && zDiff == 0) {
|
||||||
|
axis = "y";
|
||||||
|
} else if (xDiff == 0 && yDiff == 0 && zDiff > 0) {
|
||||||
|
axis = "z";
|
||||||
|
} else {
|
||||||
|
Pupeteer.setActionBarTimed("Invalid line", 3);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let start = 0;
|
||||||
|
let end = 0;
|
||||||
|
|
||||||
|
if (axis == "x") {
|
||||||
|
start = Math.min(x1, x2);
|
||||||
|
end = Math.max(x1, x2);
|
||||||
|
} else if (axis == "y") {
|
||||||
|
start = Math.min(y1, y2);
|
||||||
|
end = Math.max(y1, y2);
|
||||||
|
} else if (axis == "z") {
|
||||||
|
start = Math.min(z1, z2);
|
||||||
|
end = Math.max(z1, z2);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = start; i <= end; i++) {
|
||||||
|
let pos = vector3(0, 0, 0);
|
||||||
|
if (axis == "x") {
|
||||||
|
pos = vector3(i, y1, z1);
|
||||||
|
} else if (axis == "y") {
|
||||||
|
pos = vector3(x1, i, z1);
|
||||||
|
} else if (axis == "z") {
|
||||||
|
pos = vector3(x1, y1, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.currentTrail.points.push(new Point(pos, this.currentTrail.currentPoint));
|
||||||
|
this.currentTrail.currentPoint++;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.waitingForPoint2 = false;
|
||||||
|
Pupeteer.setActionBarTimed("Added line", 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Update() {
|
||||||
|
this.currentTrail.points.forEach((point) => {
|
||||||
|
spawnParticle(point.position, "minecraft:balloon_gas_particle", new MolangVariableMap());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Export() {
|
||||||
|
//Convert to json, and send to the log with console.warn
|
||||||
|
let json = JSON.stringify(this.currentTrail.points);
|
||||||
|
console.warn(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BlockToParticlePosition(block: Block): Vector3 {
|
||||||
|
let pos = vector3(block.location.x, block.location.y, block.location.z);
|
||||||
|
pos = Vector3Add(pos, vector3(0.5, 0, 0.5));
|
||||||
|
//If block is a slab or stair, offset by half a block
|
||||||
|
|
||||||
|
let isHalfBlock = block.typeId.includes("slab") || block.typeId.includes("stair");
|
||||||
|
if (isHalfBlock) {
|
||||||
|
pos = Vector3Add(pos, vector3(0, 0.5, 0));
|
||||||
|
} else {
|
||||||
|
pos = Vector3Add(pos, vector3(0, 1.1, 0));
|
||||||
|
}
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.currentTrail = new Trail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Trail {
|
||||||
|
points: Point[] = [];
|
||||||
|
currentPoint: number = 0;
|
||||||
|
nextParticleTimer: number = 0;
|
||||||
|
currentParticleCounter: number = 0;
|
||||||
|
|
||||||
|
constructor() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Point {
|
||||||
|
position: Vector3;
|
||||||
|
index: number;
|
||||||
|
|
||||||
|
constructor(position: Vector3, index: number) {
|
||||||
|
this.position = position;
|
||||||
|
this.index = index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,10 @@ function Vector3ToString(vector: Vector3) {
|
|||||||
return vector.x + "," + vector.y + "," + vector.z;
|
return vector.x + "," + vector.y + "," + vector.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Vector3ToCommandString(vector: Vector3) {
|
||||||
|
return `${vector.x} ${vector.y} ${vector.z}`;
|
||||||
|
}
|
||||||
|
|
||||||
function Vector3ToFancyString(vector: Vector3) {
|
function Vector3ToFancyString(vector: Vector3) {
|
||||||
return `{X: ${Math.floor(vector.x)}, Y: ${Math.floor(vector.y)}, Z: ${Math.floor(vector.z)}}`;
|
return `{X: ${Math.floor(vector.x)}, Y: ${Math.floor(vector.y)}, Z: ${Math.floor(vector.z)}}`;
|
||||||
}
|
}
|
||||||
@@ -62,5 +66,6 @@ export {
|
|||||||
Vector3Round,
|
Vector3Round,
|
||||||
Vector3Abs,
|
Vector3Abs,
|
||||||
vector3Distance,
|
vector3Distance,
|
||||||
|
Vector3ToCommandString,
|
||||||
vector3,
|
vector3,
|
||||||
};
|
};
|
||||||
|
|||||||
46
scripts/levels/levelIntro.ts
Normal file
46
scripts/levels/levelIntro.ts
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import { Vector3, world } from "@minecraft/server";
|
||||||
|
import Level from "../Commandeer/level/level";
|
||||||
|
import { leverOn } from "../Commandeer/level/levelTypes";
|
||||||
|
import { teleportAgent, isAgentAt } from "../Commandeer/utils/agentUtils";
|
||||||
|
import { startLevel } from "../Commandeer/utils/levelUtils";
|
||||||
|
import { vector3 } from "../Commandeer/utils/vectorUtils";
|
||||||
|
import { levelIntroConditions } from "../levelConditions/levelIntro";
|
||||||
|
import { CURRENT_LEVEL, mindKeeper } from "../main";
|
||||||
|
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 levelIntro: Level = new Level(
|
||||||
|
() => {
|
||||||
|
Pupeteer.sendWorldMessage("%message.intro.started");
|
||||||
|
Pupeteer.setTitleTimed("%message.intro.started", 2.5);
|
||||||
|
// startLevel(levelIntroCommandBlockPos);
|
||||||
|
// teleportAgent(levelIntroStartPosition);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
Pupeteer.setActionBar("%message.intro.make");
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
Pupeteer.clearActionBar();
|
||||||
|
world.sendMessage("%message.intro.done");
|
||||||
|
Pupeteer.setTitleTimed("%message.intro.done", 2.5);
|
||||||
|
|
||||||
|
mindKeeper.increment(CURRENT_LEVEL);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
let isComplete = true;
|
||||||
|
levelIntroConditions.conditions.forEach((condition) => {
|
||||||
|
let blockInworld = world.getDimension("overworld").getBlock(condition.position);
|
||||||
|
if (blockInworld?.type !== condition.block) {
|
||||||
|
isComplete = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (isComplete) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
export default levelIntro;
|
||||||
283
scripts/main.ts
283
scripts/main.ts
@@ -15,24 +15,41 @@ import Pupeteer from "./Commandeer/pupeteer";
|
|||||||
import Level from "./Commandeer/level/level";
|
import Level from "./Commandeer/level/level";
|
||||||
import { leverOn } from "./Commandeer/level/levelTypes";
|
import { leverOn } from "./Commandeer/level/levelTypes";
|
||||||
import { levelIntroConditions } from "./levelConditions/levelIntro";
|
import { levelIntroConditions } from "./levelConditions/levelIntro";
|
||||||
import { Vector3ToFancyString, Vector3ToString, vector3 } from "./Commandeer/utils/vectorUtils";
|
import {
|
||||||
|
Vector3Add,
|
||||||
|
Vector3ToCommandString,
|
||||||
|
Vector3ToFancyString,
|
||||||
|
Vector3ToString,
|
||||||
|
vector3,
|
||||||
|
} from "./Commandeer/utils/vectorUtils";
|
||||||
import { delay } from "./Commandeer/utils/waitUtil";
|
import { delay } from "./Commandeer/utils/waitUtil";
|
||||||
import { PARTICLES, ParticleColumn, bedrockParticles, spawnParticle } from "./Commandeer/utils/particleUtils";
|
import { PARTICLES, ParticleColumn, bedrockParticles, spawnParticle } from "./Commandeer/utils/particleUtils";
|
||||||
import { drawArrow } from "./Commandeer/utils/arrow";
|
import { drawArrow } from "./Commandeer/utils/arrow";
|
||||||
import * as agentUtils from "./Commandeer/utils/agentUtils";
|
import * as agentUtils from "./Commandeer/utils/agentUtils";
|
||||||
import { level3Conditions } from "./levelConditions/level3";
|
import { level3Conditions } from "./levelConditions/level3";
|
||||||
import { TrailMaker } from "./Commandeer/Makers/trailMaker";
|
import { TrailMaker } from "./Commandeer/trail/trailMaker";
|
||||||
import * as CCTrigger from "./Commandeer/Trigger/CCTrigger";
|
import * as CCTrigger from "./Commandeer/Trigger/CCTrigger";
|
||||||
import { Command, Commands } from "./Commandeer/command/command";
|
import { Command, Commands } from "./Commandeer/command/command";
|
||||||
|
// import { loadTriggers } from "./triggers";
|
||||||
|
|
||||||
const mindKeeper = new Mindkeeper(world);
|
const mindKeeper = new Mindkeeper(world);
|
||||||
const pupeteer = new Pupeteer(world);
|
|
||||||
const trailMaker: TrailMaker.Maker = new TrailMaker.Maker();
|
const trailMaker: TrailMaker.Maker = new TrailMaker.Maker();
|
||||||
const triggerManager = new CCTrigger.Manager(mindKeeper);
|
const triggerManager = new CCTrigger.Manager(mindKeeper);
|
||||||
const CURRENT_LEVEL = "currentLevel";
|
const CURRENT_LEVEL = "currentLevel";
|
||||||
const AGENT_ID = "agentid";
|
const AGENT_ID = "agentid";
|
||||||
const PREFIX = "!";
|
const PREFIX = "!";
|
||||||
export { pupeteer, mindKeeper, CURRENT_LEVEL };
|
export { mindKeeper, CURRENT_LEVEL, triggerManager };
|
||||||
|
|
||||||
|
// loadTriggers();
|
||||||
|
// loadCommands();
|
||||||
|
|
||||||
|
triggerManager.RegisterFunctionTrigger("resetPath", (event) => {
|
||||||
|
resetLightPath();
|
||||||
|
});
|
||||||
|
|
||||||
|
async function resetLightPath() {
|
||||||
|
world.getDimension("overworld").runCommand("/fill 2467 9 87 2468 9 105 air");
|
||||||
|
}
|
||||||
|
|
||||||
const DEVELOPER_MODE = true;
|
const DEVELOPER_MODE = true;
|
||||||
let tickCounter = 0;
|
let tickCounter = 0;
|
||||||
@@ -111,6 +128,7 @@ function updateIntro() {
|
|||||||
|
|
||||||
buttonPositions.forEach((pos) => {
|
buttonPositions.forEach((pos) => {
|
||||||
let block = world.getDimension("overworld").getBlock(pos);
|
let block = world.getDimension("overworld").getBlock(pos);
|
||||||
|
if (!block) return;
|
||||||
let index = buttonPositions.indexOf(pos);
|
let index = buttonPositions.indexOf(pos);
|
||||||
let prevState = buttonPressed[index];
|
let prevState = buttonPressed[index];
|
||||||
let currentState = block!.getRedstonePower()! > 0;
|
let currentState = block!.getRedstonePower()! > 0;
|
||||||
@@ -141,6 +159,7 @@ world.afterEvents.worldInitialize.subscribe(({ propertyRegistry }) => {
|
|||||||
mindKeeper.registerToWorld(propertyRegistry);
|
mindKeeper.registerToWorld(propertyRegistry);
|
||||||
|
|
||||||
triggerManager.Load();
|
triggerManager.Load();
|
||||||
|
// loadCommands();
|
||||||
});
|
});
|
||||||
|
|
||||||
world.beforeEvents.itemUseOn.subscribe((event) => {
|
world.beforeEvents.itemUseOn.subscribe((event) => {
|
||||||
@@ -159,7 +178,9 @@ function randomExplosions() {
|
|||||||
pos1.z + Math.random() * (pos2.z - pos1.z)
|
pos1.z + Math.random() * (pos2.z - pos1.z)
|
||||||
);
|
);
|
||||||
//create a particle
|
//create a particle
|
||||||
spawnParticle(pos, "minecraft:huge_explosion_emitter", new MolangVariableMap());
|
system.run(() => {
|
||||||
|
spawnParticle(pos, "minecraft:huge_explosion_emitter", new MolangVariableMap());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,10 +193,12 @@ let doorSize = vector3(7, 7, 7);
|
|||||||
///clone 2463 -30 81 2470 -23 87 2463 10 81
|
///clone 2463 -30 81 2470 -23 87 2463 10 81
|
||||||
|
|
||||||
function blowUpDoor() {
|
function blowUpDoor() {
|
||||||
|
world.sendMessage("Blowing up door");
|
||||||
world.getDimension("overworld").runCommand("/clone 2463 -10 81 2470 -3 87 2463 10 81");
|
world.getDimension("overworld").runCommand("/clone 2463 -10 81 2470 -3 87 2463 10 81");
|
||||||
}
|
}
|
||||||
function restoreDoor() {
|
function restoreDoor() {
|
||||||
world.getDimension("overworld").runCommand("/clone 2463 -30 81 2470 -23 87 2463 10 81");
|
world.sendMessage("Restoring door");
|
||||||
|
world.getDimension("overworld").runCommandAsync("/clone 2463 -30 81 2470 -23 87 2463 10 81");
|
||||||
}
|
}
|
||||||
|
|
||||||
world.afterEvents.chatSend.subscribe((event: ChatSendAfterEvent) => {
|
world.afterEvents.chatSend.subscribe((event: ChatSendAfterEvent) => {
|
||||||
@@ -190,6 +213,173 @@ world.afterEvents.chatSend.subscribe((event: ChatSendAfterEvent) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
system.afterEvents.scriptEventReceive.subscribe((event) => {
|
||||||
|
if (event.id == "cc:getId") {
|
||||||
|
let id = event.message;
|
||||||
|
world.sendMessage("Script got the id " + id);
|
||||||
|
mindKeeper.set(AGENT_ID, id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
class ClonePos {
|
||||||
|
point1: Vector3;
|
||||||
|
point2: Vector3;
|
||||||
|
|
||||||
|
constructor(point1: Vector3, point2: Vector3) {
|
||||||
|
this.point1 = point1;
|
||||||
|
this.point2 = point2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const FrontAirLockOpenFrames: ClonePos[] = [
|
||||||
|
{
|
||||||
|
point1: vector3(2476, 9, 94),
|
||||||
|
point2: vector3(2474, 7, 94),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
point1: vector3(2476, 5, 94),
|
||||||
|
point2: vector3(2474, 3, 94),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
point1: vector3(2476, 1, 94),
|
||||||
|
point2: vector3(2474, -1, 94),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
point1: vector3(2476, -3, 94),
|
||||||
|
point2: vector3(2474, -5, 94),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const BackAirLockOpenFrames: ClonePos[] = [
|
||||||
|
{
|
||||||
|
point1: vector3(2472, 9, 100),
|
||||||
|
point2: vector3(2472, 7, 102),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
point1: vector3(2472, 5, 100),
|
||||||
|
point2: vector3(2472, 3, 102),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
point1: vector3(2472, 1, 100),
|
||||||
|
point2: vector3(2472, -1, 102),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
point1: vector3(2472, -3, 100),
|
||||||
|
point2: vector3(2472, -5, 102),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const AirLockWaterFrames: ClonePos[] = [
|
||||||
|
{
|
||||||
|
point1: vector3(2473, 11, 95),
|
||||||
|
point2: vector3(2477, 11, 103),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
point1: vector3(2473, 12, 95),
|
||||||
|
point2: vector3(2477, 12, 103),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
point1: vector3(2473, 13, 95),
|
||||||
|
point2: vector3(2477, 13, 103),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
point1: vector3(2473, 14, 95),
|
||||||
|
point2: vector3(2477, 14, 103),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
async function CycleAirLockWater(fill: boolean, delayTime: number) {
|
||||||
|
if (animationPlaying) {
|
||||||
|
world.sendMessage("Animation already playing");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
animationPlaying = true;
|
||||||
|
let frameCount = AirLockWaterFrames.length;
|
||||||
|
|
||||||
|
for (let i = 0; i < frameCount; i++) {
|
||||||
|
let frame = fill ? AirLockWaterFrames[i] : AirLockWaterFrames[frameCount - i - 1];
|
||||||
|
let blockToFill = fill ? "minecraft:water" : "minecraft:air";
|
||||||
|
await world
|
||||||
|
.getDimension("overworld")
|
||||||
|
.runCommandAsync(
|
||||||
|
`/fill ${Vector3ToCommandString(frame.point1)} ${Vector3ToCommandString(frame.point2)} ${blockToFill}`
|
||||||
|
);
|
||||||
|
await delay(delayTime);
|
||||||
|
}
|
||||||
|
animationPlaying = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum AirLockState {
|
||||||
|
Open,
|
||||||
|
Closed,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum AirLockChamberState {
|
||||||
|
Full,
|
||||||
|
Empty,
|
||||||
|
}
|
||||||
|
|
||||||
|
let frontAirlockState: AirLockState = AirLockState.Closed;
|
||||||
|
let backAirlockState: AirLockState = AirLockState.Closed;
|
||||||
|
|
||||||
|
let chamberState: AirLockChamberState = AirLockChamberState.Full;
|
||||||
|
|
||||||
|
//The airlock sequence is
|
||||||
|
//Player enters FrontAirLockOutside
|
||||||
|
//Front door opens
|
||||||
|
triggerManager.RegisterFunctionTrigger("FrontAirLockOutside", async (event) => {
|
||||||
|
if (chamberState == AirLockChamberState.Empty) {
|
||||||
|
world.sendMessage("Filling airlock");
|
||||||
|
await FillAirlockWater();
|
||||||
|
chamberState = AirLockChamberState.Full;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (frontAirlockState == AirLockState.Closed) {
|
||||||
|
await PlayFrontDoorOpenAnimation();
|
||||||
|
frontAirlockState = AirLockState.Open;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Player enters FrontAirLockInside
|
||||||
|
//Front door closes
|
||||||
|
//Water drains
|
||||||
|
//Back door opens
|
||||||
|
triggerManager.RegisterFunctionTrigger("FrontAirLockInside", async (event) => {
|
||||||
|
if (frontAirlockState == AirLockState.Open) {
|
||||||
|
await PlayFrontDoorCloseAnimation();
|
||||||
|
frontAirlockState = AirLockState.Closed;
|
||||||
|
}
|
||||||
|
if (chamberState == AirLockChamberState.Full) {
|
||||||
|
await delay(7);
|
||||||
|
await EmptyAirlockWater();
|
||||||
|
chamberState = AirLockChamberState.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (backAirlockState == AirLockState.Closed) {
|
||||||
|
await delay(7);
|
||||||
|
await PlayBackDoorOpenAnimation();
|
||||||
|
backAirlockState = AirLockState.Open;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Player enters BackAirLockOutside
|
||||||
|
//Back door closes
|
||||||
|
|
||||||
|
triggerManager.RegisterFunctionTrigger("BackAirLockOutside", async (event) => {
|
||||||
|
if (backAirlockState == AirLockState.Open) {
|
||||||
|
world.sendMessage("Closing back door");
|
||||||
|
await PlayBackDoorCloseAnimation();
|
||||||
|
backAirlockState = AirLockState.Closed;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// function loadCommands() {
|
||||||
|
Commands.register(PREFIX, "fien", (arg) => {
|
||||||
|
system.run(() => {
|
||||||
|
arg.player.teleport(vector3(2468, 11, 114));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
Commands.register(PREFIX, "info", (arg) => {
|
Commands.register(PREFIX, "info", (arg) => {
|
||||||
world.sendMessage("-----------------");
|
world.sendMessage("-----------------");
|
||||||
world.sendMessage("Current level: " + mindKeeper.get(CURRENT_LEVEL));
|
world.sendMessage("Current level: " + mindKeeper.get(CURRENT_LEVEL));
|
||||||
@@ -212,12 +402,77 @@ Commands.register(PREFIX, "kboom", (arg) => {
|
|||||||
})();
|
})();
|
||||||
});
|
});
|
||||||
|
|
||||||
Commands.register(PREFIX, "restore", restoreDoor);
|
Commands.register(PREFIX, "restore", (arg) => {
|
||||||
|
restoreDoor();
|
||||||
system.afterEvents.scriptEventReceive.subscribe((event) => {
|
|
||||||
if (event.id == "cc:getId") {
|
|
||||||
let id = event.message;
|
|
||||||
world.sendMessage("Script got the id " + id);
|
|
||||||
mindKeeper.set(AGENT_ID, id);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Commands.register(PREFIX, "resetAirlock", (arg) => {
|
||||||
|
SetFrontDoorClosed();
|
||||||
|
SetBackDoorClosed();
|
||||||
|
FillAirlockWater();
|
||||||
|
|
||||||
|
frontAirlockState = AirLockState.Closed;
|
||||||
|
backAirlockState = AirLockState.Closed;
|
||||||
|
chamberState = AirLockChamberState.Full;
|
||||||
|
});
|
||||||
|
// }
|
||||||
|
|
||||||
|
let frontDoorRoot: Vector3 = vector3(2474, 11, 94);
|
||||||
|
let backDoorRoot: Vector3 = vector3(2472, 11, 100);
|
||||||
|
|
||||||
|
const frameDuration = 7;
|
||||||
|
|
||||||
|
let SetFrontDoorClosed = () => SetFrame(FrontAirLockOpenFrames[0], frontDoorRoot);
|
||||||
|
let SetFrontDoorOpen = () => SetFrame(FrontAirLockOpenFrames[FrontAirLockOpenFrames.length - 1], frontDoorRoot);
|
||||||
|
let PlayFrontDoorOpenAnimation = async () => playAnimation(FrontAirLockOpenFrames, frameDuration, false, frontDoorRoot);
|
||||||
|
let PlayFrontDoorCloseAnimation = async () => playAnimation(FrontAirLockOpenFrames, frameDuration, true, frontDoorRoot);
|
||||||
|
|
||||||
|
let SetBackDoorClosed = () => SetFrame(BackAirLockOpenFrames[0], backDoorRoot);
|
||||||
|
let SetBackDoorOpen = () => SetFrame(BackAirLockOpenFrames[BackAirLockOpenFrames.length - 1], backDoorRoot);
|
||||||
|
let PlayBackDoorOpenAnimation = async () => playAnimation(BackAirLockOpenFrames, frameDuration, false, backDoorRoot);
|
||||||
|
let PlayBackDoorCloseAnimation = async () => playAnimation(BackAirLockOpenFrames, frameDuration, true, backDoorRoot);
|
||||||
|
|
||||||
|
let FillAirlockWater = async () => CycleAirLockWater(true, frameDuration / 1.5);
|
||||||
|
let EmptyAirlockWater = async () => CycleAirLockWater(false, frameDuration / 1.5);
|
||||||
|
|
||||||
|
triggerManager.RegisterFunctionTrigger("openFrontDoor", (event) => PlayFrontDoorOpenAnimation());
|
||||||
|
triggerManager.RegisterFunctionTrigger("closeFrontDoor", (event) => PlayFrontDoorCloseAnimation());
|
||||||
|
|
||||||
|
triggerManager.RegisterFunctionTrigger("openBackDoor", (event) => PlayBackDoorOpenAnimation());
|
||||||
|
triggerManager.RegisterFunctionTrigger("closeBackDoor", (event) => PlayBackDoorCloseAnimation());
|
||||||
|
|
||||||
|
triggerManager.RegisterFunctionTrigger("fillAirlock", (event) => FillAirlockWater());
|
||||||
|
triggerManager.RegisterFunctionTrigger("emptyAirlock", (event) => EmptyAirlockWater());
|
||||||
|
|
||||||
|
async function SetFrame(frame: ClonePos, destination: Vector3) {
|
||||||
|
await world
|
||||||
|
.getDimension("overworld")
|
||||||
|
.runCommandAsync(
|
||||||
|
`/clone ${Vector3ToCommandString(frame.point1)} ${Vector3ToCommandString(frame.point2)} ${Vector3ToCommandString(
|
||||||
|
destination
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let animationPlaying = false;
|
||||||
|
async function playAnimation(frames: ClonePos[], delayTime: number, reverse: boolean, destination: Vector3) {
|
||||||
|
if (animationPlaying) {
|
||||||
|
world.sendMessage("Animation already playing");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let frameCount = frames.length;
|
||||||
|
animationPlaying = true;
|
||||||
|
|
||||||
|
for (let i = 0; i < frameCount; i++) {
|
||||||
|
let frame = reverse ? frames[frameCount - i - 1] : frames[i];
|
||||||
|
await world
|
||||||
|
.getDimension("overworld")
|
||||||
|
.runCommandAsync(
|
||||||
|
`/clone ${Vector3ToCommandString(frame.point1)} ${Vector3ToCommandString(
|
||||||
|
frame.point2
|
||||||
|
)} ${Vector3ToCommandString(destination)}`
|
||||||
|
);
|
||||||
|
await delay(delayTime);
|
||||||
|
}
|
||||||
|
animationPlaying = false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { Dimension, MinecraftBlockTypes, world } from "@minecraft/server";
|
import { Dimension, MinecraftBlockTypes, world } from "@minecraft/server";
|
||||||
import { CCTrigger } from "./Commandeer/Trigger/CCTrigger";
|
import { CCTrigger } from "./Commandeer/Trigger/CCTrigger";
|
||||||
import { mindKeeper } from "./main";
|
import { mindKeeper, triggerManager } from "./main";
|
||||||
import { vector3 } from "./Commandeer/utils/vectorUtils";
|
import { vector3 } from "./Commandeer/utils/vectorUtils";
|
||||||
import { delay } from "./Commandeer/utils/waitUtil";
|
import { delay } from "./Commandeer/utils/waitUtil";
|
||||||
const triggerManager = new CCTrigger.Manager(mindKeeper);
|
|
||||||
|
// const triggerManager = new CCTrigger.Manager(mindKeeper);
|
||||||
|
|
||||||
triggerManager.RegisterFunctionTrigger("test", (event) => {
|
triggerManager.RegisterFunctionTrigger("test", (event) => {
|
||||||
world.sendMessage("Wow, this is a trigger :O");
|
world.sendMessage("Wow, this is a trigger :O");
|
||||||
@@ -18,6 +19,15 @@ triggerManager.RegisterFunctionTrigger("resetPath", (event) => {
|
|||||||
resetLightPath();
|
resetLightPath();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
triggerManager.RegisterFunctionTrigger("test2", (event) => {
|
||||||
|
world.sendMessage("Wow, this is another trigger :O");
|
||||||
|
});
|
||||||
|
|
||||||
|
triggerManager.RegisterFunctionTrigger("die", (event) => {
|
||||||
|
world.sendMessage("You died");
|
||||||
|
event.player.applyDamage(1000);
|
||||||
|
});
|
||||||
|
|
||||||
//fill 2467 9 87 2468 9 105 redstone_block
|
//fill 2467 9 87 2468 9 105 redstone_block
|
||||||
async function lightUpPath() {
|
async function lightUpPath() {
|
||||||
let overworld: Dimension = world.getDimension("overworld");
|
let overworld: Dimension = world.getDimension("overworld");
|
||||||
@@ -34,12 +44,3 @@ async function lightUpPath() {
|
|||||||
async function resetLightPath() {
|
async function resetLightPath() {
|
||||||
world.getDimension("overworld").runCommand("/fill 2467 9 87 2468 9 105 air");
|
world.getDimension("overworld").runCommand("/fill 2467 9 87 2468 9 105 air");
|
||||||
}
|
}
|
||||||
|
|
||||||
triggerManager.RegisterFunctionTrigger("test2", (event) => {
|
|
||||||
world.sendMessage("Wow, this is another trigger :O");
|
|
||||||
});
|
|
||||||
|
|
||||||
triggerManager.RegisterFunctionTrigger("die", (event) => {
|
|
||||||
world.sendMessage("You died");
|
|
||||||
event.player.applyDamage(1000);
|
|
||||||
});
|
|
||||||
|
|||||||
Reference in New Issue
Block a user