Example #1
0
        internal static void SendLevelCustomBlocks(Player pl)
        {
            BlockDefinition[] defs = pl.level.CustomBlockDefs;
            for (int i = 1; i < defs.Length; i++)
            {
                BlockDefinition def = defs[i];
                if (def == null)
                {
                    continue;
                }
                if (pl.HasCpeExt(CpeExt.BlockDefinitionsExt, 2) && def.Shape != 0)
                {
                    SendDefineBlockExt(pl, def, true);
                }
                else if (pl.HasCpeExt(CpeExt.BlockDefinitionsExt) && def.Shape != 0)
                {
                    SendDefineBlockExt(pl, def, false);
                }
                else
                {
                    SendDefineBlock(pl, def);
                }

                if (pl.HasCpeExt(CpeExt.BlockPermissions))
                {
                    pl.SendSetBlockPermission(def.BlockID, pl.level.CanPlace, pl.level.CanDelete);
                }
            }
        }
Example #2
0
 internal static string GetSupportedCol(Player dst, string col)
 {
     if (col == null)
     {
         return(null);
     }
     if (col.Length >= 2 && !Colors.IsStandardColor(col[1]) && !dst.HasCpeExt(CpeExt.TextColors))
     {
         col = "&" + Colors.GetFallback(col[1]);
     }
     return(col);
 }
Example #3
0
        internal static void Spawn(Player dst, Player p, byte id, ushort x, ushort y, ushort z,
                                   byte rotx, byte roty, string possession = "")
        {
            if (!Server.zombie.Running || !p.Game.Infected)
            {
                string col = p.color;
                if (col.Length >= 2 && !Colors.IsStandardColor(col[1]) && !dst.HasCpeExt(CpeExt.TextColors))
                {
                    col = "&" + Colors.GetFallback(col[1]);
                }
                string group = p.Game.Referee ? "&2Referees" : "&fPlayers";

                if (dst.hasExtList)
                {
                    dst.SendExtAddEntity2(id, p.skinName, col + p.truename + possession, x, y, z, rotx, roty);
                    dst.SendExtAddPlayerName(id, p.skinName, col + p.truename, group, 0);
                }
                else
                {
                    dst.SendSpawn(id, col + p.truename + possession, x, y, z, rotx, roty);
                }
                return;
            }

            string name = p.truename, skinName = p.skinName;

            if (ZombieGame.ZombieName != "" && !dst.Game.Aka)
            {
                name = ZombieGame.ZombieName; skinName = name;
            }

            if (dst.hasExtList)
            {
                dst.SendExtAddEntity2(id, skinName, Colors.red + name + possession, x, y, z, rotx, roty);
                dst.SendExtAddPlayerName(id, skinName, Colors.red + name, "&cZombies", 0);
            }
            else
            {
                dst.SendSpawn(id, Colors.red + name + possession, x, y, z, rotx, roty);
            }

            if (dst.hasChangeModel && id != 0xFF)
            {
                dst.SendChangeModel(id, ZombieGame.ZombieModel);
            }
        }
Example #4
0
        public static byte[] Motd(Player p, string motd)
        {
            byte[] buffer = new byte[131];
            buffer[0] = Opcode.Handshake;
            buffer[1] = Server.version;

            bool cp437 = p.HasCpeExt(CpeExt.FullCP437);

            if (motd.Length > 64)
            {
                NetUtils.Write(motd, buffer, 2, cp437);
                NetUtils.Write(motd.Substring(64), buffer, 66, cp437);
            }
            else
            {
                NetUtils.Write(Server.name, buffer, 2, cp437);
                NetUtils.Write(motd, buffer, 66, cp437);
            }

            buffer[130] = Block.canPlace(p, Block.blackrock) ? (byte)100 : (byte)0;
            return(buffer);
        }
Example #5
0
 byte[] MakePacket(Player p, ref byte[] bulk, ref byte[] normal,
                   ref byte[] noBlockDefs, ref byte[] original)
 {
     // Different clients support varying types of blocks
     if (p.HasCpeExt(CpeExt.BulkBlockUpdate) && p.hasCustomBlocks && p.hasBlockDefs && count >= 160)
     {
         if (bulk == null)
         {
             bulk = MakeBulk();
         }
         return(bulk);
     }
     else if (p.hasCustomBlocks && p.hasBlockDefs)
     {
         if (normal == null)
         {
             normal = MakeNormal();
         }
         return(normal);
     }
     else if (p.hasCustomBlocks)
     {
         if (noBlockDefs == null)
         {
             noBlockDefs = MakeNoBlockDefs();
         }
         return(noBlockDefs);
     }
     else
     {
         if (original == null)
         {
             original = MakeOriginalOnly();
         }
         return(original);
     }
 }
Example #6
0
 public static void SendAll(Player pl) {
     if (!pl.HasCpeExt(CpeExt.BlockDefinitions)) return;
     for (int i = 1; i < GlobalDefinitions.Length; i++) {
         BlockDefinition def = GlobalDefinitions[i];
         if (def == null) continue;
         
         if (pl.HasCpeExt(CpeExt.BlockDefinitionsExt) && def.Shape != 0)
             SendDefineBlockExt(pl, def);
         else
             SendDefineBlock(pl, def);
         pl.SendSetBlockPermission(def.BlockID, 1, 1);
     }
 }