Start working at 1.2.0
/ build (push) Waiting to run

This commit is contained in:
2026-08-26 09:54:39 +08:00
Unverified
parent 36f2dd0685
commit 136d5ffa3b
159 changed files with 60793 additions and 617 deletions
+4 -2
View File
@@ -1,8 +1,9 @@
import { Command } from '../classes/Commands/Command';
import { CommandPermissionLevel, CustomCommandParamType, CustomCommandStatus, system } from '@minecraft/server';
import { structureCollection } from '../classes/Structure/StructureCollection';
import { instanceCollection } from '../classes/Instance/InstanceCollection';
import { InstanceExistsError } from '../classes/Errors/InstanceExistsError';
import { StructureNotFoundError } from '../classes/Errors/StructureNotFoundError';
import { getDefaultRenderMode } from '../options/defaultRenderMode';
export class CreateCommand extends Command {
constructor() {
@@ -34,7 +35,8 @@ export class CreateCommand extends Command {
}
addStructure(origin, instanceName, structureId) {
structureCollection.add(instanceName, structureId);
const playerId = origin.getType() === 'Player' ? origin.getSource().id : void 0;
instanceCollection.add(instanceName, structureId, { renderMode: getDefaultRenderMode(playerId) });
origin.sendMessage({ translate: 'construct.commands.create.success', with: [instanceName, structureId] });
}
+3 -3
View File
@@ -1,6 +1,6 @@
import { Command } from '../classes/Commands/Command';
import { CustomCommandParamType, CustomCommandStatus, CommandPermissionLevel, system } from '@minecraft/server';
import { structureCollection } from '../classes/Structure/StructureCollection';
import { instanceCollection } from '../classes/Instance/InstanceCollection';
export class DeleteCommand extends Command {
constructor() {
@@ -16,9 +16,9 @@ export class DeleteCommand extends Command {
}
run(origin, instanceName) {
const instance = structureCollection.get(instanceName);
const instance = instanceCollection.get(instanceName);
system.run(() => {
structureCollection.delete(instanceName);
instanceCollection.delete(instanceName);
origin.sendMessage({ translate: 'construct.commands.delete.success', with: [instanceName] });
});
return { status: CustomCommandStatus.Success };
+2 -2
View File
@@ -1,6 +1,6 @@
import { Command } from '../classes/Commands/Command';
import { CustomCommandParamType, CustomCommandStatus, CommandPermissionLevel, system } from '@minecraft/server';
import { structureCollection } from '../classes/Structure/StructureCollection';
import { instanceCollection } from '../classes/Instance/InstanceCollection';
export class EnableCommand extends Command {
constructor() {
@@ -17,7 +17,7 @@ export class EnableCommand extends Command {
}
run(origin, instanceName, state) {
const instance = structureCollection.get(instanceName);
const instance = instanceCollection.get(instanceName);
if (state && !instance.hasLocation()) {
origin.sendMessage({ translate: 'construct.commands.error.noLocation', with: [instanceName] });
return void 0;
@@ -1,6 +1,6 @@
import { CommandPermissionLevel, CustomCommandParamType, CustomCommandStatus, system } from '@minecraft/server';
import { Command } from '../classes/Commands/Command';
import { structureCollection } from '../classes/Structure/StructureCollection';
import { instanceCollection } from '../classes/Instance/InstanceCollection';
import { Vector } from '../lib/Vector';
export class InstanceInfoCommand extends Command {
@@ -17,7 +17,7 @@ export class InstanceInfoCommand extends Command {
}
run(origin, instanceName) {
const instance = structureCollection.get(instanceName);
const instance = instanceCollection.get(instanceName);
const message = { rawtext: [
this.getHeaderText(instance),
{ text: '\n' },
@@ -29,6 +29,8 @@ export class InstanceInfoCommand extends Command {
{ text: '\n' },
this.getLayerText(instance),
{ text: '\n' },
this.getRenderModeText(instance),
{ text: '\n' },
this.getVerifierText(instance),
{ text: '\n' },
this.getSizeText(instance)
@@ -49,7 +51,7 @@ export class InstanceInfoCommand extends Command {
if (!instance.hasLocation())
return { translate: 'construct.commands.instanceinfo.noLocation' };
const { dimensionId, location } = instance.getLocation();
return { translate: 'construct.commands.instanceinfo.location', with: [location.toString(), dimensionId.replace('minecraft:', '')] };
return { translate: 'construct.commands.instanceinfo.location', with: [Vector.from(location).toString(), dimensionId.replace('minecraft:', '')] };
}
getEnabledText(instance) {
@@ -60,6 +62,10 @@ export class InstanceInfoCommand extends Command {
return { translate: 'construct.commands.instanceinfo.layer', with: [String(instance.getLayer()), String(instance.getMaxLayer())] };
}
getRenderModeText(instance) {
return { translate: 'construct.commands.instanceinfo.renderMode', with: [String(instance.getRenderMode())] };
}
getVerifierText(instance) {
const verifier = instance.options.verifier;
return { translate: 'construct.commands.instanceinfo.verifier', with: [String(verifier.isEnabled)] };
@@ -67,7 +73,7 @@ export class InstanceInfoCommand extends Command {
getSizeText(instance) {
const bounds = instance.getBounds();
return { translate: 'construct.commands.instanceinfo.size', with: [bounds.max.toString(), Vector.volume(bounds.min, bounds.max).toString()] };
return { translate: 'construct.commands.instanceinfo.size', with: [Vector.from(bounds.max).toString(), Vector.volume(bounds.min, bounds.max).toString()] };
}
}
@@ -1,6 +1,6 @@
import { CommandPermissionLevel, CustomCommandStatus, system } from '@minecraft/server';
import { Command } from '../classes/Commands/Command';
import { structureCollection } from '../classes/Structure/StructureCollection';
import { instanceCollection } from '../classes/Instance/InstanceCollection';
export class InstancesCommand extends Command {
constructor() {
@@ -13,7 +13,7 @@ export class InstancesCommand extends Command {
}
run(origin) {
const names = structureCollection.getInstanceNames();
const names = instanceCollection.getInstanceNames();
if (names.length === 0)
return { status: CustomCommandStatus.Success, message: 'construct.commands.instances.empty' };
const rawtext = [
@@ -21,7 +21,7 @@ export class InstancesCommand extends Command {
{ text: '\n' }
];
for (const name of names) {
const instance = structureCollection.get(name);
const instance = instanceCollection.get(name);
const status = this.formatStatus(instance);
rawtext.push({
translate: 'construct.commands.instances.row',
+2 -2
View File
@@ -1,6 +1,6 @@
import { Command } from '../classes/Commands/Command';
import { CommandPermissionLevel, CustomCommandParamType, CustomCommandStatus, system } from '@minecraft/server';
import { structureCollection } from '../classes/Structure/StructureCollection';
import { instanceCollection } from '../classes/Instance/InstanceCollection';
export class LayerCommand extends Command {
constructor() {
@@ -17,7 +17,7 @@ export class LayerCommand extends Command {
}
run(origin, instanceName, layer) {
const instance = structureCollection.get(instanceName);
const instance = instanceCollection.get(instanceName);
const max = instance.getMaxLayer();
if (layer < 0 || layer > max) {
origin.sendMessage({ translate: 'construct.commands.layer.outOfBounds', with: [String(layer), instanceName, String(max)] });
@@ -1,6 +1,6 @@
import { CommandPermissionLevel, CustomCommandParamType, CustomCommandStatus, EntityComponentTypes, system } from '@minecraft/server';
import { Command } from '../classes/Commands/Command';
import { structureCollection } from '../classes/Structure/StructureCollection';
import { instanceCollection } from '../classes/Instance/InstanceCollection';
import { PlayerCommandOrigin } from '../classes/Commands/PlayerCommandOrigin';
import { NotAPlayerError } from '../classes/Errors/NotAPlayerError';
@@ -21,7 +21,7 @@ export class MaterialsCommand extends Command {
}
run(origin, instanceName, missing) {
const instance = structureCollection.get(instanceName);
const instance = instanceCollection.get(instanceName);
const onlyMissing = missing === true;
if (onlyMissing)
this.assertIsPlayer(origin);
+3 -3
View File
@@ -1,7 +1,7 @@
import { Command } from '../classes/Commands/Command';
import { CommandPermissionLevel, CustomCommandParamType, CustomCommandStatus, system, world } from '@minecraft/server';
import { Vector } from '../lib/Vector';
import { structureCollection } from '../classes/Structure/StructureCollection';
import { instanceCollection } from '../classes/Instance/InstanceCollection';
import { PlayerCommandOrigin } from '../classes/Commands/PlayerCommandOrigin';
export class MoveCommand extends Command {
@@ -13,7 +13,7 @@ export class MoveCommand extends Command {
{ name: 'instanceName', type: CustomCommandParamType.String }
],
optionalParameters: [
{ name: 'dimensionId', type: CustomCommandParamType.Enum }, // Enum defined in PlaceCommand.js
{ name: 'dimensionId', type: CustomCommandParamType.Enum }, // Enum defined in PlaceCommand
{ name: 'location', type: CustomCommandParamType.Location }
],
permissionLevel: CommandPermissionLevel.Any,
@@ -22,7 +22,7 @@ export class MoveCommand extends Command {
}
run(origin, instanceName, dimensionId, location) {
const instance = structureCollection.get(instanceName);
const instance = instanceCollection.get(instanceName);
if (dimensionId === void 0 || location === void 0) {
if (!(origin instanceof PlayerCommandOrigin))
return { status: CustomCommandStatus.Failure, message: 'construct.commands.move.locationRequired' };
@@ -1,6 +1,6 @@
import { CommandPermissionLevel, CustomCommandParamType, CustomCommandStatus, system } from '@minecraft/server';
import { Command } from '../classes/Commands/Command';
import { structureCollection } from '../classes/Structure/StructureCollection';
import { instanceCollection } from '../classes/Instance/InstanceCollection';
export class NextLayerCommand extends Command {
constructor() {
@@ -16,7 +16,7 @@ export class NextLayerCommand extends Command {
}
run(origin, instanceName) {
const instance = structureCollection.get(instanceName);
const instance = instanceCollection.get(instanceName);
instance.increaseLayer();
origin.sendMessage({ translate: 'construct.commands.nextlayer.success', with: [instanceName, String(instance.getLayer())] });
return { status: CustomCommandStatus.Success };
+2 -2
View File
@@ -1,6 +1,6 @@
import { Command } from '../classes/Commands/Command';
import { CommandPermissionLevel, CustomCommandParamType, CustomCommandStatus, DimensionTypes, system, world } from '@minecraft/server';
import { structureCollection } from '../classes/Structure/StructureCollection';
import { instanceCollection } from '../classes/Instance/InstanceCollection';
import { InstanceExistsError } from '../classes/Errors/InstanceExistsError';
import { Vector } from '../lib/Vector';
@@ -21,7 +21,7 @@ export class PlaceCommand extends Command {
}
run(origin, instanceName, dimensionId, location) {
const instance = structureCollection.get(instanceName);
const instance = instanceCollection.get(instanceName);
const flooredLocation = Vector.from(location).floor();
this.assertDimensionExists(dimensionId);
system.run(() => {
@@ -1,6 +1,6 @@
import { CommandPermissionLevel, CustomCommandParamType, CustomCommandStatus, system } from '@minecraft/server';
import { Command } from '../classes/Commands/Command';
import { structureCollection } from '../classes/Structure/StructureCollection';
import { instanceCollection } from '../classes/Instance/InstanceCollection';
export class PrevLayerCommand extends Command {
constructor() {
@@ -16,7 +16,7 @@ export class PrevLayerCommand extends Command {
}
run(origin, instanceName) {
const instance = structureCollection.get(instanceName);
const instance = instanceCollection.get(instanceName);
instance.decreaseLayer();
origin.sendMessage({ translate: 'construct.commands.prevlayer.success', with: [instanceName, String(instance.getLayer())] });
return { status: CustomCommandStatus.Success };
+4 -4
View File
@@ -1,6 +1,6 @@
import { Command } from '../classes/Commands/Command';
import { CommandPermissionLevel, CustomCommandParamType, CustomCommandStatus, system } from '@minecraft/server';
import { structureCollection } from '../classes/Structure/StructureCollection';
import { instanceCollection } from '../classes/Instance/InstanceCollection';
export class RenameCommand extends Command {
constructor() {
@@ -17,12 +17,12 @@ export class RenameCommand extends Command {
}
run(origin, instanceName, newName) {
const instance = structureCollection.get(instanceName);
if (structureCollection.has(newName)) {
const instance = instanceCollection.get(instanceName);
if (instanceCollection.has(newName)) {
origin.sendMessage({ translate: 'construct.error.instanceExists', with: [newName] });
return void 0;
}
structureCollection.rename(instanceName, newName);
instanceCollection.rename(instanceName, newName);
origin.sendMessage({ translate: 'construct.commands.rename.success', with: [instanceName, newName] });
return { status: CustomCommandStatus.Success };
}
+5 -6
View File
@@ -1,9 +1,9 @@
import { Command } from '../classes/Commands/Command';
import { CommandPermissionLevel, CustomCommandParamType, CustomCommandStatus, system, TicksPerSecond } from '@minecraft/server';
import { InstanceFormBuilder } from '../classes/Instance/InstanceFormBuilder';
import { structureCollection } from '../classes/Structure/StructureCollection';
import { instanceCollection } from '../classes/Instance/InstanceCollection';
import { StructureVerifier } from '../classes/Verifier/StructureVerifier';
import { StructureStatistics } from '../classes/Structure/StructureStatistics';
import { InstanceStatistics } from '../classes/Instance/InstanceStatistics';
export class StatsCommand extends Command {
constructor() {
@@ -19,7 +19,7 @@ export class StatsCommand extends Command {
}
run(origin, instanceName) {
const instance = structureCollection.get(instanceName);
const instance = instanceCollection.get(instanceName);
if (this.structureVerifier)
return { status: CustomCommandStatus.Failure, error: 'construct.commands.stats.alreadyRunning' };
system.run(async () => {
@@ -29,10 +29,9 @@ export class StatsCommand extends Command {
}
async getStatsMessage(instance) {
const verifierOptions = { isEnabled: true, particleLifetime: 1*TicksPerSecond, isStandalone: true };
this.structureVerifier = new StructureVerifier(instance, verifierOptions);
this.structureVerifier = StructureVerifier.standalone(instance, { particleLifetime: 1*TicksPerSecond });
const verification = await this.structureVerifier.verifyStructure(true);
const statistics = new StructureStatistics(instance, verification);
const statistics = new InstanceStatistics(instance, verification);
const statsMessage = statistics.getMessage();
this.structureVerifier = void 0;
return statsMessage;
+2 -2
View File
@@ -2,7 +2,7 @@ import { Command } from '../classes/Commands/Command';
import { CommandPermissionLevel, CustomCommandParamType, CustomCommandStatus, EntityComponentTypes, EquipmentSlot, system } from '@minecraft/server';
import { PlayerCommandOrigin } from '../classes/Commands/PlayerCommandOrigin';
import { MENU_ITEM } from '../consts';
import { structureCollection } from '../classes/Structure/StructureCollection';
import { instanceCollection } from '../classes/Instance/InstanceCollection';
export class TagCommand extends Command {
constructor() {
@@ -19,7 +19,7 @@ export class TagCommand extends Command {
}
run(origin, instanceName) {
const instance = structureCollection.get(instanceName);
const instance = instanceCollection.get(instanceName);
const player = origin.getSource();
const equipment = player.getComponent(EntityComponentTypes.Equippable);
const itemStack = equipment?.getEquipment(EquipmentSlot.Mainhand);
+2 -2
View File
@@ -1,6 +1,6 @@
import { CommandPermissionLevel, CustomCommandParamType, CustomCommandStatus, system } from '@minecraft/server';
import { Command } from '../classes/Commands/Command';
import { structureCollection } from '../classes/Structure/StructureCollection';
import { instanceCollection } from '../classes/Instance/InstanceCollection';
export class VerifierCommand extends Command {
constructor() {
@@ -17,7 +17,7 @@ export class VerifierCommand extends Command {
}
run(origin, instanceName, state) {
const instance = structureCollection.get(instanceName);
const instance = instanceCollection.get(instanceName);
if (state)
instance.setVerifierEnabled(true);
else