protected bool DrawOneBlock() { BlocksProcessed++; if (!Map.InBounds(Coords)) { BlocksSkipped++; return(false); } #if DEBUG_CHECK_DUPLICATE_COORDS TestForDuplicateModification(); #endif Block newBlock = Brush.NextBlock(this); if (newBlock == Block.Undefined) { return(false); } int blockIndex = Map.Index(Coords); Block oldBlock = (Block)Map.Blocks[blockIndex]; if (oldBlock == newBlock) { BlocksSkipped++; return(false); } if (Player.CanPlace(Map, Coords, newBlock, Context) != CanPlaceResult.Allowed) { BlocksDenied++; return(false); } Map.Blocks[blockIndex] = (byte)newBlock; World world = Map.World; if (world != null && !world.IsFlushing) { world.Players.SendLowPriority(PacketWriter.MakeSetBlock(Coords, newBlock)); } Player.RaisePlayerPlacedBlockEvent(Player, Map, Coords, oldBlock, newBlock, Context); if (!UndoState.IsTooLargeToUndo) { if (!UndoState.Add(Coords, oldBlock)) { Player.LastDrawOp = null; Player.Message("{0}: Too many blocks to undo.", Description); } } BlocksUpdated++; return(true); }
private static void PlayerMoving(object sender, PlayerMovingEventArgs e) { if (_world != null && e.Player.World == _world) { if (_world.gameMode == GameMode.MineField && !Failed.Contains(e.Player)) { if (e.NewPosition != null) { Vector3I oldPos = new Vector3I(e.OldPosition.X / 32, e.OldPosition.Y / 32, e.OldPosition.Z / 32); Vector3I newPos = new Vector3I(e.NewPosition.X / 32, e.NewPosition.Y / 32, e.NewPosition.Z / 32); if (oldPos.X != newPos.X || oldPos.Y != newPos.Y || oldPos.Z != newPos.Z) { if (!_map.InBounds(newPos)) { e.Player.TeleportTo(_map.Spawn); newPos = (Vector3I)_map.Spawn; } // Check if the player jumped, flew, whatevers if (newPos.Z > _ground + 2) { e.Player.TeleportTo(e.OldPosition); newPos = oldPos; } foreach (Vector3I pos in Mines.Values) { if (newPos == new Vector3I(pos.X, pos.Y, pos.Z + 2) || newPos == new Vector3I(pos.X, pos.Y, pos.Z + 1) || newPos == new Vector3I(pos.X, pos.Y, pos.Z)) { _world.Map.QueueUpdate(new BlockUpdate(null, pos, Block.TNT)); _world.AddPhysicsTask(new TNTTask(_world, pos, null, true, false), 0); Vector3I removed; Mines.TryRemove(pos.ToString(), out removed); } } if (_map.GetBlock(newPos.X, newPos.Y, newPos.Z - 2) == Block.Green && !_stopped) { _stopped = true; Stop(e.Player, true); } } } } } }