First Version

This commit is contained in:
2024-09-09 09:28:16 +02:00
parent 1ab45204b9
commit e5d35618f8
9 changed files with 69 additions and 43 deletions

View File

@@ -28,19 +28,19 @@ export namespace TrailMaker {
OnChat(event: ChatSendAfterEvent) {
if (event.message == "!trailWand") {
let item: ItemStack = new ItemStack("minecraft:stick");
const 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");
const 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");
const 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")} >:(`);
@@ -50,7 +50,6 @@ export namespace TrailMaker {
}
}
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)!;
@@ -58,8 +57,8 @@ export namespace TrailMaker {
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);
const block = event.block;
const pos = this.BlockToParticlePosition(block);
world.sendMessage(`Added Point ${Vector3ToString(pos)}`);
this.currentTrail.points.push(new Point(pos, this.currentTrail.currentPoint));
@@ -68,10 +67,10 @@ export namespace TrailMaker {
}
if (event.itemStack.typeId == "minecraft:stick" && event.itemStack.nameTag == "DeletePoint") {
let block = event.block;
let pos = this.BlockToParticlePosition(block);
const block = event.block;
const pos = this.BlockToParticlePosition(block);
let point = this.currentTrail.points.find((point) => Vector3ToString(point.position) == Vector3ToString(pos));
const 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);
@@ -96,18 +95,18 @@ export namespace TrailMaker {
//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;
const x1 = this.point1.x;
const x2 = this.point2.x;
const y1 = this.point1.y;
const y2 = this.point2.y;
const z1 = this.point1.z;
const 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);
const xDiff = Math.abs(x2 - x1);
const yDiff = Math.abs(y2 - y1);
const zDiff = Math.abs(z2 - z1);
let axis = "";
@@ -165,8 +164,8 @@ export namespace TrailMaker {
Export() {
let output = "";
for (let i = 0; i < this.currentTrail.points.length; i++) {
let point = this.currentTrail.points[i];
let actualPos = point.position;
const point = this.currentTrail.points[i];
const actualPos = point.position;
output += `{ index: ${point.index}, position: vector3(${actualPos.x}, ${actualPos.y}, ${actualPos.z}) },\n`;
}
console.warn(output);
@@ -177,7 +176,7 @@ export namespace TrailMaker {
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");
const isHalfBlock = block.typeId.includes("slab") || block.typeId.includes("stair");
if (isHalfBlock) {
pos = Vector3Add(pos, vector3(0, 0.5, 0));
} else {