From fd8d29f1d48b83afc660b640828d92fe71f70818 Mon Sep 17 00:00:00 2001 From: SIsilicon Date: Sat, 16 Mar 2024 09:56:34 -0500 Subject: [PATCH] Made shape success message slightly more accurate --- src/server/modules/pattern.ts | 42 +++++++++------------------------ src/server/shapes/base_shape.ts | 3 +-- 2 files changed, 12 insertions(+), 33 deletions(-) diff --git a/src/server/modules/pattern.ts b/src/server/modules/pattern.ts index 396275e80..e58c7bcc1 100644 --- a/src/server/modules/pattern.ts +++ b/src/server/modules/pattern.ts @@ -153,11 +153,13 @@ export class Pattern implements CustomArgType { } const command = `fill ${start.x} ${start.y} ${start.z} ${end.x} ${end.y} ${end.z} ${this.simpleCache}`; const maskArgs = mask?.getSimpleForCommandArgs(); + let successCount = 0; if (maskArgs?.length) { - maskArgs.forEach((m) => dimension.runCommand(command + ` replace ${m}`)); + maskArgs.forEach((m) => (successCount += dimension.runCommand(command + ` replace ${m}`).successCount)); } else { - dimension.runCommand(command); + successCount += dimension.runCommand(command).successCount; } + return !!successCount; } getSimpleBlockFill() { @@ -335,10 +337,7 @@ class BlockPattern extends PatternNode { readonly opCount = 0; readonly permutation: BlockPermutation; - constructor( - token: Token, - public block: parsedBlock - ) { + constructor(token: Token, public block: parsedBlock) { super(token); this.permutation = parsedBlock2BlockPermutation(block); } @@ -354,10 +353,7 @@ class TypePattern extends PatternNode { readonly permutation: BlockPermutation; readonly props: Record; - constructor( - token: Token, - public type: string - ) { + constructor(token: Token, public type: string) { super(token); this.permutation = BlockPermutation.resolve(type); this.props = this.permutation.getAllStates(); @@ -376,10 +372,7 @@ class StatePattern extends PatternNode { readonly prec = -1; readonly opCount = 0; - constructor( - token: Token, - public states: parsedBlock["states"] - ) { + constructor(token: Token, public states: parsedBlock["states"]) { super(token); } @@ -398,10 +391,7 @@ class RandStatePattern extends PatternNode { readonly opCount = 0; readonly permutations: BlockPermutation[]; - constructor( - token: Token, - public block: string - ) { + constructor(token: Token, public block: string) { super(token); this.permutations = Array.from(Server.block.iteratePermutations(this.block)); } @@ -415,10 +405,7 @@ class ClipboardPattern extends PatternNode { readonly prec = -1; readonly opCount = 0; - constructor( - token: Token, - public offset: Vector3 - ) { + constructor(token: Token, public offset: Vector3) { super(token); } @@ -455,11 +442,7 @@ class GradientPattern extends PatternNode { private ctxCardinal: Cardinal; - constructor( - token: Token, - public gradientId: string, - public cardinal?: Cardinal - ) { + constructor(token: Token, public gradientId: string, public cardinal?: Cardinal) { super(token); if (cardinal) this.updateDirectionParams(cardinal); } @@ -497,10 +480,7 @@ class PercentPattern extends PatternNode { readonly prec = 2; readonly opCount = 1; - constructor( - token: Token, - public percent: number - ) { + constructor(token: Token, public percent: number) { super(token); } diff --git a/src/server/shapes/base_shape.ts b/src/server/shapes/base_shape.ts index 26f11bc71..2010558eb 100644 --- a/src/server/shapes/base_shape.ts +++ b/src/server/shapes/base_shape.ts @@ -267,8 +267,7 @@ export abstract class Shape { const [min, max] = block; const volume = regionVolume(min, max); if (Jobs.inContext()) while (!Jobs.loadBlock(min)) yield sleep(1); - pattern.fillSimpleArea(dimension, min, max, mask); - count += volume; + if (pattern.fillSimpleArea(dimension, min, max, mask)) count += volume; yield Jobs.setProgress(progress / blocksAffected); progress += volume; }