mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-25 22:30:52 -04:00
Add black-and-white rainbow brush, add random rainbow brush with a seed.
This commit is contained in:
parent
ab5f5f3824
commit
672e93ba2a
@ -31,7 +31,7 @@ namespace MCGalaxy.Commands {
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
parts[i] = parts[i].ToLower();
|
||||
CatchPos cpos = default(CatchPos);
|
||||
cpos.message = message;
|
||||
cpos.message = message.ToLower();
|
||||
cpos.solid = message == "" ? SolidType.solid : GetType(parts[parts.Length - 1]);
|
||||
OnUse(p, message, parts, ref cpos);
|
||||
p.blockchangeObject = cpos;
|
||||
|
@ -29,11 +29,12 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
public abstract byte NextExtBlock(DrawOp op);
|
||||
|
||||
public static Dictionary<string, Func<BrushArgs, Brush>> Brushes
|
||||
= new Dictionary<string, Func<BrushArgs, Brush>> {
|
||||
= new Dictionary<string, Func<BrushArgs, Brush>> {
|
||||
{ "normal", SolidBrush.Process },
|
||||
{ "paste", PasteBrush.Process },
|
||||
{ "checkered", CheckeredBrush.Process },
|
||||
{ "rainbow", RainbowBrush.Process },
|
||||
{ "bwrainbow", BWRainbowBrush.Process },
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -25,11 +25,7 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
public sealed class RainbowBrush : Brush {
|
||||
|
||||
public override byte NextBlock(DrawOp op) {
|
||||
int dx = op.Coords.X - op.Min.X;
|
||||
int dy = op.Coords.Y - op.Min.Y;
|
||||
int dz = op.Coords.Z - op.Min.Z;
|
||||
|
||||
int offset = (dx + dy + dz) % 13;
|
||||
int offset = (op.Coords.X + op.Coords.Y + op.Coords.Z) % 13;
|
||||
if (offset < 0) offset += 13;
|
||||
return (byte)(Block.red + offset);
|
||||
}
|
||||
@ -37,9 +33,34 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
public override byte NextExtBlock(DrawOp op) { return 0; }
|
||||
|
||||
public static Brush Process(BrushArgs args) {
|
||||
if (args.Message == "random")
|
||||
return new RandomRainbowBrush();
|
||||
return new RainbowBrush(); // TODO: seed
|
||||
if (args.Message.StartsWith("random")) {
|
||||
string[] parts = args.Message.Split(' ');
|
||||
int seed;
|
||||
if (parts.Length > 1 && Int32.TryParse(parts[1], out seed))
|
||||
return new RandomRainbowBrush(seed);
|
||||
return new RandomRainbowBrush();
|
||||
}
|
||||
|
||||
if (args.Message == "bw")
|
||||
return new BWRainbowBrush();
|
||||
return new RainbowBrush();
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class BWRainbowBrush : Brush {
|
||||
|
||||
static byte[] blocks = { Block.iron, Block.white, Block.lightgrey,
|
||||
Block.darkgrey, Block.obsidian, Block.darkgrey, Block.lightgrey, Block.white };
|
||||
public override byte NextBlock(DrawOp op) {
|
||||
int offset = (op.Coords.X + op.Coords.Y + op.Coords.Z) % 8;
|
||||
if (offset < 0) offset += 8;
|
||||
return blocks[offset];
|
||||
}
|
||||
|
||||
public override byte NextExtBlock(DrawOp op) { return 0; }
|
||||
|
||||
public static Brush Process(BrushArgs args) {
|
||||
return new BWRainbowBrush();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,9 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
/// <summary> Maximum coordinates of the bounds of this drawing command. </summary>
|
||||
public Vector3U16 Max;
|
||||
|
||||
/// <summary> Coordinates of the first point selected by the user. </summary>
|
||||
public Vector3U16 Origin;
|
||||
|
||||
/// <summary> Coordinates of the current block being processed by the drawing command. </summary>
|
||||
public Vector3U16 Coords;
|
||||
|
||||
@ -118,6 +121,7 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
public static bool DoDrawOp(DrawOp op, Brush brush, Player p,
|
||||
ushort x1, ushort y1, ushort z1, ushort x2, ushort y2, ushort z2) {
|
||||
int affected = 0;
|
||||
op.Origin = new Vector3U16(x1, y1, z1);
|
||||
op.Min = Vector3U16.Min(x1, y1, z1, x2, y2, z2);
|
||||
op.Max = Vector3U16.Max(x1, y1, z1, x2, y2, z2);
|
||||
if (op.MinMaxCoords) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user