feat(cli): add construct:nextlayer command

This commit is contained in:
ForestOfLight
2026-05-20 02:50:05 -07:00
Unverified
parent 469906db91
commit 6520082d16
4 changed files with 45 additions and 0 deletions
@@ -0,0 +1,36 @@
import { CustomCommandParamType, CustomCommandStatus, system } from '@minecraft/server';
import { Command } from '../classes/Commands/Command';
import { findInstance } from '../classes/Commands/lib/findInstance';
import { commandError } from '../classes/Commands/lib/commandError';
export class NextLayerCommand extends Command {
constructor() {
super({
name: 'nextlayer',
description: 'construct.commands.nextlayer',
mandatoryParameters: [
{ name: 'instanceName', type: CustomCommandParamType.String }
],
callback: (source, instanceName) => this.run(source, instanceName)
});
}
run(source, instanceName) {
try {
const instance = findInstance(source, instanceName);
if (!instance) return { status: CustomCommandStatus.Failure };
system.run(() => {
instance.increaseLayer();
source.sendMessage({
rawtext: [{ translate: 'construct.commands.nextlayer.success',
with: [instanceName, String(instance.getLayer())] }]
});
});
return { status: CustomCommandStatus.Success };
} catch (err) {
return commandError(source, err);
}
}
}
export const nextLayerCommand = new NextLayerCommand();
+1
View File
@@ -19,6 +19,7 @@ import './commands/PlaceCommand';
import './commands/MoveCommand';
import './commands/ActiveCommand';
import './commands/LayerCommand';
import './commands/NextLayerCommand';
// Other
import './classes/BlockInfo';
+4
View File
@@ -150,3 +150,7 @@ construct.commands.error.noLocation=§cInstance "%1" has no saved location.
construct.commands.layer=Set the active layer of an instance (0 = whole structure).
construct.commands.layer.success=§aSet instance "%1" layer to %2.
construct.commands.layer.outOfBounds=§cLayer %1 is out of bounds for instance "%2" (max %3).
## construct:nextlayer
construct.commands.nextlayer=Step layer up by one (wraps max to 0).
construct.commands.nextlayer.success=§aInstance "%1" advanced to layer %2.
+4
View File
@@ -150,3 +150,7 @@ construct.commands.error.noLocation=§cInstance "%1" has no saved location.
construct.commands.layer=Set the active layer of an instance (0 = whole structure).
construct.commands.layer.success=§aSet instance "%1" layer to %2.
construct.commands.layer.outOfBounds=§cLayer %1 is out of bounds for instance "%2" (max %3).
## construct:nextlayer
construct.commands.nextlayer=Step layer up by one (wraps max to 0).
construct.commands.nextlayer.success=§aInstance "%1" advanced to layer %2.