GetFallbackBlock() 공개 정적인 메소드

public static GetFallbackBlock ( Block block ) : Block
block Block
리턴 Block
예제 #1
0
 // For non-extended players, use appropriate substitution
 public void ProcessOutgoingSetBlock(ref Packet packet)
 {
     if (packet.Data[7] > (byte)Map.MaxLegalBlockType && !UsesCustomBlocks)
     {
         packet.Data[7] = (byte)Map.GetFallbackBlock((Block)packet.Data[7]);
     }
 }
예제 #2
0
        // Applies pending updates and sends them to players (if applicable).
        internal void ProcessUpdates()
        {
            if (World == null)
            {
                throw new InvalidOperationException("Map must be assigned to a world to process updates.");
            }

            if (World.IsLocked)
            {
                if (World.IsPendingMapUnload)
                {
                    World.UnloadMap(true);
                }
                return;
            }

            int  packetsSent         = 0;
            bool canFlush            = false;
            int  maxPacketsPerUpdate = Server.CalculateMaxPacketsPerUpdate(World);

            while (packetsSent < maxPacketsPerUpdate)
            {
                BlockUpdate update;
                if (!updates.TryDequeue(out update))
                {
                    if (World.IsFlushing)
                    {
                        canFlush = true;
                    }
                    break;
                }
                if (!InBounds(update.X, update.Y, update.Z))
                {
                    continue;
                }
                int blockIndex = Index(update.X, update.Y, update.Z);
                Blocks[blockIndex] = (byte)update.BlockType;

                if (!World.IsFlushing)
                {
                    //non classicube players get fallbacks instead of the real blocks
                    Packet packet  = PacketWriter.MakeSetBlock(update.X, update.Y, update.Z, update.BlockType);
                    Packet packet2 = PacketWriter.MakeSetBlock(update.X, update.Y, update.Z, Map.GetFallbackBlock(update.BlockType));

                    World.Players.Where(p => p.usesCPE).SendLowPriority(update.Origin, packet);
                    World.Players.Where(p => !p.usesCPE).SendLowPriority(update.Origin, packet2);
                }
                packetsSent++;
            }

            if (drawOps.Count > 0)
            {
                lock ( drawOpLock ) {
                    if (drawOps.Count > 0)
                    {
                        packetsSent += ProcessDrawOps(maxPacketsPerUpdate - packetsSent);
                    }
                }
            }
            else if (canFlush)
            {
                World.EndFlushMapBuffer();
            }

            if (packetsSent == 0 && World.IsPendingMapUnload)
            {
                World.UnloadMap(true);
            }
        }