Fix rotate transform with /paste, make 'centre' option actually scale/rotate from centre.

This commit is contained in:
UnknownShadow200 2016-09-01 20:48:34 +10:00
parent 6d2ab937ce
commit b1faf7c502
5 changed files with 17 additions and 13 deletions

View File

@ -41,10 +41,6 @@ namespace MCGalaxy.Commands.Building {
string message = (string)state;
CopyState cState = p.CopyBuffer;
m[0] += cState.Offset;
if (cState.X != cState.OriginX) m[0].X -= (cState.Width - 1);
if (cState.Y != cState.OriginY) m[0].Y -= (cState.Height - 1);
if (cState.Z != cState.OriginZ) m[0].Z -= (cState.Length - 1);
if (message == "") {
SimplePasteDrawOp simpleOp = new SimplePasteDrawOp();

View File

@ -28,6 +28,17 @@ namespace MCGalaxy.Drawing.Ops {
return CopyState.UsedBlocks;
}
public override void SetMarks(Vec3S32[] m) {
Origin = m[0];
CopyState cState = CopyState;
if (cState.X != cState.OriginX) m[0].X -= (cState.Width - 1);
if (cState.Y != cState.OriginY) m[0].Y -= (cState.Height - 1);
if (cState.Z != cState.OriginZ) m[0].Z -= (cState.Length - 1);
Min = m[0]; Max = m[0];
Max.X += cState.Width; Max.Y += cState.Height; Max.Z += cState.Length;
}
public override void Perform(Vec3S32[] marks, Player p, Level lvl, Brush brush, Action<DrawOpBlock> output) {
CopyState state = CopyState;
bool pasteAir = state.PasteAir;
@ -41,22 +52,17 @@ namespace MCGalaxy.Drawing.Ops {
ushort x = (ushort)(locX + x1), y = (ushort)(locY + y1), z = (ushort)(locZ + z1);
if ((b != Block.air || pasteAir) && lvl.InBound(x, y, z))
output(Place(x, y, z, b, extB));
output(Place(x, y, z, b, extB));
}
}
}
public class PasteDrawOp : DrawOp {
public class PasteDrawOp : SimplePasteDrawOp {
public CopyState CopyState;
public ExtBlock[] Include, Exclude;
public override string Name { get { return "Paste"; } }
public override long BlocksAffected(Level lvl, Vec3S32[] marks) {
return CopyState.UsedBlocks;
}
public override void Perform(Vec3S32[] marks, Player p, Level lvl, Brush brush, Action<DrawOpBlock> output) {
CopyState state = CopyState;
bool pasteAir = state.PasteAir;
@ -88,7 +94,7 @@ namespace MCGalaxy.Drawing.Ops {
for (int j = 0; j < include.Length; j++) {
ExtBlock block = include[j];
if (b == block.Block && (b != Block.custom_block || extB == block.Ext)) {
output(Place(x, y, z, b, extB)); break;
output(Place(x, y, z, b, extB)); break;
}
}
}

View File

@ -43,7 +43,7 @@ namespace MCGalaxy.Drawing.Transforms {
DrawOp op, Brush brush, Action<DrawOpBlock> output) {
P = (op.Min + op.Max) / 2;
width = lvl.Width; height = lvl.Height; length = lvl.Length;
if (!CentreOrigin) P = op.Origin;
if (!CentreOrigin) P = op.Origin;
op.Perform(marks, p, lvl, brush, b => OutputBlock(b, output));
}

View File

@ -46,6 +46,7 @@ namespace MCGalaxy.Drawing.Transforms {
if (!args[args.Length - 1].CaselessEq("centre")) {
Player.Message(p, "The mode must be either \"centre\", or not given."); return null;
}
rotater.CentreOrigin = true;
return rotater;
}

View File

@ -68,6 +68,7 @@ namespace MCGalaxy.Drawing.Transforms {
if (!args[args.Length - 1].CaselessEq("centre")) {
Player.Message(p, "The mode must be either \"centre\", or not given."); return null;
}
scaler.CentreOrigin = true;
return scaler;
}