Add alot
This commit is contained in:
@@ -139,11 +139,19 @@ export class Maker {
|
||||
} else {
|
||||
map.setColorRGB("variable.color", { red: 0, green: 255, blue: 0 });
|
||||
const particleData: MolangVariableMap = new MolangVariableMap();
|
||||
particleData.setColorRGB("variable.color", {
|
||||
red: 1,
|
||||
green: 1,
|
||||
blue: 1,
|
||||
});
|
||||
if (color == PaletteColor.Red) {
|
||||
particleData.setColorRGB("variable.color", {
|
||||
red: 1,
|
||||
green: 0,
|
||||
blue: 0,
|
||||
});
|
||||
} else if (color == PaletteColor.White) {
|
||||
particleData.setColorRGB("variable.color", {
|
||||
red: 1,
|
||||
green: 1,
|
||||
blue: 1,
|
||||
});
|
||||
}
|
||||
spawnParticle(vector3(x, y + 0.1, z), "codecosmos:point", particleData);
|
||||
}
|
||||
}
|
||||
@@ -162,16 +170,16 @@ export class Maker {
|
||||
(trigger.point1.y + trigger.point2.y) / 2,
|
||||
(trigger.point1.z + trigger.point2.z) / 2
|
||||
);
|
||||
const distnaces = players.map((player) => {
|
||||
const distances = players.map((player) => {
|
||||
return {
|
||||
player: player,
|
||||
distance: vector3Distance(player.location, triggerCenter),
|
||||
};
|
||||
});
|
||||
|
||||
distnaces.sort((a, b) => a.distance - b.distance);
|
||||
const closestPlayer = distnaces[0].player;
|
||||
const distance = distnaces[0].distance;
|
||||
distances.sort((a, b) => a.distance - b.distance);
|
||||
const closestPlayer = distances[0].player;
|
||||
const distance = distances[0].distance;
|
||||
|
||||
if (distance > 25) return;
|
||||
|
||||
|
||||
@@ -69,14 +69,14 @@ export class Trigger {
|
||||
}
|
||||
|
||||
Update() {
|
||||
world
|
||||
.getDimension("overworld")
|
||||
.getEntities({ type: "minecraft:player" })
|
||||
.forEach((player) => {
|
||||
//Check if the distance between the player and the trigger is less than the width of the trigger
|
||||
// if (this.hasPlayerEnterdTrigger(player.location)) {
|
||||
// world.sendMessage(`Player ${player.nameTag} is in trigger`);
|
||||
// }
|
||||
});
|
||||
// world
|
||||
// .getDimension("overworld")
|
||||
// .getEntities({ type: "minecraft:player" })
|
||||
// .forEach((player) => {
|
||||
// //Check if the distance between the player and the trigger is less than the width of the trigger
|
||||
// // if (this.hasPlayerEnterdTrigger(player.location)) {
|
||||
// // world.sendMessage(`Player ${player.nameTag} is in trigger`);
|
||||
// // }
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
66
scripts/Commandeer/animations/animation.ts
Normal file
66
scripts/Commandeer/animations/animation.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { Vector3, world } from "@minecraft/server";
|
||||
import { Vector3ToCommandString } from "../utils/vectorUtils";
|
||||
import { delay } from "../utils/waitUtil";
|
||||
|
||||
let animationPlaying = false;
|
||||
|
||||
function setAmimationPlaying(value: boolean) {
|
||||
animationPlaying = value;
|
||||
}
|
||||
function getAnimationPlaying() {
|
||||
return animationPlaying;
|
||||
}
|
||||
|
||||
class ClonePos {
|
||||
point1: Vector3;
|
||||
point2: Vector3;
|
||||
|
||||
constructor(point1: Vector3, point2: Vector3) {
|
||||
this.point1 = point1;
|
||||
this.point2 = point2;
|
||||
}
|
||||
}
|
||||
|
||||
async function SetFrame(frame: ClonePos, destination: Vector3) {
|
||||
await world
|
||||
.getDimension("overworld")
|
||||
.runCommandAsync(
|
||||
`/clone ${Vector3ToCommandString(frame.point1)} ${Vector3ToCommandString(frame.point2)} ${Vector3ToCommandString(
|
||||
destination
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
async function playAnimation(
|
||||
frames: ClonePos[],
|
||||
delayTime: number,
|
||||
reverse: boolean,
|
||||
destination: Vector3,
|
||||
force: boolean = false
|
||||
) {
|
||||
if (animationPlaying && !force) {
|
||||
world.sendMessage("Animation already playing");
|
||||
return;
|
||||
}
|
||||
let frameCount = frames.length;
|
||||
if (!force) {
|
||||
animationPlaying = true;
|
||||
}
|
||||
|
||||
for (let i = 0; i < frameCount; i++) {
|
||||
let frame = reverse ? frames[frameCount - i - 1] : frames[i];
|
||||
await world
|
||||
.getDimension("overworld")
|
||||
.runCommandAsync(
|
||||
`/clone ${Vector3ToCommandString(frame.point1)} ${Vector3ToCommandString(
|
||||
frame.point2
|
||||
)} ${Vector3ToCommandString(destination)}`
|
||||
);
|
||||
await delay(delayTime);
|
||||
}
|
||||
if (!force) {
|
||||
animationPlaying = false;
|
||||
}
|
||||
}
|
||||
|
||||
export { SetFrame, ClonePos, playAnimation, animationPlaying, setAmimationPlaying, getAnimationPlaying };
|
||||
74
scripts/Commandeer/level/abstractTrackFollowMission.ts
Normal file
74
scripts/Commandeer/level/abstractTrackFollowMission.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import { Vector3, world } from "@minecraft/server";
|
||||
import Level from "./level";
|
||||
import pupeteer from "../pupeteer";
|
||||
import { teleportAgent, isAgentAt, getAgentLocation, getAgent } from "../utils/agentUtils";
|
||||
import { startLevel } from "../utils/levelUtils";
|
||||
import { vector3, Vector3Add, Vector3ToCommandString } from "../utils/vectorUtils";
|
||||
import { mindKeeper, CURRENT_LEVEL } from "../../main";
|
||||
import { MinecraftBlockTypes } from "../../vanilla-data/mojang-block";
|
||||
|
||||
class AbstractAgentTrackMission extends Level {
|
||||
levelid: string;
|
||||
constructor(
|
||||
levelid: string,
|
||||
agentStartPositon: Vector3,
|
||||
agentEndPosition: Vector3,
|
||||
startLevelCommandBlockPos: Vector3
|
||||
) {
|
||||
super(
|
||||
() => {
|
||||
pupeteer.sendWorldMessage(`%message.${levelid}.started`);
|
||||
pupeteer.setTitleTimed(`%message.${levelid}.name`, 2.5);
|
||||
startLevel(startLevelCommandBlockPos);
|
||||
teleportAgent(agentStartPositon);
|
||||
},
|
||||
() => {
|
||||
pupeteer.setActionBar(`%message.${levelid}.make`);
|
||||
},
|
||||
() => {
|
||||
pupeteer.clearActionBar();
|
||||
pupeteer.sendWorldMessage(`%message.${levelid}.complete`);
|
||||
pupeteer.setTitleTimed(`%message.${levelid}.complete`, 2.5);
|
||||
|
||||
mindKeeper.increment(CURRENT_LEVEL);
|
||||
},
|
||||
() => {
|
||||
let isComplete = false;
|
||||
let isOutOfBounds = false;
|
||||
|
||||
let agentPos = getAgentLocation();
|
||||
let blockLava = world.getDimension("overworld").getBlock(Vector3Add(agentPos, vector3(0, -7, 0)));
|
||||
let blockAir = world.getDimension("overworld").getBlock(Vector3Add(agentPos, vector3(0, -1, 0)));
|
||||
|
||||
if (
|
||||
blockLava &&
|
||||
blockLava.type.id === MinecraftBlockTypes.Lava &&
|
||||
blockAir &&
|
||||
blockAir.type.id === MinecraftBlockTypes.Air
|
||||
) {
|
||||
isOutOfBounds = true;
|
||||
}
|
||||
|
||||
if (isAgentAt(agentEndPosition)) {
|
||||
isComplete = true;
|
||||
}
|
||||
|
||||
if (isOutOfBounds) {
|
||||
pupeteer.sendWorldMessage(`%message.outofbounds`);
|
||||
pupeteer.setTitleTimed(`%message.outofbounds`, 2.5);
|
||||
// world.getDimension("overworld").runCommand("/kill @e[type=agent]");
|
||||
world.getDimension("overworld").runCommand("execute as @p run codebuilder runtime stop @s");
|
||||
|
||||
teleportAgent(agentStartPositon);
|
||||
return false;
|
||||
} else if (isComplete) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
this.levelid = levelid;
|
||||
}
|
||||
}
|
||||
|
||||
export default AbstractAgentTrackMission;
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BlockType, Vector3, World } from "@minecraft/server";
|
||||
import { BlockType, Vector3, world, World } from "@minecraft/server";
|
||||
|
||||
export type blockCondition = {
|
||||
block: string;
|
||||
@@ -42,3 +42,14 @@ export type AgentNoGoZone = {
|
||||
export type LevelNoGoZone = {
|
||||
zones: AgentNoGoZone[];
|
||||
};
|
||||
|
||||
export const checkBlockCondition = (condition: LevelBlockCondition): boolean => {
|
||||
let isComplete: boolean = true;
|
||||
condition.conditions.forEach((condition) => {
|
||||
let block = world.getDimension("overworld").getBlock(condition.position);
|
||||
if (block!.typeId != condition.block) {
|
||||
isComplete = false;
|
||||
}
|
||||
});
|
||||
return isComplete;
|
||||
};
|
||||
|
||||
@@ -29,7 +29,6 @@ enum StoreType {
|
||||
*/
|
||||
class Mindkeeper {
|
||||
registerdStores: Array<Store> = [];
|
||||
// propertyManager = new DynamicPropertiesDefinition();
|
||||
world: World;
|
||||
initialised: boolean = false;
|
||||
debugLog: string[] = [];
|
||||
@@ -75,7 +74,6 @@ class Mindkeeper {
|
||||
registerToWorld() {
|
||||
for (let i = 0; i < this.registerdStores.length; i++) {
|
||||
let isAlreadyDefined = true;
|
||||
|
||||
try {
|
||||
let test = this.world.getDynamicProperty(this.registerdStores[i].getName());
|
||||
if (test === undefined) {
|
||||
@@ -218,9 +216,8 @@ class Mindkeeper {
|
||||
if (command === "!deleteStoresConfirm") {
|
||||
this.getStores().forEach((store) => {
|
||||
this.world.sendMessage(`Deleting ${store.getName()}`);
|
||||
this.world.sendMessage("This feature no longer works, thanks minecraft ");
|
||||
// this.world.dynami(store.getName());
|
||||
});
|
||||
this.world.clearDynamicProperties();
|
||||
this.secondWarning = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
import { Entity, Vector3, world } from "@minecraft/server";
|
||||
import { Vector3ToString, vector3 } from "./vectorUtils";
|
||||
import { mindKeeper } from "../../main";
|
||||
function teleportAgent(position: Vector3) {
|
||||
world
|
||||
.getDimension("overworld")
|
||||
.runCommand(`/execute as @a run tp @e[type=agent] ${position.x} ${position.y} ${position.z}`);
|
||||
|
||||
//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 {
|
||||
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 isAgentAt(position: Vector3): boolean {
|
||||
|
||||
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 };
|
||||
@@ -11,7 +11,7 @@ function clearWall(wall: Wall) {
|
||||
world.getDimension("overworld").fillBlocks(volume, MinecraftBlockTypes.Air);
|
||||
}
|
||||
|
||||
function fillWall(wall: Wall, block: BlockType) {
|
||||
function fillWall(wall: Wall, block: string) {
|
||||
let volume: BlockVolume = new BlockVolume(wall.startPos, wall.endPos);
|
||||
world.getDimension("overworld").fillBlocks(volume, block);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,31 @@
|
||||
import { Vector3 } from "@minecraft/server";
|
||||
|
||||
enum Direction {
|
||||
North = 0,
|
||||
East = 1,
|
||||
South = 2,
|
||||
West = 3,
|
||||
Up = 4,
|
||||
Down = 5,
|
||||
}
|
||||
|
||||
function directionToVector3(direction: Direction): Vector3 {
|
||||
switch (direction) {
|
||||
case Direction.North:
|
||||
return vector3(0, 0, -1);
|
||||
case Direction.East:
|
||||
return vector3(1, 0, 0);
|
||||
case Direction.South:
|
||||
return vector3(0, 0, 1);
|
||||
case Direction.West:
|
||||
return vector3(-1, 0, 0);
|
||||
case Direction.Up:
|
||||
return vector3(0, 1, 0);
|
||||
case Direction.Down:
|
||||
return vector3(0, -1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function vector3(x: number, y: number, z: number): Vector3 {
|
||||
return { x: x, y: y, z: z };
|
||||
}
|
||||
@@ -55,6 +81,8 @@ function vector3Distance(vector1: Vector3, vector2: Vector3): number {
|
||||
}
|
||||
|
||||
export {
|
||||
Direction,
|
||||
directionToVector3,
|
||||
Vector3ToString,
|
||||
Vector3ToFancyString,
|
||||
Vector3Add,
|
||||
|
||||
Reference in New Issue
Block a user