From b4ff844f234c50b72f59e54d9c9d01b6adb442eb Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 13 Jul 2023 23:15:44 +1000 Subject: [PATCH] Replace and paste brushes now support block ranges for arguments, also change striped brush to default to 'skip' instead of 'air' when only 0 or 1 argument provided --- MCGalaxy/Drawing/BrushFactories/ReplaceBrushes.cs | 11 ++++++----- MCGalaxy/Drawing/BrushFactories/SimpleBrushes.cs | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/MCGalaxy/Drawing/BrushFactories/ReplaceBrushes.cs b/MCGalaxy/Drawing/BrushFactories/ReplaceBrushes.cs index a62765cbe..f457dcdd9 100644 --- a/MCGalaxy/Drawing/BrushFactories/ReplaceBrushes.cs +++ b/MCGalaxy/Drawing/BrushFactories/ReplaceBrushes.cs @@ -16,6 +16,7 @@ permissions and limitations under the Licenses. */ using System; +using System.Collections.Generic; using MCGalaxy.Commands; using BlockID = System.UInt16; @@ -52,14 +53,14 @@ namespace MCGalaxy.Drawing.Brushes } internal static BlockID[] GetBlocks(Player p, int start, int max, string[] parts) { - BlockID[] blocks = new BlockID[max - start]; + List blocks = new List(max - start); + for (int i = 0; start < max; start++, i++) { - BlockID block; - if (!CommandParser.GetBlockIfAllowed(p, parts[start], "draw with", out block)) return null; - blocks[i] = block; + int count = CommandParser.GetBlocksIfAllowed(p, parts[start], "draw with", blocks, false); + if (count == 0) return null; } - return blocks; + return blocks.ToArray(); } static bool GetTargetBlock(BrushArgs args, string[] parts, out BlockID target) { diff --git a/MCGalaxy/Drawing/BrushFactories/SimpleBrushes.cs b/MCGalaxy/Drawing/BrushFactories/SimpleBrushes.cs index 084085e9b..40114389b 100644 --- a/MCGalaxy/Drawing/BrushFactories/SimpleBrushes.cs +++ b/MCGalaxy/Drawing/BrushFactories/SimpleBrushes.cs @@ -166,14 +166,14 @@ namespace MCGalaxy.Drawing.Brushes Player p = args.Player; if (args.Message.Length == 0) { if (!CommandParser.IsBlockAllowed(p, "draw with", args.Block)) return null; - return new StripedBrush(args.Block, Block.Air); + return new StripedBrush(args.Block, Block.Invalid); } string[] parts = args.Message.SplitSpaces(); BlockID block1; if (!CommandParser.GetBlockIfAllowed(p, parts[0], "draw with", out block1, true)) return null; if (parts.Length == 1) - return new StripedBrush(block1, Block.Air); + return new StripedBrush(block1, Block.Invalid); BlockID block2; if (!CommandParser.GetBlockIfAllowed(p, parts[1], "draw with", out block2, true)) return null;