static void CopyCallback([NotNull] Player player, [NotNull] Vector3I[] marks, [NotNull] object tag)
{
int sx = Math.Min(marks[0].X, marks[1].X);
int ex = Math.Max(marks[0].X, marks[1].X);
int sy = Math.Min(marks[0].Y, marks[1].Y);
int ey = Math.Max(marks[0].Y, marks[1].Y);
int sz = Math.Min(marks[0].Z, marks[1].Z);
int ez = Math.Max(marks[0].Z, marks[1].Z);
BoundingBox bounds = new BoundingBox(sx, sy, sz, ex, ey, ez);
int volume = bounds.Volume;
if (!player.CanDraw(volume))
{
player.MessageNow(
"You are only allowed to run commands that affect up to {0} blocks. This one would affect {1} blocks.",
player.Info.Rank.DrawLimit,
volume);
return;
}
// remember dimensions and orientation
CopyState copyInfo = new CopyState(marks[0], marks[1]);
Map map = player.WorldMap;
World playerWorld = player.World;
if (playerWorld == null)
{
PlayerOpException.ThrowNoWorld(player);
}
for (int x = sx; x <= ex; x++)
{
for (int y = sy; y <= ey; y++)
{
for (int z = sz; z <= ez; z++)
{
copyInfo.Blocks[x - sx, y - sy, z - sz] = map.GetBlock(x, y, z);
}
}
}
copyInfo.OriginWorld = playerWorld.Name;
copyInfo.CopyTime = DateTime.UtcNow;
player.SetCopyState(copyInfo);
player.MessageNow("{0} blocks copied into slot #{1}, origin at {2} corner. You can now &H/Paste",
volume,
player.CopySlot + 1,
copyInfo.OriginCorner);
Logger.Log(LogType.UserActivity,
"{0} copied {1} blocks from world {2} (between {3} and {4}).",
player.Name,
volume,
playerWorld.Name,
bounds.MinVertex,
bounds.MaxVertex);
}