Fix /paste not working correctly when paste origin was outside the map.

This commit is contained in:
UnknownShadow200 2016-05-26 09:17:52 +10:00
parent d311ee34eb
commit e7409d5301
2 changed files with 8 additions and 9 deletions

View File

@ -45,11 +45,11 @@ namespace MCGalaxy.Commands.Building {
void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
CatchPos cpos = (CatchPos)p.blockchangeObject;
RevertAndClearState(p, x, y, z);
int offX = p.copyoffset[0] + x, offY = p.copyoffset[1] + y, offZ = p.copyoffset[2] + z;
int x1 = p.copyoffset[0] + x, y1 = p.copyoffset[1] + y, z1 = p.copyoffset[2] + z;
CopyState state = p.CopyBuffer;
if (state.X != state.OriginX) offX -= (state.Width - 1);
if (state.Y != state.OriginY) offY -= (state.Height - 1);
if (state.Z != state.OriginZ) offZ -= (state.Length - 1);
if (state.X != state.OriginX) x1 -= (state.Width - 1);
if (state.Y != state.OriginY) y1 -= (state.Height - 1);
if (state.Z != state.OriginZ) z1 -= (state.Length - 1);
DrawOp op;
if (cpos.message == "") {
@ -64,8 +64,8 @@ namespace MCGalaxy.Commands.Building {
else
((PasteDrawOp)op).Include = ReplaceBrush.GetBlocks(p, 0, args.Length, args);
}
if (!DrawOp.DoDrawOp(op, null, p, (ushort)offX, (ushort)offY, (ushort)offZ, 0, 0, 0))
Vec3S32[] marks = { new Vec3S32(x1, y1, z1) };
if (!DrawOp.DoDrawOp(op, null, p, marks))
return;
if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
}

View File

@ -32,18 +32,17 @@ namespace MCGalaxy.Drawing.Ops {
}
public override void Perform(Vec3S32[] marks, Player p, Level lvl, Brush brush) {
Vec3U16 p1 = Clamp(marks[0]);
CopyState state = CopyState;
bool pasteAir = state.PasteAir;
// Adjust for the fact that paste origin may be outside the map.
short offX = (short)p1.X, offY = (short)p1.Y, offZ = (short)p1.Z;
int x1 = marks[0].X, y1 = marks[0].Y, z1 = marks[0].Z;
for (int i = 0; i < state.Blocks.Length; i++ ) {
ushort locX, locY, locZ;
byte b = state.Blocks[i], extB = state.ExtBlocks[i];
state.GetCoords(i, out locX, out locY, out locZ);
ushort x = (ushort)(locX + offX), y = (ushort)(locY + offY), z = (ushort)(locZ + offZ);
ushort x = (ushort)(locX + x1), y = (ushort)(locY + y1), z = (ushort)(locZ + z1);
byte type = lvl.GetTile(x, y, z), extType = 0;
if (type == Block.custom_block) extType = lvl.GetExtTile(x, y, z);