From 6520082d1659ec3bf2754cb31f7f19ac5eab2210 Mon Sep 17 00:00:00 2001 From: ForestOfLight Date: Wed, 20 May 2026 02:50:05 -0700 Subject: [PATCH] feat(cli): add construct:nextlayer command --- packs/BP/scripts/commands/NextLayerCommand.js | 36 +++++++++++++++++++ packs/BP/scripts/main.js | 1 + packs/RP/texts/en_US.lang | 4 +++ packs/RP/texts/zh_CN.lang | 4 +++ 4 files changed, 45 insertions(+) create mode 100644 packs/BP/scripts/commands/NextLayerCommand.js diff --git a/packs/BP/scripts/commands/NextLayerCommand.js b/packs/BP/scripts/commands/NextLayerCommand.js new file mode 100644 index 0000000..fa4684c --- /dev/null +++ b/packs/BP/scripts/commands/NextLayerCommand.js @@ -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(); diff --git a/packs/BP/scripts/main.js b/packs/BP/scripts/main.js index 3066101..a7d1a42 100644 --- a/packs/BP/scripts/main.js +++ b/packs/BP/scripts/main.js @@ -19,6 +19,7 @@ import './commands/PlaceCommand'; import './commands/MoveCommand'; import './commands/ActiveCommand'; import './commands/LayerCommand'; +import './commands/NextLayerCommand'; // Other import './classes/BlockInfo'; diff --git a/packs/RP/texts/en_US.lang b/packs/RP/texts/en_US.lang index 7804ce2..51b3c38 100644 --- a/packs/RP/texts/en_US.lang +++ b/packs/RP/texts/en_US.lang @@ -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. diff --git a/packs/RP/texts/zh_CN.lang b/packs/RP/texts/zh_CN.lang index 19dd07e..098ec04 100644 --- a/packs/RP/texts/zh_CN.lang +++ b/packs/RP/texts/zh_CN.lang @@ -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.