mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-26 23:02:04 -04:00
Only blocks of different types should be replaced by /paste.
This commit is contained in:
parent
c0be192333
commit
48c3b7cf94
@ -90,8 +90,7 @@ namespace MCGalaxy.Commands
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
|
for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
|
||||||
for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
|
for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
|
||||||
|
|
||||||
for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
|
for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
|
||||||
{
|
{
|
||||||
p.level.Blockchange(p, xx, yy, zz, blocks[xx + (zz * width) + (yy * width * height)]);
|
p.level.Blockchange(p, xx, yy, zz, blocks[xx + (zz * width) + (yy * width * height)]);
|
||||||
|
@ -65,10 +65,8 @@ namespace MCGalaxy.Commands
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Help(Player p)
|
public override void Help(Player p) {
|
||||||
{
|
|
||||||
Player.SendMessage(p, "/TempRankInfo <player> - Lists the info of the Temporary rank of the given player");
|
Player.SendMessage(p, "/TempRankInfo <player> - Lists the info of the Temporary rank of the given player");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,91 +1,97 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2011 MCGalaxy
|
Copyright 2011 MCGalaxy
|
||||||
|
|
||||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||||
not use this file except in compliance with the Licenses. You may
|
not use this file except in compliance with the Licenses. You may
|
||||||
obtain a copy of the Licenses at
|
obtain a copy of the Licenses at
|
||||||
|
|
||||||
http://www.opensource.org/licenses/ecl2.php
|
http://www.opensource.org/licenses/ecl2.php
|
||||||
http://www.gnu.org/licenses/gpl-3.0.html
|
http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,
|
||||||
software distributed under the Licenses are distributed on an "AS IS"
|
software distributed under the Licenses are distributed on an "AS IS"
|
||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using MCGalaxy.Drawing;
|
using MCGalaxy.Drawing;
|
||||||
|
|
||||||
namespace MCGalaxy.Commands
|
namespace MCGalaxy.Commands
|
||||||
{
|
{
|
||||||
public sealed class CmdPaste : Command
|
public sealed class CmdPaste : Command
|
||||||
{
|
{
|
||||||
public override string name { get { return "paste"; } }
|
public override string name { get { return "paste"; } }
|
||||||
public override string shortcut { get { return "v"; } }
|
public override string shortcut { get { return "v"; } }
|
||||||
public override string type { get { return CommandTypes.Building; } }
|
public override string type { get { return CommandTypes.Building; } }
|
||||||
public override bool museumUsable { get { return false; } }
|
public override bool museumUsable { get { return false; } }
|
||||||
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
|
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
|
||||||
|
|
||||||
public CmdPaste() { }
|
public CmdPaste() { }
|
||||||
|
|
||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
if (message != "") { Help(p); return; }
|
if (message != "") { Help(p); return; }
|
||||||
if (p.CopyBuffer == null) {
|
if (p.CopyBuffer == null) {
|
||||||
Player.SendMessage(p, "You haven't copied anything yet"); return;
|
Player.SendMessage(p, "You haven't copied anything yet"); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.blockchangeObject = default(CatchPos);
|
p.blockchangeObject = default(CatchPos);
|
||||||
Player.SendMessage(p, "Place a block in the corner of where you want to paste."); p.ClearBlockchange();
|
Player.SendMessage(p, "Place a block in the corner of where you want to paste."); p.ClearBlockchange();
|
||||||
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
|
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
|
void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
|
||||||
RevertAndClearState(p, x, y, z);
|
RevertAndClearState(p, x, y, z);
|
||||||
int offX = p.copyoffset[0] + x, offY = p.copyoffset[1] + y, offZ = p.copyoffset[2] + z;
|
int offX = p.copyoffset[0] + x, offY = p.copyoffset[1] + y, offZ = p.copyoffset[2] + z;
|
||||||
Player.UndoPos Pos1;
|
CopyState state = p.CopyBuffer;
|
||||||
CopyState state = p.CopyBuffer;
|
if (state.X != state.OriginX) offX -= (state.Width - 1);
|
||||||
if (state.X != state.OriginX) offX -= (state.Width - 1);
|
if (state.Y != state.OriginY) offY -= (state.Height - 1);
|
||||||
if (state.Y != state.OriginY) offY -= (state.Height - 1);
|
if (state.Z != state.OriginZ) offZ -= (state.Length - 1);
|
||||||
if (state.Z != state.OriginZ) offZ -= (state.Length - 1);
|
int blocksChanged = 0;
|
||||||
|
|
||||||
if (p.level.bufferblocks && !p.level.Instant) {
|
if (p.level.bufferblocks && !p.level.Instant) {
|
||||||
for (int i = 0; i < state.Blocks.Length; i++ ) {
|
for (int i = 0; i < state.Blocks.Length; i++ ) {
|
||||||
ushort locX, locY, locZ;
|
ushort locX, locY, locZ;
|
||||||
byte b = state.Blocks[i];
|
byte b = state.Blocks[i], extB = state.ExtBlocks[i];
|
||||||
state.GetCoords(i, out locX, out locY, out locZ);
|
state.GetCoords(i, out locX, out locY, out locZ);
|
||||||
|
|
||||||
Pos1.x = (ushort)(locX + offX);
|
x = (ushort)(locX + offX); y = (ushort)(locY + offY); z = (ushort)(locZ + offZ);
|
||||||
Pos1.y = (ushort)(locY + offY);
|
type = p.level.GetTile(x, y, z);
|
||||||
Pos1.z = (ushort)(locZ + offZ);
|
if (type == Block.custom_block) extType = p.level.GetExtTile(x, y, z);
|
||||||
if ((b != Block.air || p.copyAir) && p.level.InBound(Pos1.x, Pos1.y, Pos1.z))
|
|
||||||
BlockQueue.Addblock(p, Pos1.x, Pos1.y, Pos1.z, b, state.ExtBlocks[i]);
|
bool place = p.level.InBound(x, y, z) && (b != type || (b == Block.custom_block && extB != extType));
|
||||||
}
|
if ((b != Block.air || p.copyAir) && place) {
|
||||||
} else {
|
BlockQueue.Addblock(p, x, y, z, b, extB); blocksChanged++;
|
||||||
for (int i = 0; i < state.Blocks.Length; i++ ) {
|
}
|
||||||
ushort locX, locY, locZ;
|
}
|
||||||
byte b = state.Blocks[i];
|
} else {
|
||||||
state.GetCoords(i, out locX, out locY, out locZ);
|
for (int i = 0; i < state.Blocks.Length; i++ ) {
|
||||||
|
ushort locX, locY, locZ;
|
||||||
Pos1.x = (ushort)(locX + offX);
|
byte b = state.Blocks[i], extB = state.ExtBlocks[i];
|
||||||
Pos1.y = (ushort)(locY + offY);
|
state.GetCoords(i, out locX, out locY, out locZ);
|
||||||
Pos1.z = (ushort)(locZ + offZ);
|
|
||||||
if ((b != Block.air || p.copyAir) && p.level.InBound(Pos1.x, Pos1.y, Pos1.z))
|
x = (ushort)(locX + offX); y = (ushort)(locY + offY); z = (ushort)(locZ + offZ);
|
||||||
p.level.Blockchange(p, Pos1.x, Pos1.y, Pos1.z, b, state.ExtBlocks[i]);
|
type = p.level.GetTile(x, y, z);
|
||||||
}
|
if (type == Block.custom_block) extType = p.level.GetExtTile(x, y, z);
|
||||||
}
|
|
||||||
|
bool place = p.level.InBound(x, y, z) && (b != type || (b == Block.custom_block && extB != extType));
|
||||||
|
if ((b != Block.air || p.copyAir) && place) {
|
||||||
|
p.level.Blockchange(p, x, y, z, b, extB); blocksChanged++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Player.SendMessage(p, "Pasted " + p.CopyBuffer.Volume + " blocks.");
|
Player.SendMessage(p, "Pasted " + p.CopyBuffer.Volume + " blocks, " + blocksChanged + " changed.");
|
||||||
if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
|
if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CatchPos { }
|
struct CatchPos { }
|
||||||
|
|
||||||
public override void Help(Player p)
|
public override void Help(Player p)
|
||||||
{
|
{
|
||||||
Player.SendMessage(p, "/paste - Pastes the stored copy.");
|
Player.SendMessage(p, "/paste - Pastes the stored copy.");
|
||||||
Player.SendMessage(p, "&4BEWARE: " + Server.DefaultColor + "The blocks will always be pasted in a set direction");
|
Player.SendMessage(p, "&4BEWARE: " + Server.DefaultColor + "The blocks will always be pasted in a set direction");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user