public void CatchBlock2(OnPlayerBlockChange opbc) { CatchPos FirstBlock = (CatchPos)opbc.datapass; List<Pos> buffer = new List<Pos>(); for (ushort xx = Math.Min((ushort)(FirstBlock.pos.x), opbc.x); xx <= Math.Max((ushort)(FirstBlock.pos.x), opbc.x); ++xx) { for (ushort zz = Math.Min((ushort)(FirstBlock.pos.z), opbc.z); zz <= Math.Max((ushort)(FirstBlock.pos.z), opbc.z); ++zz) { for (ushort yy = Math.Min((ushort)(FirstBlock.pos.y), opbc.y); yy <= Math.Max((ushort)(FirstBlock.pos.y), opbc.y); ++yy) { Vector3 loop = new Vector3(xx, zz, yy); if (opbc.Player.Level.GetBlock(loop) != FirstBlock.type) { BufferAdd(buffer, loop); } } } } //Group Max Blocks permissions here opbc.Player.SendMessage(buffer.Count.ToString() + " blocks."); //Level Blockqueue .-. buffer.ForEach(delegate(Pos pos) { opbc.Player.Level.BlockChange((ushort)(pos.pos.x), (ushort)(pos.pos.z), (ushort)(pos.pos.y), FirstBlock.type2); }); }
public void CatchBlock(OnPlayerBlockChange args) { CatchPos cpos = (CatchPos)args.datapass; cpos.pos = new Vector3(args.x, args.z, args.y); args.Cancel(); args.Unregister(); OnPlayerBlockChange.Register(CatchBlock2, args.Player, cpos); }
//public void CatchBlock(Player p, ushort x, ushort z, ushort y, byte NewType, bool placed, object DataPass) public void CatchBlock(OnPlayerBlockChange opbc) { CatchPos cpos = (CatchPos)opbc.datapass; cpos.pos = new Vector3(opbc.x, opbc.z, opbc.y); opbc.Unregister(); OnPlayerBlockChange.Register(CatchBlock2, opbc.Player, cpos); //p.CatchNextBlockchange(CatchBlock2, (object)cpos); }
//public void CatchBlock(Player p, ushort x, ushort z, ushort y, byte NewType, bool placed, object DataPass) public void CatchBlock(OnPlayerBlockChange args) { args.Cancel(); args.Unregister(); args.Player.SendBlockChange(args.x, args.z, args.y, args.Player.Level.GetBlock(args.x, args.z, args.y)); CatchPos cpos = (CatchPos)args.datapass; cpos.FirstBlock = new Vector3(args.x, args.z, args.y); OnPlayerBlockChange.Register(CatchBlock2, args.Player, cpos); //p.CatchNextBlockchange(new Player.BlockChangeDelegate(CatchBlock2), (object)cpos); }
//public void CatchBlock2(Player p, ushort x, ushort z, ushort y, byte NewType, bool placed, object DataPass) public void CatchBlock2(OnPlayerBlockChange args) { args.Cancel(); args.Unregister(); args.Player.SendBlockChange(args.x, args.z, args.y, args.Player.Level.GetBlock(args.x, args.z, args.y)); CatchPos cpos = (CatchPos)args.datapass; Vector3 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(args.Player.Level.GetBlock(xx, zz, yy))) { count++; } } args.Player.SendMessage(count + " blocks are between (" + FirstBlock.x + ", " + FirstBlock.z + ", " + FirstBlock.y + ") and (" + args.x + ", " + args.z + ", " + args.y + ")"); }
public void CatchBlock2(OnPlayerBlockChange args) { CatchPos cpos = (CatchPos)args.datapass; Cuboid(cpos, args.holding, args.Player, args.x, args.y, args.z); args.Cancel(); args.Unregister(); }
/// <summary> /// Unregisters the specific event /// </summary> /// <param name="pe">The event to unregister</param> public static void Unregister(OnPlayerBlockChange pe) { pe.Unregister(); }
/// <summary> /// Used to register a method to be executed when the event is fired. /// </summary> /// <param name="callback">The method to call</param> /// <param name="target">The player to watch for. (null for any players)</param> /// <param name="datapass">The data to return when this event fires.</param> /// <returns></returns> public static OnPlayerBlockChange Register(OnCall callback, Player target, object datapass) { Logger.Log("OnPlayerBlockChange registered to the method " + callback.Method.Name, LogType.Debug); //We add it to the list here OnPlayerBlockChange pe = _eventQueue.Find(match => (match.Player == null ? target == null : target != null && target.Username == match.Player.Username)); if (pe != null) //It already exists, so we just add it to the queue. pe._queue += callback; else { //Doesn't exist yet. Make a new one. pe = new OnPlayerBlockChange(callback, target, datapass); _eventQueue.Add(pe); } return pe; }