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:
Bram Verhulst
2024-07-05 14:14:17 +02:00
parent 67af73c6b5
commit ba384d79d8
13 changed files with 697 additions and 129 deletions

View File

@@ -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";
class Pupeteer {
world: World;
constructor(world: World) {
this.world = world;
}
private getActualString(message: string): string | RawText {
private static getActualString(message: string): string | RawText {
if (message.startsWith("%")) {
const key = message.substring(1);
return { rawtext: [{ translate: key }] };
@@ -16,27 +21,31 @@ class Pupeteer {
return message;
}
setActionBarTimed(message: string, duration: number): void {
this.world.getPlayers().forEach((player) => {
player.onScreenDisplay.setActionBar(this.getActualString(message));
static setActionBarTimed(message: string, duration: number): void {
world.getPlayers().forEach((player) => {
system.run(() => {
player.onScreenDisplay.setActionBar(this.getActualString(message));
});
});
delayedRun(() => {
this.clearActionBar();
}, duration * TicksPerSecond);
}
setActionBar(message: string): void {
this.world.getPlayers().forEach((player) => {
player.onScreenDisplay.setActionBar(this.getActualString(message));
static setActionBar(message: string): void {
world.getPlayers().forEach((player) => {
system.run(() => {
player.onScreenDisplay.setActionBar(this.getActualString(message));
});
});
}
sendWorldMessage(message: string): void {
this.world.sendMessage(this.getActualString(message));
static sendWorldMessage(message: string): void {
world.sendMessage(this.getActualString(message));
}
setTitleTimed(message: string, duration: number): void {
this.world.getPlayers().forEach((player) => {
static setTitleTimed(message: string, duration: number): void {
world.getPlayers().forEach((player) => {
let options: TitleDisplayOptions = {
fadeInDuration: 20,
fadeOutDuration: 20,
@@ -46,39 +55,39 @@ class Pupeteer {
});
}
setTitle(message: string): void {
this.world.getPlayers().forEach((player) => {
static setTitle(message: string): void {
world.getPlayers().forEach((player) => {
player.onScreenDisplay.setTitle(message);
});
}
updateSubtitle(message: string): void {
this.world.getPlayers().forEach((player) => {
static updateSubtitle(message: string): void {
world.getPlayers().forEach((player) => {
player.onScreenDisplay.updateSubtitle(this.getActualString(message));
});
}
clearTitle(): void {
this.world.getPlayers().forEach((player) => {
static clearTitle(): void {
world.getPlayers().forEach((player) => {
player.onScreenDisplay.setTitle("");
});
}
clearSubtitle(): void {
this.world.getPlayers().forEach((player) => {
static clearSubtitle(): void {
world.getPlayers().forEach((player) => {
player.onScreenDisplay.updateSubtitle("");
});
}
clearActionBar(): void {
this.world.getPlayers().forEach((player) => {
static clearActionBar(): void {
world.getPlayers().forEach((player) => {
player.onScreenDisplay.setActionBar("");
});
}
testForLocation(location: Vector3, radius: number): boolean {
static testForLocation(location: Vector3, radius: number): boolean {
let isPlayerInArea = false;
this.world.getPlayers().forEach((player) => {
world.getPlayers().forEach((player) => {
let dx = location.x - player.location.x;
let dy = location.y - player.location.y;
let dz = location.z - player.location.z;
@@ -91,8 +100,12 @@ class Pupeteer {
return isPlayerInArea;
}
setNpcText(npcTag: string, sceneName: string) {
this.world.getDimension("overworld").runCommand(`/dialogue change @e[tag=${npcTag}] ${sceneName} @a`);
static setNpcText(npcTag: string, sceneName: string) {
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);
}
}