Before Format Wars

This commit is contained in:
2024-08-29 10:45:07 +02:00
parent 35af9ffc97
commit 545e47a9f3
20 changed files with 1243 additions and 399 deletions

View File

@@ -12,6 +12,7 @@ class AbstractAgentTrackMission extends Level {
constructor(
levelid: string,
agentStartPositon: Vector3,
agentStartFacing: Vector3,
agentEndPosition: Vector3,
startLevelCommandBlockPos: Vector3
) {
@@ -20,7 +21,7 @@ class AbstractAgentTrackMission extends Level {
pupeteer.sendWorldMessage(`%message.${levelid}.started`);
pupeteer.setTitleTimed(`%message.${levelid}.name`, 2.5);
startLevel(startLevelCommandBlockPos);
teleportAgent(agentStartPositon);
teleportAgent(agentStartPositon, agentStartFacing);
},
() => {
pupeteer.setActionBar(`%message.${levelid}.make`);

View File

@@ -1,6 +1,7 @@
import { MolangVariableMap, Vector3, world } from "@minecraft/server";
import { Vector3Add } from "../utils/vectorUtils";
import { TrailType } from "./trailTypes";
import { PARTICLES, spawnParticle } from "../utils/particleUtils";
class TrailPoint {
postion: Vector3;
@@ -15,9 +16,7 @@ class TrailPoint {
// let spawnPosition: Vector3 = Vector3Add(this.postion, { x: 0.5, y: 0.5, z: 0.5 });
let spawnPosition: Vector3 = this.postion;
try {
world
.getDimension("overworld")
.spawnParticle("minecraft:balloon_gas_particle", spawnPosition, new MolangVariableMap());
spawnParticle(spawnPosition, PARTICLES.balloon_gas_particle, new MolangVariableMap());
} catch (e) {}
}
}
@@ -40,19 +39,14 @@ class Trail {
addPoint(point: TrailPoint) {
this.points.push(point);
//this could be a one liner,
let maxlength: number = 0;
this.points.forEach((point) => {
if (point.index > maxlength) {
maxlength = point.index;
}
});
this.calculatedLength = maxlength;
this.calculatedLength = this.points.length;
}
fromTrail(trail: TrailType) {
let currentIndex = 0;
trail.points.forEach((point) => {
this.addPoint(new TrailPoint(point.position, point.index));
this.addPoint(new TrailPoint(point.position, currentIndex));
currentIndex++;
});
}
@@ -63,17 +57,19 @@ class Trail {
let pointsPerInterval = this.wrapIndex > 0 ? this.calculatedLength / this.wrapIndex : 0;
this.points
.filter((point) => {
return (
point.index === this.currentPoint ||
(this.wrapIndex > 0 && point.index % pointsPerInterval === this.currentPoint)
);
if (this.wrapIndex > 0) {
return point.index % this.wrapIndex == this.currentPoint;
} else {
return point.index == this.currentPoint;
}
})
.forEach((point) => {
point.spawn();
});
this.currentPoint++;
if (this.currentPoint >= this.calculatedLength) {
let actualLength = this.wrapIndex > 0 ? this.wrapIndex : this.calculatedLength;
if (this.currentPoint >= actualLength) {
this.currentPoint = 0;
}
} else {

View File

@@ -1,5 +1,5 @@
import { Entity, Vector3, world } from "@minecraft/server";
import { Vector3ToString, vector3 } from "./vectorUtils";
import { Vector3Add, Vector3ToString, vector3 } from "./vectorUtils";
import { mindKeeper } from "../../main";
//Make a facing with vector3
@@ -11,10 +11,11 @@ function teleportAgent(position: Vector3, facing: Vector3 = vector3(0, 0, 0)): v
.getDimension("overworld")
.runCommand(`/execute as @a run tp @e[type=agent] ${position.x} ${position.y} ${position.z}`);
} else {
let facing2 = Vector3Add(position, facing);
world
.getDimension("overworld")
.runCommand(
`/execute as @a run tp @e[type=agent] ${position.x} ${position.y} ${position.z} facing ${facing.x} ${facing.y} ${facing.z}`
`/execute as @a run tp @e[type=agent] ${position.x} ${position.y} ${position.z} facing ${facing2.x} ${facing2.y} ${facing2.z}`
);
}
}

View File

@@ -222,6 +222,12 @@ function spawnParticle(
return;
}
map.setVector3("variable.direction", vector3(0, 0, 0));
// map.setFloat("Variable.r", 2);
map.setColorRGB("variable.color", {
red: 1,
green: 1,
blue: 1,
});
const dimension = world.getDimension("overworld");
if (dimension) {