本文整理汇总了C#中MCForge.Entity.Player.SendBlockChange方法的典型用法代码示例。如果您正苦于以下问题:C# Player.SendBlockChange方法的具体用法?C# Player.SendBlockChange怎么用?C# Player.SendBlockChange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCForge.Entity.Player
的用法示例。
在下文中一共展示了Player.SendBlockChange方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CatchBlock
//public void CatchBlock(Player p, ushort x, ushort z, ushort y, byte NewType, bool placed, object DataPass)
public void CatchBlock(Player sender, BlockChangeEventArgs args) {
args.Cancel();
args.Unregister();
sender.SendBlockChange(args.X, args.Z, args.Y, sender.Level.GetBlock(args.X, args.Z, args.Y));
CatchPos cpos = (CatchPos)sender.GetDatapass("CmdMeasure_cpos");
cpos.FirstBlock = new Vector3S(args.X, args.Z, args.Y);
sender.SetDatapass("CmdMeasure_cpos", cpos);
sender.OnPlayerBlockChange.Normal += new BlockChangeEvent.EventHandler(CatchBlock2);
//p.CatchNextBlockchange(new Player.BlockChangeDelegate(CatchBlock2), (object)cpos);
}
示例2: CatchBlock2
//public void CatchBlock2(Player p, ushort x, ushort z, ushort y, byte NewType, bool placed, object DataPass)
public void CatchBlock2(Player sender, BlockChangeEventArgs args) {
args.Cancel();
args.Unregister();
sender.SendBlockChange(args.X, args.Z, args.Y, sender.Level.GetBlock(args.X, args.Z, args.Y));
CatchPos cpos = (CatchPos)sender.GetDatapass("CmdMeasure_cpos");
Vector3S FirstBlock = cpos.FirstBlock;
ushort xx, zz, yy;
int count = 0;
for (xx = Math.Min((ushort)(FirstBlock.x), args.X); xx <= Math.Max((ushort)(FirstBlock.x), args.X); ++xx)
for (zz = Math.Min((ushort)(FirstBlock.z), args.Z); zz <= Math.Max((ushort)(FirstBlock.z), args.Z); ++zz)
for (yy = Math.Min((ushort)(FirstBlock.y), args.Y); yy <= Math.Max((ushort)(FirstBlock.y), args.Y); ++yy) {
if (cpos.ignore == null || !cpos.ignore.Contains(sender.Level.GetBlock(xx, zz, yy))) {
count++;
}
}
sender.SendMessage(count + " blocks are between (" + FirstBlock.x + ", " + FirstBlock.z + ", " + FirstBlock.y + ") and (" + args.X + ", " + args.Z + ", " + args.Y + ")");
}
示例3: BlockChange
void BlockChange(Player sender, BlockChangeEventArgs e) {
e.Cancel();
var raw = (BrushData)sender.ExtraData.GetIfExist<object, object> ("BrushData");
if(raw == null){
sender.SendMessage("An error occurred while trying to brush");
sender.OnPlayerBlockChange.Normal -= BlockChange;
return;
}
byte block = raw.Block != 255 ? raw.Block : e.Holding;
Vector3S loc = new Vector3S(e.X, e.Z, e.Y);
IBrush b = (IBrush)Activator.CreateInstance(raw.BrushType);
var qq = b.Draw(loc, raw.Block, raw.Size);
if (sender.Group.MaxBlockChange < qq.Count()) {
sender.SendMessage("You cannot set that many blocks");
return;
}
foreach (var fml in qq)
sender.SendBlockChange((ushort)fml.x, (ushort)fml.z, (ushort)fml.y, block);
#if DEBUG
sender.SendMessage(string.Format("Brushed {0} blocks", qq.Count()));
#endif
}
示例4: BlockChange
/// <summary>
/// Causes a block change for the level
/// </summary>
/// <param name="x">Location of x</param>
/// <param name="z">Location of z</param>
/// <param name="y">Location of y</param>
/// <param name="block">Block to set</param>
/// <param name="p">A player who doesn't need the update.</param>
/// <param name="blockqueue">Should this blockchange be queued by BlockQueue?</param>
public void BlockChange(ushort x, ushort z, ushort y, byte block, Player p = null, bool blockqueue = false)
{
if (blockqueue)
{
BlockQueue.Addblock(p, x, y, z, block);
}
if (!IsInBounds(x, z, y) || y == CWMap.Size.z)
{
Logger.Log("Blockchange((ushort) " + x + ", (ushort)" + z + ", (ushort) " + y + ", (byte) " + block + ", (Player) " + p + ") is outside of level");
return;
}
byte currentType = GetBlock(x, z, y);
if (block == 0)
{
pblocks.ForEach(pb =>
{
if (pb.X == x && pb.Y == y && pb.Z == z)
{
pblocks.Remove(pb);
return;
}
});
}
if (block == currentType) return;
if (p != null)
{
byte blockFrom = GetBlock(x, z, y);
BlockChangeHistory.Add(p.Level.Name, (uint)p.UID, x, z, y, block);
}
SetBlock(x, z, y, block);
if (p == null)
Player.GlobalBlockchange(this, x, z, y, block);
else
{
p.SendBlockchangeToOthers(this, x, z, y, block);
p.SendBlockChange(x, z, y, block);
}
if ((Block)block is PhysicsBlock)
{
PhysicsBlock pb = (PhysicsBlock)((PhysicsBlock)block).Clone();
pb.X = x;
pb.Y = y;
pb.Z = z;
pblocks.Add(pb);
}
//TODO Special stuff for block changing
}
示例5: Curse
void Curse(Player sender) {
if (sender.ExtraData["cursorlocked"] != null && (bool)sender.ExtraData["cursorlocked"]) return;
lock (this) {
sender.ExtraData["cursorlocked"] = true;
if (sender.ExtraData["Cursor"] != null) {
Vector3S old;
if (sender.ExtraData["Cursor"].GetType() == typeof(Vector3S))
old = (Vector3S)sender.ExtraData["Cursor"];
else {
old = new Vector3S();
old.FromString((string)sender.ExtraData["Cursor"]);
}
sender.SendBlockChange((ushort)old.x, (ushort)old.z, (ushort)old.y, sender.Level.GetBlock(old));
}
Vector3S cursor = sender.GetBlockFromView();
if ((object)cursor != null) {
sender.SendBlockChange((ushort)cursor.x, (ushort)cursor.z, (ushort)cursor.y, 21);
}
sender.ExtraData["Cursor"] = cursor;
sender.ExtraData["cursorlocked"] = false;
}
}
示例6: MoveGlass
void MoveGlass(Player sender) {
if (sender.ExtraData["cursormoveglasslocked"] != null && (bool)sender.ExtraData["cursormoveglasslocked"]) return;
lock (this) {
sender.ExtraData["cursormovelocked"] = true;
if (sender.ExtraData["CursorGlassCenter"] != null) {
Vector3S old;
if (sender.ExtraData["CursorGlassCenter"].GetType() == typeof(Vector3S))
old = (Vector3S)sender.ExtraData["CursorGlassCenter"];
else {
old = new Vector3S();
old.FromString((string)sender.ExtraData["CursorGlassCenter"]);
}
sender.ResendBlockChange(surrounder, old);
}
Vector3S pos = new Vector3S((ushort)(sender.Pos.x / 32), (ushort)(sender.Pos.z / 32), (ushort)(sender.Pos.y / 32));
sender.SendBlockChange(surrounder, pos, 20);
sender.ExtraData["CursorGlassCenter"] = pos;
sender.ExtraData["cursormoveglasslocked"] = false;
}
}
示例7: Use
public void Use(Player p, string[] args)
{
p.ExtraData.CreateIfNotExist("IsFlying", false);
p.ExtraData["IsFlying"] = !(bool)p.ExtraData["IsFlying"];
if (!(bool)p.ExtraData["IsFlying"])
{
return;
}
p.SendMessage("You are now flying. &cJump!");
Thread fly = new Thread(new ThreadStart(delegate
{
Vector3 pos;
Vector3 oldpos = new Vector3();
List<Vector3> buffer = new List<Vector3>();
while ((bool)p.ExtraData["IsFlying"])
{
Thread.Sleep(20);
if (p.Pos.x == oldpos.x && p.Pos.z == oldpos.z && p.Pos.y == oldpos.y) continue;
try
{
List<Vector3> tempBuffer = new List<Vector3>();
List<Vector3> toRemove = new List<Vector3>();
ushort x = (ushort)((p.Pos.x) / 32);
ushort z = (ushort)((p.Pos.z) / 32);
ushort y = (ushort)((p.Pos.y - 60) / 32);
try
{
for (ushort xx = (ushort)(x - 1); xx <= x + 1; xx++)
{
for (ushort yy = (ushort)(y - 1); yy <= y; yy++)
{
for (ushort zz = (ushort)(z - 1); zz <= z + 1; zz++)
{
if (p.Level.GetBlock(xx, zz, yy) == Block.BlockList.AIR)
{
pos.x = (short)xx; pos.y = (short)yy; pos.z = (short)zz;
tempBuffer.Add(pos);
}
}
}
}
foreach (Vector3 cP in tempBuffer)
{
if (!buffer.Contains(cP))
{
buffer.Add(cP);
p.SendBlockChange((ushort)cP.x, (ushort)cP.z, (ushort)cP.y, Block.BlockList.GLASS);
}
}
foreach (Vector3 cP in buffer)
{
if (!tempBuffer.Contains(cP))
{
p.SendBlockChange((ushort)cP.x, (ushort)cP.z, (ushort)cP.y, Block.BlockList.AIR);
toRemove.Add(cP);
}
}
foreach (Vector3 cP in toRemove)
{
buffer.Remove(cP);
}
tempBuffer.Clear();
toRemove.Clear();
}
catch { }
}
catch { }
//
//p.Pos.CopyTo(oldpos, 0);
}
foreach (Vector3 cP in buffer)
{
p.SendBlockChange((ushort)cP.x, (ushort)cP.z, (ushort)cP.y, 0); //Air
}
p.SendMessage("Stopped flying");
}));
fly.Start();
}