Add Formatting (Thank God)
This commit is contained in:
@@ -1,17 +1,15 @@
|
||||
import { Entity, Vector3, world } from "@minecraft/server";
|
||||
import { Vector3Add, Vector3ToString, vector3 } from "./vectorUtils";
|
||||
import { Vector3Add, vector3 } from "./vectorUtils";
|
||||
import { mindKeeper } from "../../main";
|
||||
|
||||
//Make a facing with vector3
|
||||
type Facing = Vector3;
|
||||
|
||||
function teleportAgent(position: Vector3, facing: Vector3 = vector3(0, 0, 0)): void {
|
||||
if (facing == vector3(0, 0, 0)) {
|
||||
world
|
||||
.getDimension("overworld")
|
||||
.runCommand(`/execute as @a run tp @e[type=agent] ${position.x} ${position.y} ${position.z}`);
|
||||
} else {
|
||||
let facing2 = Vector3Add(position, facing);
|
||||
const facing2 = Vector3Add(position, facing);
|
||||
world
|
||||
.getDimension("overworld")
|
||||
.runCommand(
|
||||
@@ -38,13 +36,13 @@ function isAgentAt(position: Vector3): boolean {
|
||||
}
|
||||
|
||||
function getAgent(): Entity {
|
||||
let agent = world.getEntity(mindKeeper.get("agentid") as string);
|
||||
const agent = world.getEntity(mindKeeper.get("agentid") as string);
|
||||
return agent!;
|
||||
}
|
||||
|
||||
function getAgentLocation(): Vector3 {
|
||||
let agentLocation: Vector3 = vector3(0, 0, 0);
|
||||
let agent = world.getEntity(mindKeeper.get("agentid") as string);
|
||||
const agent = world.getEntity(mindKeeper.get("agentid") as string);
|
||||
agentLocation = agent!.location;
|
||||
|
||||
return agentLocation;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { MolangVariableMap, Vector3, world } from "@minecraft/server";
|
||||
import { MolangVariableMap, Vector3 } from "@minecraft/server";
|
||||
import { Vector3Add, vector3 } from "./vectorUtils";
|
||||
import { PARTICLES, spawnParticle } from "./particleUtils";
|
||||
|
||||
let arrowTemplate: Vector3[] = [
|
||||
const arrowTemplate: Vector3[] = [
|
||||
vector3(0, 0, 0),
|
||||
|
||||
vector3(1, 1, 0),
|
||||
@@ -21,18 +21,16 @@ let arrowTemplate: Vector3[] = [
|
||||
vector3(0, 5, 0),
|
||||
];
|
||||
|
||||
let offset: Vector3 = vector3(0, 0, 0);
|
||||
|
||||
let angleOffset = 0;
|
||||
let heightBobbing = 0;
|
||||
let tickCounter = 0;
|
||||
|
||||
function rotate(pos: Vector3, angle: number) {
|
||||
let x = pos.x;
|
||||
let z = pos.z;
|
||||
const x = pos.x;
|
||||
const z = pos.z;
|
||||
|
||||
let newX = x * Math.cos(angle) - z * Math.sin(angle);
|
||||
let newZ = x * Math.sin(angle) + z * Math.cos(angle);
|
||||
const newX = x * Math.cos(angle) - z * Math.sin(angle);
|
||||
const newZ = x * Math.sin(angle) + z * Math.cos(angle);
|
||||
|
||||
return vector3(newX, pos.y, newZ);
|
||||
}
|
||||
@@ -49,10 +47,9 @@ function drawArrow(offsetPos: Vector3) {
|
||||
if (tickCounter % 2 == 0) {
|
||||
angleOffset += 0.1;
|
||||
heightBobbing += 0.3;
|
||||
offset = vector3(46.5, 75, 220.5);
|
||||
arrowTemplate.forEach((pos) => {
|
||||
let rotatedPos = rotate(pos, angleOffset);
|
||||
let finalPos = Vector3Add(offsetPos, rotatedPos);
|
||||
const rotatedPos = rotate(pos, angleOffset);
|
||||
const finalPos = Vector3Add(offsetPos, rotatedPos);
|
||||
finalPos.y += Math.sin(heightBobbing) / 2;
|
||||
spawnParticle(finalPos, PARTICLES.point, particleData);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BlockType, BlockTypes, BlockVolume, Vector3, world } from "@minecraft/server";
|
||||
import { BlockVolume, Vector3, world } from "@minecraft/server";
|
||||
import { MinecraftBlockTypes } from "../../vanilla-data/mojang-block";
|
||||
|
||||
type Wall = {
|
||||
@@ -7,18 +7,17 @@ type Wall = {
|
||||
};
|
||||
|
||||
function clearWall(wall: Wall) {
|
||||
let volume: BlockVolume = new BlockVolume(wall.startPos, wall.endPos);
|
||||
const volume: BlockVolume = new BlockVolume(wall.startPos, wall.endPos);
|
||||
world.getDimension("overworld").fillBlocks(volume, MinecraftBlockTypes.Air);
|
||||
}
|
||||
|
||||
function fillWall(wall: Wall, block: string) {
|
||||
let volume: BlockVolume = new BlockVolume(wall.startPos, wall.endPos);
|
||||
const volume: BlockVolume = new BlockVolume(wall.startPos, wall.endPos);
|
||||
world.getDimension("overworld").fillBlocks(volume, block);
|
||||
}
|
||||
|
||||
function startLevel(commandBlockPos: Vector3) {
|
||||
let volume: BlockVolume = new BlockVolume(commandBlockPos, commandBlockPos);
|
||||
const volume: BlockVolume = new BlockVolume(commandBlockPos, commandBlockPos);
|
||||
world.getDimension("overworld").fillBlocks(volume, MinecraftBlockTypes.RedstoneBlock);
|
||||
}
|
||||
BlockTypes;
|
||||
export { Wall, clearWall, fillWall, startLevel };
|
||||
|
||||
@@ -172,13 +172,13 @@ class ParticleColumn {
|
||||
|
||||
generatePoints() {
|
||||
for (let layer = 0; layer < this.layerCount; layer++) {
|
||||
let layerRadius = this.radius - layer;
|
||||
const layerRadius = this.radius - layer;
|
||||
for (let point = 0; point < this.pointsPerLayer; point++) {
|
||||
let angle = (point / this.pointsPerLayer) * (Math.PI * 2);
|
||||
const angle = (point / this.pointsPerLayer) * (Math.PI * 2);
|
||||
this.anglePerLayer.push(angle);
|
||||
let x = Math.cos(angle) * layerRadius;
|
||||
let z = Math.sin(angle) * layerRadius;
|
||||
let y = layer;
|
||||
const x = Math.cos(angle) * layerRadius;
|
||||
const z = Math.sin(angle) * layerRadius;
|
||||
const y = layer;
|
||||
this.points.push(Vector3Add(this.pos, vector3(x, y, z)));
|
||||
}
|
||||
}
|
||||
@@ -186,20 +186,17 @@ class ParticleColumn {
|
||||
|
||||
update() {
|
||||
//update each point by increasing the angle by the speed
|
||||
let layerCount = 0;
|
||||
let pointCount = 0;
|
||||
this.tickCounter++;
|
||||
if (this.tickCounter % 2 == 0) {
|
||||
this.points.forEach((point, index) => {
|
||||
let layer = Math.floor(index / this.pointsPerLayer);
|
||||
const layer = Math.floor(index / this.pointsPerLayer);
|
||||
let angle = this.anglePerLayer[index];
|
||||
angle += this.speed * (layer / 5);
|
||||
this.anglePerLayer[index] = angle;
|
||||
let layerRadius = this.radius - Math.floor(index / this.pointsPerLayer);
|
||||
let calcAngle = angle;
|
||||
let x = Math.cos(calcAngle) * this.radius;
|
||||
let z = Math.sin(calcAngle) * this.radius;
|
||||
let y = Math.floor(index / this.pointsPerLayer) + (this.tickCounter % 2);
|
||||
const calcAngle = angle;
|
||||
const x = Math.cos(calcAngle) * this.radius;
|
||||
const z = Math.sin(calcAngle) * this.radius;
|
||||
const y = Math.floor(index / this.pointsPerLayer) + (this.tickCounter % 2);
|
||||
this.points[index] = Vector3Add(this.pos, vector3(x, y, z));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { system } from "@minecraft/server";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
||||
function delayedRun(callback: Function, delay: number) {
|
||||
let timer = system.runTimeout(() => {
|
||||
const timer = system.runTimeout(() => {
|
||||
callback();
|
||||
system.clearRun(timer);
|
||||
}, delay);
|
||||
}
|
||||
|
||||
function delay(t: number) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return new Promise((r: any) => {
|
||||
system.runTimeout(r, t);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user