예제 #1
0
        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);
        }
예제 #2
0
 static void SealLiquids(Map map, byte sealantType)
 {
     for (int x = 1; x < map.Width - 1; x++)
     {
         for (int z = 1; z < map.Height; z++)
         {
             for (int y = 1; y < map.Length - 1; y++)
             {
                 int index = map.Index(x, y, z);
                 if ((map.Blocks[index] == 10 || map.Blocks[index] == 11 || map.Blocks[index] == 8 || map.Blocks[index] == 9) &&
                     (map.GetBlock(x - 1, y, z) == Block.Air || map.GetBlock(x + 1, y, z) == Block.Air ||
                      map.GetBlock(x, y - 1, z) == Block.Air || map.GetBlock(x, y + 1, z) == Block.Air ||
                      map.GetBlock(x, y, z - 1) == Block.Air))
                 {
                     map.Blocks[index] = sealantType;
                 }
             }
         }
     }
 }