mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 03:55:18 -04:00
Now if only [block] is given for replace/replacenot/replaceall, it replaces that block with your current held block.
This commit is contained in:
parent
93b70cbebc
commit
3603893216
@ -26,6 +26,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
public override string type { get { return CommandTypes.Building; } }
|
||||
public override bool museumUsable { get { return false; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
|
||||
protected virtual bool ReplaceNot { get { return false; } }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
Player.Message(p, "Place two blocks to determine the edges.");
|
||||
@ -41,12 +42,11 @@ namespace MCGalaxy.Commands.Building {
|
||||
return DrawOp.DoDrawOp(drawOp, brush, p, marks);
|
||||
}
|
||||
|
||||
protected virtual bool ReplaceNot { get { return false; } }
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/replace [block] [block2].. [new]");
|
||||
Player.Message(p, "%HReplaces [block] with [new] between two points.");
|
||||
Player.Message(p, "%H If more than one [block] is specified, they will all be replaced with [new].");
|
||||
Player.Message(p, "%H If more than one [block] is given, they are all replaced.");
|
||||
Player.Message(p, "%H If only [block] is given, replaces with your held block.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,7 +58,8 @@ namespace MCGalaxy.Commands.Building {
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/replacenot [block] [block2].. [new]");
|
||||
Player.Message(p, "%HReplaces everything but [block] with [new] between two points.");
|
||||
Player.Message(p, "%H If more than one [block] is specified, they will all be ignored.");
|
||||
Player.Message(p, "%H If more than one [block] is given, they are all skipped.");
|
||||
Player.Message(p, "%H If only [block] is given, replaces with your held block.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,7 +88,8 @@ namespace MCGalaxy.Commands.Building {
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/replaceall [block] [block2].. [new]");
|
||||
Player.Message(p, "%HReplaces [block] with [new] for the entire map.");
|
||||
Player.Message(p, "%H If more than one [block] is specified, they will all be replaced with [new].");
|
||||
Player.Message(p, "%H If more than one [block] is given, they are all replaced.");
|
||||
Player.Message(p, "%H If only [block] is given, replaces with your held block.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,10 +58,10 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
public struct BrushArgs {
|
||||
public Player Player;
|
||||
public string Message;
|
||||
public byte Type, ExtType; // currently holding
|
||||
public byte Block, ExtBlock; // currently holding
|
||||
|
||||
public BrushArgs(Player p, string message, byte type, byte extType) {
|
||||
Player = p; Message = message; Type = type; ExtType = extType;
|
||||
public BrushArgs(Player p, string message, byte block, byte extBlock) {
|
||||
Player = p; Message = message; Block = block; ExtBlock = extBlock;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
|
||||
public static Brush Process(BrushArgs args) {
|
||||
if (args.Message == "")
|
||||
return new CheckeredBrush(args.Type, args.ExtType, 0, 0);
|
||||
return new CheckeredBrush(args.Block, args.ExtBlock, 0, 0);
|
||||
string[] parts = args.Message.Split(' ');
|
||||
|
||||
byte extBlock1;
|
||||
|
@ -78,7 +78,7 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
|
||||
// No blocks given, assume first is held block
|
||||
if (bCount == 0)
|
||||
blocks[0] = new ExtBlock(args.Type, args.ExtType);
|
||||
blocks[0] = new ExtBlock(args.Block, args.ExtBlock);
|
||||
}
|
||||
|
||||
public static ExtBlock[] Combine(ExtBlock[] toAffect, int[] count) {
|
||||
|
@ -36,27 +36,27 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
|
||||
public static string[] HelpString = new [] {
|
||||
"%TArguments: [block1] [block2].. [new]",
|
||||
"%HDraws by replacing existing blocks that are in " +
|
||||
"the given [blocks] with the block [new]",
|
||||
"%HDraws by replacing existing blocks that are in the given [blocks] with [new]",
|
||||
"%H If only [block] is given, replaces with your held block.",
|
||||
};
|
||||
|
||||
public static Brush Process(BrushArgs args) {
|
||||
return ProcessReplace(args, false);
|
||||
return ProcessReplace(args, false);
|
||||
}
|
||||
|
||||
internal static Brush ProcessReplace(BrushArgs args, bool not) {
|
||||
string[] parts = args.Message.Split(' ');
|
||||
if (parts.Length < 2) {
|
||||
args.Player.SendMessage("You need to provide a target block, and at least one block to replace."); return null;
|
||||
string[] parts = args.Message.Split(' ');
|
||||
if (args.Message == "") {
|
||||
args.Player.SendMessage("You need at least one block to replace."); return null;
|
||||
}
|
||||
ExtBlock[] toAffect = GetBlocks(args.Player, 0, parts.Length - 1, parts);
|
||||
|
||||
int count = parts.Length == 1 ? 1 : parts.Length - 1;
|
||||
ExtBlock[] toAffect = GetBlocks(args.Player, 0, count, parts);
|
||||
if (toAffect == null) return null;
|
||||
|
||||
ExtBlock target;
|
||||
int block = DrawCmd.GetBlock(args.Player, parts[parts.Length - 1], out target.Ext);
|
||||
if (block == -1) return null;
|
||||
if (!GetTargetBlock(args, parts, out target)) return null;
|
||||
|
||||
target.Block = (byte)block;
|
||||
if (not) return new ReplaceNotBrush(toAffect, target);
|
||||
return new ReplaceBrush(toAffect, target);
|
||||
}
|
||||
@ -74,6 +74,19 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
static bool GetTargetBlock(BrushArgs args, string[] parts, out ExtBlock target) {
|
||||
if (parts.Length == 1) {
|
||||
target = new ExtBlock(args.Block, args.ExtBlock);
|
||||
return true;
|
||||
}
|
||||
|
||||
target = default(ExtBlock);
|
||||
int block = DrawCmd.GetBlock(args.Player, parts[parts.Length - 1], out target.Ext);
|
||||
if (block == -1) return false;
|
||||
target.Block = (byte)block;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override byte NextBlock(DrawOp op) {
|
||||
ushort x = op.Coords.X, y = op.Coords.Y, z = op.Coords.Z;
|
||||
byte tile = op.Level.GetTile(x, y, z), extTile = 0;
|
||||
@ -106,8 +119,8 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
|
||||
public static string[] HelpString = new [] {
|
||||
"%TArguments: [block1] [block2].. [new]",
|
||||
"%HDraws by replacing existing blocks that not are in " +
|
||||
"the given [blocks] with the block [new]",
|
||||
"%HDraws by replacing existing blocks that not are in the given [blocks] with [new]",
|
||||
"%H If only [block] is given, replaces with your held block.",
|
||||
};
|
||||
|
||||
public static Brush Process(BrushArgs args) {
|
||||
|
@ -41,7 +41,7 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
|
||||
public static Brush Process(BrushArgs args) {
|
||||
if (args.Message == "")
|
||||
return new SolidBrush(args.Type, args.ExtType);
|
||||
return new SolidBrush(args.Block, args.ExtBlock);
|
||||
byte extBlock;
|
||||
int block = DrawCmd.GetBlock(args.Player, args.Message, out extBlock);
|
||||
if (block == -1) return null;
|
||||
|
@ -43,7 +43,7 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
|
||||
public static Brush Process(BrushArgs args) {
|
||||
if (args.Message == "")
|
||||
return new StripedBrush(args.Type, args.ExtType, 0, 0);
|
||||
return new StripedBrush(args.Block, args.ExtBlock, 0, 0);
|
||||
string[] parts = args.Message.Split(' ');
|
||||
|
||||
byte extBlock1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user