mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Fix /copy cut not being counted as a drawop that could be used in /undo (Thanks FabTheZen), closes #169.
This commit is contained in:
parent
ff9d2d1627
commit
4cafa26354
@ -20,6 +20,8 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using MCGalaxy.Drawing;
|
using MCGalaxy.Drawing;
|
||||||
|
using MCGalaxy.Drawing.Brushes;
|
||||||
|
using MCGalaxy.Drawing.Ops;
|
||||||
|
|
||||||
namespace MCGalaxy.Commands
|
namespace MCGalaxy.Commands
|
||||||
{
|
{
|
||||||
@ -105,12 +107,18 @@ namespace MCGalaxy.Commands
|
|||||||
void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
|
void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
|
||||||
RevertAndClearState(p, x, y, z);
|
RevertAndClearState(p, x, y, z);
|
||||||
CatchPos cpos = (CatchPos)p.blockchangeObject;
|
CatchPos cpos = (CatchPos)p.blockchangeObject;
|
||||||
ushort minX = (ushort)Math.Min(x, cpos.x), minY = (ushort)Math.Min(y, cpos.y);
|
ushort minX = (ushort)Math.Min(x, cpos.x), maxX = (ushort)Math.Max(x, cpos.x);
|
||||||
ushort minZ = (ushort)Math.Min(z, cpos.z), maxX = (ushort)Math.Max(x, cpos.x);
|
ushort minY = (ushort)Math.Min(y, cpos.y), maxY = (ushort)Math.Max(y, cpos.y);
|
||||||
ushort maxY = (ushort)Math.Max(y, cpos.y), maxZ = (ushort)Math.Max(z, cpos.z);
|
ushort minZ = (ushort)Math.Min(z, cpos.z), maxZ = (ushort)Math.Max(z, cpos.z);
|
||||||
|
|
||||||
CopyState state = new CopyState(minX, minY, minZ, maxX - minX + 1,
|
CopyState state = new CopyState(minX, minY, minZ, maxX - minX + 1,
|
||||||
maxY - minY + 1, maxZ - minZ + 1);
|
maxY - minY + 1, maxZ - minZ + 1);
|
||||||
|
if (state.Volume > p.group.maxBlocks) {
|
||||||
|
Player.Message(p, "You tried to copy up to " + state.Volume + " blocks.");
|
||||||
|
Player.Message(p, "You cannot copy more than " + p.group.maxBlocks + ".");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
state.SetOrigin(cpos.x, cpos.y, cpos.z);
|
state.SetOrigin(cpos.x, cpos.y, cpos.z);
|
||||||
int totalAir = 0, index = 0;
|
int totalAir = 0, index = 0;
|
||||||
state.PasteAir = cpos.type == 2;
|
state.PasteAir = cpos.type == 2;
|
||||||
@ -130,22 +138,11 @@ namespace MCGalaxy.Commands
|
|||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
p.CopyBuffer = state;
|
p.CopyBuffer = state;
|
||||||
|
|
||||||
if ((state.Volume - totalAir) > p.group.maxBlocks) {
|
if (cpos.type == 1) {
|
||||||
Player.Message(p, "You tried to copy " + state.Volume + " blocks.");
|
DrawOp op = new CuboidDrawOp();
|
||||||
Player.Message(p, "You cannot copy more than " + p.group.maxBlocks + ".");
|
Brush brush = new SolidBrush(Block.air, 0);
|
||||||
p.CopyBuffer = null;
|
DrawOp.DoDrawOp(op, brush, p, minX, minY, minZ, maxX, maxY, maxZ);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cpos.type == 1)
|
|
||||||
for (ushort yy = minY; yy <= maxY; ++yy)
|
|
||||||
for (ushort zz = minZ; zz <= maxZ; ++zz)
|
|
||||||
for (ushort xx = minX; xx <= maxX; ++xx)
|
|
||||||
{
|
|
||||||
byte b = p.level.GetTile(xx, yy, zz);
|
|
||||||
if (b != Block.air && Block.canPlace(p, b))
|
|
||||||
p.level.UpdateBlock(p, xx, yy, zz, Block.air, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Player.Message(p, (state.Volume - totalAir) + " blocks copied.");
|
Player.Message(p, (state.Volume - totalAir) + " blocks copied.");
|
||||||
|
@ -35,8 +35,8 @@ namespace MCGalaxy.Commands {
|
|||||||
cpos.mode = GetMode(message, parts);
|
cpos.mode = GetMode(message, parts);
|
||||||
OnUse(p, message, parts, ref cpos);
|
OnUse(p, message, parts, ref cpos);
|
||||||
|
|
||||||
p.blockchangeObject = cpos;
|
p.blockchangeObject = cpos;
|
||||||
Player.Message(p, PlaceMessage);
|
Player.Message(p, PlaceMessage);
|
||||||
p.ClearBlockchange();
|
p.ClearBlockchange();
|
||||||
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
|
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user