This commit is contained in:
2024-08-05 10:12:32 +02:00
parent ba384d79d8
commit 61c5a0e489
20 changed files with 1035 additions and 189 deletions

View File

@@ -60,6 +60,7 @@ export namespace TrailMaker {
if (event.itemStack.typeId == "minecraft:stick" && event.itemStack.nameTag == "AddPoint") {
let block = event.block;
let pos = this.BlockToParticlePosition(block);
world.sendMessage(`Added Point ${Vector3ToString(pos)}`);
this.currentTrail.points.push(new Point(pos, this.currentTrail.currentPoint));
this.currentTrail.currentPoint++;
@@ -80,18 +81,14 @@ export namespace TrailMaker {
}
if (event.itemStack.typeId == "minecraft:stick" && event.itemStack.nameTag == "AddLine") {
world.sendMessage(`Waiting for point 2: ${this.waitingForPoint2}`);
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.point1 = vector3(blockInteracted.location.x, blockInteracted.location.y, blockInteracted.location.z);
this.point1 = this.BlockToParticlePosition(blockInteracted);
this.waitingForPoint2 = true;
Pupeteer.setActionBar("Select a second point");
world.sendMessage("Select a second point");
return;
} else {
@@ -166,9 +163,13 @@ export namespace TrailMaker {
}
Export() {
//Convert to json, and send to the log with console.warn
let json = JSON.stringify(this.currentTrail.points);
console.warn(json);
let output = "";
for (let i = 0; i < this.currentTrail.points.length; i++) {
let point = this.currentTrail.points[i];
let actualPos = point.position;
output += `{ index: ${point.index}, position: vector3(${actualPos.x}, ${actualPos.y}, ${actualPos.z}) },\n`;
}
console.warn(output);
}
private BlockToParticlePosition(block: Block): Vector3 {