Пример #1
0
 internal static void SendLevelCustomBlocks(Player pl)
 {
     BlockDefinition[] defs = pl.level.CustomBlockDefs;
     for (int i = 0; i < defs.Length; i++)
     {
         BlockDefinition def = defs[i];
         if (def != null)
         {
             pl.Send(def.MakeDefinePacket(pl));
         }
     }
 }
Пример #2
0
 internal static void SendLevelCustomBlocks(Player pl)
 {
     BlockDefinition[] defs = pl.level.CustomBlockDefs;
     for (int i = 0; i < defs.Length; i++)
     {
         BlockDefinition def = defs[i];
         if (def == null || def.RawID > pl.MaxRawBlock)
         {
             continue;
         }
         pl.Send(def.MakeDefinePacket(pl));
     }
 }
Пример #3
0
        public static void Add(BlockDefinition def, BlockDefinition[] defs, Level level)
        {
            byte raw    = def.BlockID;
            bool global = defs == GlobalDefs;

            if (global)
            {
                UpdateGlobalCustom(raw, def);
            }

            defs[raw] = def;
            if (global)
            {
                Block.SetDefaultNames();
            }
            if (!global)
            {
                level.UpdateCustomBlock(raw, def);
            }

            Player[] players = PlayerInfo.Online.Items;
            foreach (Player pl in players)
            {
                if (!global && pl.level != level)
                {
                    continue;
                }
                if (!pl.hasBlockDefs)
                {
                    continue;
                }
                if (global && pl.level.CustomBlockDefs[raw] != GlobalDefs[raw])
                {
                    continue;
                }

                pl.Send(def.MakeDefinePacket(pl));
                if (pl.Supports(CpeExt.BlockPermissions))
                {
                    pl.Send(Packet.BlockPermission(def.BlockID, pl.level.CanPlace, pl.level.CanDelete));
                }
            }
            Save(global, level);
        }
Пример #4
0
        public static void Add(BlockDefinition def, BlockDefinition[] defs, Level level)
        {
            BlockID block  = def.GetBlock();
            bool    global = defs == GlobalDefs;

            if (global)
            {
                UpdateGlobalCustom(block, def);
            }

            defs[block] = def;
            if (global)
            {
                Block.SetDefaultNames();
            }
            if (!global)
            {
                level.UpdateCustomBlock(block, def);
            }

            Player[] players = PlayerInfo.Online.Items;
            foreach (Player pl in players)
            {
                if (!global && pl.level != level)
                {
                    continue;
                }
                if (!pl.hasBlockDefs || def.RawID > pl.MaxRawBlock)
                {
                    continue;
                }
                if (global && pl.level.CustomBlockDefs[block] != GlobalDefs[block])
                {
                    continue;
                }

                pl.Send(def.MakeDefinePacket(pl));
                pl.SendCurrentBlockPermissions();
            }
            Save(global, level);
        }