NPCs included, finishing touches zijn nog nodig
This commit is contained in:
@@ -39,8 +39,8 @@ function rotate(pos: Vector3, angle: number) {
|
||||
|
||||
const particleData = new MolangVariableMap();
|
||||
particleData.setColorRGB("variable.color", {
|
||||
red: 1,
|
||||
green: 1,
|
||||
red: 0,
|
||||
green: 0.5,
|
||||
blue: 1,
|
||||
});
|
||||
|
||||
|
||||
15
scripts/Commandeer/utils/entityUtils.ts
Normal file
15
scripts/Commandeer/utils/entityUtils.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { system, world } from "@minecraft/server";
|
||||
|
||||
function runEntityEventOnTag(tag: string, event: string) {
|
||||
system.run(() => {
|
||||
world.getDimension("overworld").runCommand(`/event entity @e[tag=${tag}] ${event}`);
|
||||
});
|
||||
}
|
||||
|
||||
function setNPCDialog(npcTag: string, dialogId: string) {
|
||||
system.run(() => {
|
||||
world.getDimension("overworld").runCommand(`/dialogue change @e[tag=${npcTag}] ${dialogId} @a`);
|
||||
});
|
||||
}
|
||||
|
||||
export { runEntityEventOnTag, setNPCDialog };
|
||||
@@ -1,5 +1,6 @@
|
||||
import { BlockType, BlockTypes, BlockVolume, Vector3, world } from "@minecraft/server";
|
||||
import { MinecraftBlockTypes } from "../../vanilla-data/mojang-block";
|
||||
import { vector3 } from "./vectorUtils";
|
||||
|
||||
type Wall = {
|
||||
startPos: Vector3;
|
||||
@@ -20,5 +21,19 @@ function startLevel(commandBlockPos: Vector3) {
|
||||
let volume: BlockVolume = new BlockVolume(commandBlockPos, commandBlockPos);
|
||||
world.getDimension("overworld").fillBlocks(volume, MinecraftBlockTypes.RedstoneBlock);
|
||||
}
|
||||
|
||||
function teleportAndFaceAgent(position: Vector3, facing: Vector3 = vector3(0, 0, 0)): void {
|
||||
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}`
|
||||
);
|
||||
}
|
||||
|
||||
function placeBlock(position: Vector3, blockType: MinecraftBlockTypes) {
|
||||
const block = world.getDimension("overworld").getBlock(position);
|
||||
block!.setType(blockType);
|
||||
}
|
||||
|
||||
BlockTypes;
|
||||
export { Wall, clearWall, fillWall, startLevel };
|
||||
export { Wall, clearWall, fillWall, startLevel, teleportAndFaceAgent, placeBlock };
|
||||
|
||||
59
scripts/Commandeer/utils/smallArrow.ts
Normal file
59
scripts/Commandeer/utils/smallArrow.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { MolangVariableMap, Vector3, world } from "@minecraft/server";
|
||||
import { Vector3Add, vector3 } from "./vectorUtils";
|
||||
import { PARTICLES, spawnParticle } from "./particleUtils";
|
||||
|
||||
let arrowTemplate: Vector3[] = [
|
||||
vector3(0, 0, 0),
|
||||
|
||||
vector3(0.5, 0.5, 0),
|
||||
vector3(-0.5, 0.5, 0),
|
||||
|
||||
vector3(0.75, 1, 0),
|
||||
vector3(-0.75, 1, 0),
|
||||
|
||||
vector3(0, 0.5, 0),
|
||||
vector3(0, 1, 0),
|
||||
vector3(0, 1.5, 0),
|
||||
vector3(0, 2, 0),
|
||||
vector3(0, 2.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;
|
||||
|
||||
let newX = x * Math.cos(angle) - z * Math.sin(angle);
|
||||
let newZ = x * Math.sin(angle) + z * Math.cos(angle);
|
||||
|
||||
return vector3(newX, pos.y, newZ);
|
||||
}
|
||||
|
||||
const particleData = new MolangVariableMap();
|
||||
particleData.setColorRGB("variable.color", {
|
||||
red: 0,
|
||||
green: 0.5,
|
||||
blue: 1,
|
||||
});
|
||||
|
||||
function drawSmallArrow(offsetPos: Vector3) {
|
||||
tickCounter++;
|
||||
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);
|
||||
finalPos.y += Math.sin(heightBobbing) / 2;
|
||||
spawnParticle(finalPos, PARTICLES.point, particleData);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export { drawSmallArrow };
|
||||
Reference in New Issue
Block a user