mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-21 11:29:42 -04:00
Fix rotate transform with /paste, make 'centre' option actually scale/rotate from centre.
This commit is contained in:
parent
6d2ab937ce
commit
b1faf7c502
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user