本文整理汇总了C#中MCSharp.Player.SendBlockchange方法的典型用法代码示例。如果您正苦于以下问题:C# Player.SendBlockchange方法的具体用法?C# Player.SendBlockchange怎么用?C# Player.SendBlockchange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCSharp.Player
的用法示例。
在下文中一共展示了Player.SendBlockchange方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Blockchange2
public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
{
p.ClearBlockchange();
byte b = p.level.GetTile(x, y, z);
p.SendBlockchange(x, y, z, b);
CatchPos cpos = (CatchPos)p.blockchangeObject;
unchecked { if (cpos.type != (byte)-1) { type = cpos.type; } }
List<Pos> buffer = new List<Pos>();
switch (cpos.solid)
{
case SolidType.solid:
if (!Server.operators.Contains(p.name))
{
int attemptedLimit = (Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z));
if (attemptedLimit > p.group.CuboidLimit && p.group.CuboidLimit != 0) //OPERATOR door LIMIT, same as cuboid
{
p.SendMessage("You're trying to convert " + attemptedLimit + " blocks.");
p.SendMessage("Your block limit is " + p.group.CuboidLimit.ToString() + " blocks. Build in stages.");
return;
}
}
buffer.Capacity = Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z);
for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
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)
/*if (p.level.GetTile(xx, yy, zz) != type) {*/
BufferAdd(buffer, xx, yy, zz); //}
break;
}
p.SendMessage("Converting " + buffer.Count.ToString() + " blocks into door_material.");
// Disable physics before changing the blocks
Physics physicsSetting = p.level.Physics;
p.level.Physics = Physics.Off;
p.level.ClearPhysics();
// Because we are calling ClearPhysics() we do not need to account for doorair_material. These materials will be
// converted back into door_material automatically.
buffer.ForEach(delegate(Pos pos)
{
byte oldBlock = p.level.GetTile(pos.x, pos.y, pos.z); //Get the block that is there at the moment
byte newBlock = Block.convertDoor(oldBlock);
if (newBlock != oldBlock) // if the block is doorifiable
{
if (!opMats.doorBlocks.Contains(oldBlock)) // if the block is not already a door
{
if (!ignoreList.Contains(newBlock)) // if the new block is not being ignored
{
p.level.Blockchange(p, pos.x, pos.y, pos.z, newBlock); // send converted reg_material
}
}
}
});
p.level.Physics = physicsSetting;
p.SendMessage("Conversion complete.");
}
示例2: Blockchange2
public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
{
p.ClearBlockchange();
byte b = p.level.GetTile(x, y, z);
p.SendBlockchange(x, y, z, b);
CatchPos cpos = (CatchPos)p.blockchangeObject;
unchecked { if (cpos.type != (byte)-1) { type = cpos.type; } }
List<Pos> buffer = new List<Pos>();
switch (cpos.solid)
{
case SolidType.solid:
if (!Server.operators.Contains(p.name))
{
int attemptedLimit = (Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z));
if (attemptedLimit > 200000 && p.group.CuboidLimit != 0)
{ //OPERATOR opview limit, NOT DESTRUCTIVE, therefor high limit
p.SendMessage("You're trying to view " + attemptedLimit + " blocks.");
p.SendMessage("Your OpView limit is " + 200000 + " blocks. Build in stages.");
return;
}
}
buffer.Capacity = Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z);
for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
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)
/*if (p.level.GetTile(xx, yy, zz) != type) {*/
BufferAdd(buffer, xx, yy, zz); //}
break;
}
p.SendMessage("Processing " + buffer.Count.ToString() + " blocks.");
buffer.ForEach(delegate(Pos pos)
{
byte bl = p.level.GetTile(pos.x, pos.y, pos.z); //Get the block that is there at the moment
if (!ignoreList.Contains(bl)) // if the block is not being ignored
{
if (opMats.doorBlocks.Contains(bl)) // if the block is a door_material
{
p.SendBlockchange(pos.x, pos.y, pos.z, ((byte)Block.green)); // turn it green
}
}
}
);
p.SendMessage("Doorview complete.");
}
示例3: Blockchange2
public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
{
p.ClearBlockchange();
byte b = p.level.GetTile(x, y, z);
p.SendBlockchange(x, y, z, b);
CatchPos cpos = (CatchPos)p.blockchangeObject;
unchecked { if (cpos.type != (byte)-1) { type = cpos.type; } }
List<Pos> buffer = new List<Pos>();
switch (cpos.solid)
{
case SolidType.solid:
if (!Server.operators.Contains(p.name))
{
int attemptedLimit = (Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z));
if (attemptedLimit > p.group.CuboidLimit && p.group.CuboidLimit != 0) // Use cuboid limit
{
p.SendMessage("You're trying to unview " + attemptedLimit + " blocks.");
p.SendMessage("Your block limit is " + p.group.CuboidLimit.ToString() + " blocks. Build in stages.");
return;
}
}
buffer.Capacity = Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z);
for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
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)
/*if (p.level.GetTile(xx, yy, zz) != type) {*/
BufferAdd(buffer, xx, yy, zz); //}
break;
}
p.SendMessage("Processing " + buffer.Count.ToString() + " blocks.");
buffer.ForEach(delegate(Pos pos)
{
byte bl = p.level.GetTile(pos.x, pos.y, pos.z); //Get the block that is there at the moment
if (!ignoreList.Contains(bl))// if the block is not being ignored
{
if (opMats.doorBlocks.Contains(bl)) // if the block is a door_material// Saves bandwidth not sending reg_material updates
{
p.SendBlockchange(pos.x, pos.y, pos.z, bl); // Send original texture back to client
}
}
}
);
p.SendMessage("Undoorview complete.");
}
示例4: Blockchange1
public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
{
p.ClearBlockchange();
byte b = p.level.GetTile(x, y, z);
p.SendBlockchange(x, y, z, b);
CatchPos bp = (CatchPos)p.blockchangeObject;
bp.x = x; bp.y = y; bp.z = z; p.blockchangeObject = bp;
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange2);
}
示例5: Blockchange2
public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
{
p.ClearBlockchange();
byte b = p.level.GetTile(x, y, z);
p.SendBlockchange(x, y, z, b);
CatchPos cpos = (CatchPos)p.blockchangeObject;
unchecked { if (cpos.type != (byte)-1) { type = cpos.type; } }
List<Pos> buffer = new List<Pos>();
switch (cpos.solid)
{
case SolidType.solid:
if (!Server.operators.Contains(p.name))
{
int attemptedLimit = Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z);
if (attemptedLimit > p.group.CuboidLimit && p.group.CuboidLimit != 0) //OPERATOR unlock LIMIT, same as cuboid
{
p.SendMessage("You're trying to unlock " + attemptedLimit + " blocks.");
p.SendMessage("Your block limit is " + p.group.CuboidLimit.ToString() + " blocks. Build in stages.");
return;
}
}
buffer.Capacity = Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z);
for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
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)
/*if (p.level.GetTile(xx, yy, zz) != type) {*/
BufferAdd(buffer, xx, yy, zz); //}
break;
}
p.SendMessage("Unlocking " + buffer.Count.ToString() + " blocks.");
// Disable physics before changing the blocks
Physics physicsSetting = p.level.Physics;
p.level.Physics = Physics.Off;
p.level.ClearPhysics();
buffer.ForEach(delegate(Pos pos)
{
byte bl = p.level.GetTile(pos.x, pos.y, pos.z); //Get the block that is there at the moment
if (opMats.opBlocks.Contains(bl)) // if the block is op_material
{
if (!ignoreList.Contains(bl)) // if the block is not being ignored
{
p.level.Blockchange(p, pos.x, pos.y, pos.z, (byte)Block.convertOp(bl)); // send converted reg_material
}
}
});
//p.level.Blockchange(p, pos.x, pos.y, pos.z, (byte)(Block.lavastill));
p.level.Physics = physicsSetting;
p.SendMessage("Unlocking complete.");
}
示例6: Blockchange
public void Blockchange(Player p,ushort x,ushort y,ushort z,byte type)
{
p.ClearBlockchange();
byte b = p.level.GetTile(x,y,z);
if (b != Block.Zero)
{
p.SendBlockchange(x, y, z, b);
string message = "Block (" + x + "," + y + "," + z + "): ";
message += "&f" + b + " = " + Block.Name(b);
p.SendMessage(message + "&e.");
}
else
{
p.SendMessage("Invalid Block(" + x + "," + y + "," + z + ")!");
}
}
示例7: Use
// Code to run when used by a player
public override void Use(Player p, string message)
{
byte type = Block.yellow; // Default value
message = message.ToLower().Trim();
int number = message.Split(' ').Length;
//p.SendMessage("DEBUG /AID: Number = " + number);
if (number < 2)
{
if (number == 1) // Set the block type to what the user wanted
{
type = Block.Byte(message);
if (type == 255)
{
type = Block.yellow;
}
}
if (p.Rank >= GroupEnum.AdvBuilder && !Block.Placable(type) && !Block.AdvPlacable(type))
{
p.SendMessage("You're not allowed to place that block type.");
}
else
{
double x = p.pos[0];
double y = p.pos[1];
double z = p.pos[2];
x = Math.Round((x / 32) - 0.4, MidpointRounding.AwayFromZero);
y = Math.Round((y / 32), MidpointRounding.AwayFromZero) - 3;
z = Math.Round((z / 32) - 0.4, MidpointRounding.AwayFromZero);
Logger.Log("Command /aid debug info. Used by " + p.name, LogType.Debug);
Logger.Log("Player X: " + x, LogType.Debug);
Logger.Log("Player Y: " + y, LogType.Debug);
Logger.Log("Player Z: " + z, LogType.Debug);
p.SendBlockchange((ushort)x, (ushort)y, (ushort)z, (byte)(type)); // take currently held block?
}
}
else
{
Help(p);
}
}
示例8: Blockchange2
public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
{
p.ClearBlockchange();
byte b = p.level.GetTile(x, y, z);
p.SendBlockchange(x, y, z, b);
CatchPos cpos = (CatchPos)p.blockchangeObject;
unchecked { if (cpos.type != (byte)-1) { type = cpos.type; } }
List<Pos> buffer = new List<Pos>();
for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
{
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)
{
if (p.level.GetTile(xx, yy, zz) == type)
{
BufferAdd(buffer, xx, yy, zz);
}
}
}
}
if (buffer.Count > p.group.CuboidLimit && p.group.CuboidLimit != 0)
{
p.SendMessage("You're trying to replace " + buffer.Count.ToString() + " blocks.");
p.SendMessage("Your block limit is " + p.group.CuboidLimit.ToString() + " blocks. Replace in stages.");
return;
}
p.SendMessage(buffer.Count.ToString() + " blocks.");
buffer.ForEach(delegate(Pos pos)
{
p.level.Blockchange(p, pos.x, pos.y, pos.z, cpos.type2); //update block for everyone
});
}
示例9: Blockchange2
public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
{
p.ClearBlockchange();
byte b = p.level.GetTile(x, y, z);
p.SendBlockchange(x, y, z, b);
CatchPos cpos = (CatchPos)p.blockchangeObject;
unchecked { if (cpos.type != (byte)-1) { type = cpos.type; } }
List<Pos> buffer = new List<Pos>();
if (Math.Abs(x - cpos.x) != Math.Abs(z - cpos.z)) { p.SendMessage("No good, make it a circle."); return; }
float CenX = Middle(x , cpos.x);
float CenZ = Middle(z , cpos.z);
float Rad = Math.Abs(CenX - (float)x);
if (Rad != (int)Rad) { p.SendMessage("No good, try a diferent radius."); return; }
switch (cpos.solid)
{
case SolidType.solid:
//for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
// 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)
// if (p.level.GetTile(xx, yy, zz).type != type) { BufferAdd(buffer, xx, yy, zz); }
float error = -Rad;
float varx = Rad;
float varz = 0;
p.SendMessage("Radius " + Rad.ToString());
while (varx >= varz)
{
for (ushort yy = (ushort)(Math.Min(cpos.y, y)); yy <= Math.Max(cpos.y, y); ++yy)
{
BufferAdd(buffer, (ushort)(CenX + varx), yy, (ushort)(CenZ + varz));
BufferAdd(buffer, (ushort)(CenX - varx), yy, (ushort)(CenZ + varz));
BufferAdd(buffer, (ushort)(CenX + varx), yy, (ushort)(CenZ - varz));
BufferAdd(buffer, (ushort)(CenX - varx), yy, (ushort)(CenZ - varz));
BufferAdd(buffer, (ushort)(CenX + varz), yy, (ushort)(CenZ + varx));
BufferAdd(buffer, (ushort)(CenX - varz), yy, (ushort)(CenZ + varx));
BufferAdd(buffer, (ushort)(CenX + varz), yy, (ushort)(CenZ - varx));
BufferAdd(buffer, (ushort)(CenX - varz), yy, (ushort)(CenZ - varx));
}
error += varz;
++varz;
error += varz;
// The following test may be implemented in assembly language in
// most machines by testing the carry flag after adding 'y' to
// the value of 'error' in the previous step, since 'error'
// nominally has a negative value.
if (error >= 0)
{
--varx;
error -= varx;
error -= varx;
}
}
break;
case SolidType.hollow:
p.SendMessage("Not implemented yet.");
return;
}
if (!Server.operators.Contains(p.name))
{
if (buffer.Count > 800)
{
p.SendMessage("Too many blocks, build in stages.");
return;
}
}
else if (buffer.Count > 20000)
{
p.SendMessage("That is a bad idea.");
return;
}
p.SendMessage(buffer.Count.ToString() + " blocks.");
buffer.ForEach(delegate(Pos pos)
{
p.level.Blockchange(p, pos.x, pos.y, pos.z, type); //update block for everyone
});
}
示例10: Blockchange2
// Get the second position
public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
{
p.ClearBlockchange();
byte b = p.level.GetTile(x, y, z);
p.SendBlockchange(x, y, z, b);
CatchPos cpos = (CatchPos)p.blockchangeObject;
unchecked { if (cpos.type != (byte)-1) { type = cpos.type; } }
byte[,,] blockBuffer;
ushort lowX = Math.Min(cpos.x, x);
ushort lowY = Math.Min(cpos.y, y);
ushort lowZ = Math.Min(cpos.z, z);
ushort highX = Math.Max(cpos.x, x);
ushort highY = Math.Max(cpos.y, y);
ushort highZ = Math.Max(cpos.z, z);
ushort dimX = (ushort)Math.Abs(cpos.x - x);
ushort dimY = (ushort)Math.Abs(cpos.y - y);
ushort dimZ = (ushort)Math.Abs(cpos.z - z);
dimX++;
dimY++;
dimZ++;
Level copyLevel = p.level;
// Now that we have the positions, check the size
// If it's too big, cancel
if (dimX * dimY * dimZ <= p.group.CuboidLimit || p.group.CuboidLimit == 0)
{
try
{
// Resize the buffer
blockBuffer = new byte[highX - lowX + 1, highY - lowY + 1, highZ - lowZ + 1];
// Let the player know we're copying blocks now
p.SendMessage("Copying " + blockBuffer.Length + " blocks.");
// Add the tiles to a temporary buffer
for (ushort xx = lowX; xx <= highX; ++xx)
{
for (ushort yy = lowY; yy <= highY; ++yy)
{
for (ushort zz = lowZ; zz <= highZ; ++zz)
{
blockBuffer[xx - lowX, yy - lowY, zz - lowZ] = copyLevel.GetTile(xx, yy, zz);
}
}
}
// Replace the players buffer
p.copyBuffer.SetBuffer(blockBuffer, dimX, dimY, dimZ);
p.SendMessage("The block copy was successful!");
}
catch (Exception e)
{
Logger.Log("Error copying blocks for " + p.name, LogType.Error);
Logger.Log(e.Message, LogType.ErrorMessage);
p.SendMessage("There was an error doing /copy!");
}
}
else
{
p.SendMessage("You're trying to copy " + dimX * dimY * dimZ + " blocks.");
p.SendMessage("Your block limit is " + p.group.CuboidLimit.ToString() + " blocks. Copy in stages.");
}
}
示例11: Blockchange2
// Second block change (defining second corner)
public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
{
p.ClearBlockchange();
byte b = p.level.GetTile(x, y, z);
p.SendBlockchange(x, y, z, b);
CatchPos cpos = (CatchPos) p.blockchangeObject;
unchecked { if (cpos.type != (byte) -1) { type = cpos.type; } }
List<Pos> buffer = new List<Pos>();
// Solid is default
switch (cpos.solid)
{
case SolidType.solid:
// redundant?
if (Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z) > p.group.CuboidLimit && p.group.CuboidLimit != 0)
{
p.SendMessage("You're trying to place " + buffer.Count.ToString() + " blocks.");
p.SendMessage("Your block limit is " + p.group.CuboidLimit.ToString() + " blocks. Build in stages.");
return;
}
// end redundant?
buffer.Capacity = Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z);
// Nested for loops to cover a solid cube
for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
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)
if (p.level.GetTile(xx, yy, zz) != type) { BufferAdd(buffer, xx, yy, zz); }
break;
case SolidType.hollow:
// TODO: Work out if theres 800 blocks used before making the buffer
// Hollow will build only the outer shell of a cube leaving the center alone
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)
{
if (p.level.GetTile(cpos.x, yy, zz) != type) { BufferAdd(buffer, cpos.x, yy, zz); }
if (cpos.x != x) { if (p.level.GetTile(x, yy, zz) != type) { BufferAdd(buffer, x, yy, zz); } }
}
if (Math.Abs(cpos.x - x) >= 2)
{
for (ushort xx = (ushort) (Math.Min(cpos.x, x) + 1); xx <= Math.Max(cpos.x, x) - 1; ++xx)
for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
{
if (p.level.GetTile(xx, cpos.y, zz) != type) { BufferAdd(buffer, xx, cpos.y, zz); }
if (cpos.y != y) { if (p.level.GetTile(xx, y, zz) != type) { BufferAdd(buffer, xx, y, zz); } }
}
if (Math.Abs(cpos.y - y) >= 2)
{
for (ushort xx = (ushort) (Math.Min(cpos.x, x) + 1); xx <= Math.Max(cpos.x, x) - 1; ++xx)
for (ushort yy = (ushort) (Math.Min(cpos.y, y) + 1); yy <= Math.Max(cpos.y, y) - 1; ++yy)
{
if (p.level.GetTile(xx, yy, cpos.z) != type) { BufferAdd(buffer, xx, yy, cpos.z); }
if (cpos.z != z) { if (p.level.GetTile(xx, yy, z) != type) { BufferAdd(buffer, xx, yy, z); } }
}
}
}
break;
// Walls builds only the surrounding vertical borders of a cube
case SolidType.walls:
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)
{
if (p.level.GetTile(cpos.x, yy, zz) != type) { BufferAdd(buffer, cpos.x, yy, zz); }
if (cpos.x != x) { if (p.level.GetTile(x, yy, zz) != type) { BufferAdd(buffer, x, yy, zz); } }
}
if (Math.Abs(cpos.x - x) >= 2)
{
if (Math.Abs(cpos.z - z) >= 2)
{
for (ushort xx = (ushort) (Math.Min(cpos.x, x) + 1); xx <= Math.Max(cpos.x, x) - 1; ++xx)
for (ushort yy = (ushort) (Math.Min(cpos.y, y)); yy <= Math.Max(cpos.y, y); ++yy)
{
if (p.level.GetTile(xx, yy, cpos.z) != type) { BufferAdd(buffer, xx, yy, cpos.z); }
if (cpos.z != z) { if (p.level.GetTile(xx, yy, z) != type) { BufferAdd(buffer, xx, yy, z); } }
}
}
}
break;
}
// Why are we running this in the solid case statement as well?
if (buffer.Count > p.group.CuboidLimit && p.group.CuboidLimit != 0)
{
p.SendMessage("You're trying to place " + buffer.Count.ToString() + " blocks.");
p.SendMessage("Your block limit is " + p.group.CuboidLimit.ToString() + " blocks. Build in stages.");
return;
}
p.SendMessage(buffer.Count.ToString() + " blocks.");
// This code may not be needed. We already check whether the player can place the block near the top of this class
if (!Server.advbuilders.Contains(p.name))
{
buffer.ForEach(delegate(Pos pos)
//.........这里部分代码省略.........
示例12: Blockchange1
// Grab the first position
public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
{
p.ClearBlockchange();
byte b = p.level.GetTile(x, y, z);
p.SendBlockchange(x, y, z, b);
byte[,,] blockBuffer;
int tempX = Math.Abs(p.copyBuffer.DimX + x - 1);
int tempY = Math.Abs(p.copyBuffer.DimY + y - 1);
int tempZ = Math.Abs(p.copyBuffer.DimZ + z - 1); ;
ushort x2 = (tempX > p.level.width - 1) ? (ushort)(p.level.width - 1) : (ushort)tempX;
ushort y2 = (tempY > p.level.depth - 1) ? (ushort)(p.level.depth - 1) : (ushort)tempY;
ushort z2 = (tempZ > p.level.height - 1) ? (ushort)(p.level.height - 1) : (ushort)tempZ;
ushort dimX = (ushort)Math.Abs(x - x2);
ushort dimY = (ushort)Math.Abs(y - y2);
ushort dimZ = (ushort)Math.Abs(z - z2);
dimX++;
dimY++;
dimZ++;
BlockPos pos1, pos2;
pos1.x = x;
pos1.y = y;
pos1.z = z;
pos2.x = x2;
pos2.y = y2;
pos2.z = z2;
try
{
// Resize the buffer for undo
blockBuffer = new byte[Math.Abs(x - x2) + 1, Math.Abs(y - y2) + 1, Math.Abs(z - z2) + 1];
// Store where we're copying to the undo buffer
for (ushort xx = Math.Min(x, x2); xx <= Math.Max(x, x2); ++xx)
{
for (ushort yy = Math.Min(y, y2); yy <= Math.Max(y, y2); ++yy)
{
for (ushort zz = Math.Min(z, z2); zz <= Math.Max(z, z2); ++zz)
{
blockBuffer[xx - x, yy - y, zz - z] = p.level.GetTile(xx, yy, zz);
}
}
}
// Move the blocks to the undo buffer
p.undoPasteBuffer.SetBuffer(blockBuffer, dimX, dimY, dimZ, pos1, pos2, p.level.name);
// Do the block changes
for (ushort xx = Math.Min(x, x2); xx <= Math.Max(x, x2); ++xx)
{
for (ushort yy = Math.Min(y, y2); yy <= Math.Max(y, y2); ++yy)
{
for (ushort zz = Math.Min(z, z2); zz <= Math.Max(z, z2); ++zz)
{
p.level.Blockchange(p, xx, yy, zz, p.copyBuffer.GetTile((ushort)(xx - x), (ushort)(yy - y), (ushort)(zz - z))); // Make the change for everyone
}
}
}
}
catch
{
p.SendMessage("There was an error during /paste! Use /undoLastPaste to undo the damage.");
}
}