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

This commit is contained in:
UnknownShadow200 2023-07-13 23:15:44 +10:00
parent a9adbbd45f
commit b4ff844f23
2 changed files with 8 additions and 7 deletions

View File

@ -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<BlockID> blocks = new List<BlockID>(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) {

View File

@ -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;