Esempio n. 1
1
 /// <summary> Creates a new SetBlockServer (0x06) packet. </summary>
 /// <param name="coords"> Coordinates of the block. </param>
 /// <param name="type"> Block type to set at given coordinates. </param>
 /// <param name="player"> Player packet is being sent to, used to get fallback block </param>
 public static Packet MakeSetBlock( Vector3I coords, Block type, Player player ) {
     Packet packet = new Packet( OpCode.SetBlockServer );
     //Logger.Log(LogType.Debug, "Send: MakeSetBlock({0})({1})", coords, type);
     ToNetOrder( (short)coords.X, packet.Bytes, 1 );
     ToNetOrder( (short)coords.Z, packet.Bytes, 3 );
     ToNetOrder( (short)coords.Y, packet.Bytes, 5 );
     packet.Bytes[7] = (byte)player.getFallback(type);
     return packet;
 }
Esempio n. 2
0
 public static Packet MakeCustomBlockSupportLevel(byte level)
 {
     Logger.Log(LogType.Debug, "Send: CustomBlockSupportLevel({0})", level);
     Packet packet = new Packet(OpCode.CustomBlocks);
     packet.Data[1] = level;
     return packet;
 }
Esempio n. 3
0
 public static Packet MakeChangeModel(byte EntityID, string modelName)
 {
     Packet packet = new Packet(OpCode.ChangeModel);
     packet.Data[1] = EntityID;
     Encoding.ASCII.GetBytes(modelName.PadRight(64), 0, 64, packet.Data, 2);
     return packet;
 }
Esempio n. 4
0
 public static Packet MakeExtEntry(string name, int version)
 {
     Logger.Log(LogType.Debug, "Send: ExtEntry({0},{1})", name, version);
     Packet packet = new Packet(OpCode.ExtEntry);
     Encoding.ASCII.GetBytes(name.PadRight(64), 0, 64, packet.Data, 1);
     ToNetOrder(version, packet.Data, 65);
     return packet;
 }
Esempio n. 5
0
 public static Packet MakeSetBlock( short x, short y, short z, Block type ) {
     Packet packet = new Packet( OpCode.SetBlockServer );
     ToNetOrder( x, packet.Bytes, 1 );
     ToNetOrder( z, packet.Bytes, 3 );
     ToNetOrder( y, packet.Bytes, 5 );
     packet.Bytes[7] = (byte)type;
     return packet;
 }
Esempio n. 6
0
 public static Packet MakeExtAddEntity(byte EntityID, string entityName, string skinName)
 {
     Packet packet = new Packet(OpCode.ExtAddEntity);
     packet.Data[1] = EntityID;
     Encoding.ASCII.GetBytes(entityName.PadRight(64), 0, 64, packet.Data, 2);
     Encoding.ASCII.GetBytes(skinName.PadRight(64), 0, 64, packet.Data, 66);
     return packet;
 }
Esempio n. 7
0
 public static Packet MakeSetBlock( Vector3I coords, Block type ) {
     Packet packet = new Packet( OpCode.SetBlockServer );
     ToNetOrder( (short)coords.X, packet.Bytes, 1 );
     ToNetOrder( (short)coords.Z, packet.Bytes, 3 );
     ToNetOrder( (short)coords.Y, packet.Bytes, 5 );
     packet.Bytes[7] = (byte)type;
     return packet;
 }
Esempio n. 8
0
 public static Packet MakeSetBlockPermission(Block block, bool canPlace, bool canDelete)
 {
     Packet packet = new Packet(OpCode.SetBlockPermissions);
     packet.Data[1] = (byte)block;
     packet.Data[2] = (byte)(canPlace ? 1 : 0);
     packet.Data[3] = (byte)(canDelete ? 1 : 0);
     return packet;
 }
Esempio n. 9
0
 internal static Packet MakeMove( int id, Position pos )
 {
     Packet packet = new Packet( OpCode.Move );
     packet.Data[1] = ( byte )id;
     packet.Data[2] = ( byte )pos.X;
     packet.Data[3] = ( byte )pos.Z;
     packet.Data[4] = ( byte )pos.Y;
     return packet;
 }
Esempio n. 10
0
 public static Packet MakeEnvSetMapAppearance(string textureURL, byte sideBlock, byte edgeBlock, short sideLevel)
 {
     Packet packet = new Packet(OpCode.EnvSetMapAppearance);
     Encoding.ASCII.GetBytes(textureURL.PadRight(64), 0, 64, packet.Data, 1);
     packet.Data[65] = sideBlock;
     packet.Data[66] = edgeBlock;
     ToNetOrder((short)sideLevel, packet.Data, 67);
     return packet;
 }
Esempio n. 11
0
 public static Packet MakeSetBlock( int x, int y, int z, Block type )
 {
     Packet packet = new Packet( OpCode.SetBlockServer );
     ToNetOrder( x, packet.Data, 1 );
     ToNetOrder( z, packet.Data, 3 );
     ToNetOrder( y, packet.Data, 5 );
     packet.Data[7] = (byte)type;
     return packet;
 }
Esempio n. 12
0
        internal static Packet MakeDisconnect( string reason )
        {
            if ( reason == null )
                throw new ArgumentNullException( "reason" );

            Packet packet = new Packet( OpCode.Kick );
            Encoding.ASCII.GetBytes( reason.PadRight( 64 ), 0, 64, packet.Data, 1 );
            return packet;
        }
Esempio n. 13
0
 /// <summary> Packet used to change players names/group in TabList as well as their autocomplete name. Color code friendly. </summary>
 /// <param name="NameID"> Name ID number from 0-255 </param>
 /// <param name="PlayerName"> Name used for autocompletion (can be null) </param>
 /// <param name="ListName"> Name displayed in Tab List </param>
 /// <param name="GroupName"> Name of group in Tab List </param>
 /// <param name="GroupRank"> Rank of group in Tab list (0 is highest) </param>
 public static Packet MakeExtAddPlayerName(short NameID, [CanBeNull]string PlayerName, string ListName, string GroupName, byte GroupRank)
 {
     Packet packet = new Packet(OpCode.ExtAddPlayerName); //0
     ToNetOrder((short)NameID, packet.Data, 1); //1
     Encoding.ASCII.GetBytes(PlayerName.PadRight(64), 0, 64, packet.Data, 3);  //2
     Encoding.ASCII.GetBytes(ListName.PadRight(64), 0, 64, packet.Data, 67); //67
     Encoding.ASCII.GetBytes(GroupName.PadRight(64), 0, 64, packet.Data, 131); //131
     packet.Data[195] = (byte)GroupRank;
     return packet;
 }
Esempio n. 14
0
 public static Packet MakeEnvSetColor(byte selection, string colorcode)
 {
     System.Drawing.Color col = System.Drawing.ColorTranslator.FromHtml(colorcode.ToUpper());
     Packet packet = new Packet(OpCode.EnvSetColor);
     packet.Data[1] = selection;
     ToNetOrder((short)(col.R), packet.Data, 2);
     ToNetOrder((short)(col.G), packet.Data, 4);
     ToNetOrder((short)(col.B), packet.Data, 6);
     return packet;
 }
Esempio n. 15
0
        public static Packet MakeExtInfo( short extCount )
        {
            String VersionString = "800Craft " + Updater.CurrentRelease.VersionString;
            Logger.Log( LogType.SystemActivity, "Send: ExtInfo({0},{1})", VersionString, extCount );

            Packet packet = new Packet( OpCode.ExtInfo );
            Encoding.ASCII.GetBytes( VersionString.PadRight( 64 ), 0, 64, packet.Data, 1 );
            ToNetOrder( extCount, packet.Data, 65 );
            return packet;
        }
Esempio n. 16
0
        public static Packet MakeExtInfo(short extCount)
        {
            String VersionString = "LegendCraft " + Updater.LatestStable;
            Logger.Log(LogType.Debug, "Send: ExtInfo({0},{1})", VersionString, extCount);

            Packet packet = new Packet(OpCode.ExtInfo);
            Encoding.ASCII.GetBytes(VersionString.PadRight(64), 0, 64, packet.Data, 1);
            ToNetOrder(extCount, packet.Data, 65);
            return packet;
        }
Esempio n. 17
0
 public static Packet MakeTeleport( sbyte id, Position pos ) {
     Packet packet = new Packet( OpCode.Teleport );
     packet.Bytes[1] = (byte)id;
     ToNetOrder( pos.X, packet.Bytes, 2 );
     ToNetOrder( pos.Z, packet.Bytes, 4 );
     ToNetOrder( pos.Y, packet.Bytes, 6 );
     packet.Bytes[8] = pos.R;
     packet.Bytes[9] = pos.L;
     return packet;
 }
Esempio n. 18
0
        internal static Packet MakeMessage( string message )
        {
            if ( message == null )
                throw new ArgumentNullException( "message" );

            Packet packet = new Packet( OpCode.Message );
            packet.Data[1] = 0; // unused
            Encoding.ASCII.GetBytes( message.PadRight( 64 ), 0, 64, packet.Data, 2 );
            return packet;
        }
Esempio n. 19
0
        /// <summary> Creates a new Handshake (0x00) packet. </summary>
        /// <param name="serverName"> Server name, to be shown on recipient's loading screen. May not be null. </param>
        /// <param name="player"> Player to whom this packet is being sent.
        /// Used to determine DeleteAdmincrete permission, for client-side checks. May not be null. </param>
        /// <param name="motd"> Message-of-the-day (text displayed below the server name). May not be null. </param>
        /// <exception cref="ArgumentNullException"> player, serverName, or motd is null </exception>
        public static Packet MakeHandshake([NotNull] Player player, [NotNull] string serverName, [NotNull] string motd) {
            if (serverName == null) throw new ArgumentNullException("serverName");
            if (motd == null) throw new ArgumentNullException("motd");

            Packet packet = new Packet(OpCode.Handshake);
            packet.Bytes[1] = Config.ProtocolVersion;
            Encoding.ASCII.GetBytes(serverName.PadRight(64), 0, 64, packet.Bytes, 2);
            Encoding.ASCII.GetBytes(motd.PadRight(64), 0, 64, packet.Bytes, 66);
            packet.Bytes[130] = (byte)(player.Can(Permission.DeleteAdmincrete) ? 100 : 0);
            return packet;
        }
Esempio n. 20
0
        public static Packet MakeAddEntity( sbyte id, [NotNull] string name, Position pos ) {
            if( name == null ) throw new ArgumentNullException( "name" );

            Packet packet = new Packet( OpCode.AddEntity );
            packet.Bytes[1] = (byte)id;
            Encoding.ASCII.GetBytes( name.PadRight( 64 ), 0, 64, packet.Bytes, 2 );
            ToNetOrder( pos.X, packet.Bytes, 66 );
            ToNetOrder( pos.Z, packet.Bytes, 68 );
            ToNetOrder( pos.Y, packet.Bytes, 70 );
            packet.Bytes[72] = pos.R;
            packet.Bytes[73] = pos.L;
            return packet;
        }
Esempio n. 21
0
 /// <summary> Creates a new AddEntity (0x07) packet. </summary>
 /// <param name="id"> Entity ID. Negative values refer to "self". </param>
 /// <param name="name"> Entity name. May not be null. </param>
 /// <param name="spawnPosition"> Spawning position for the player. </param>
 /// <exception cref="ArgumentNullException"> name is null </exception>
 public static Packet MakeAddEntity( sbyte id, [NotNull] string name, Position spawnPosition ) {
     if (name == null) throw new ArgumentNullException("name");
     
     Packet packet = new Packet( OpCode.AddEntity );
     //Logger.Log(LogType.Debug, "Send: MakeAddEntity({0}, {1}, {2})", id, name, spawnPosition);
     packet.Bytes[1] = (byte)id;
     Encoding.ASCII.GetBytes( name.PadRight( 64 ), 0, 64, packet.Bytes, 2 );
     ToNetOrder( spawnPosition.X, packet.Bytes, 66 );
     ToNetOrder( spawnPosition.Z, packet.Bytes, 68 );
     ToNetOrder( spawnPosition.Y, packet.Bytes, 70 );
     packet.Bytes[72] = spawnPosition.R;
     packet.Bytes[73] = spawnPosition.L;
     return packet;
 }
Esempio n. 22
0
 public static Packet MakeAddSelectionBox(byte ID, string Label, short StartX, short StartY, short StartZ, short EndX, short EndY, short EndZ, short R, short G, short B, short A)
 {
     Logger.Log(LogType.Debug, "Send: MakeAddSelectionBox({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11})",
         ID, Label, StartX, StartY, StartZ, EndX, EndY, EndZ, R, G, B, A);
     Packet packet = new Packet(OpCode.SelectionCuboid);
     packet.Data[1] = ID;
     Encoding.ASCII.GetBytes(Label.PadRight(64), 0, 64, packet.Data, 2);
     ToNetOrder(StartX, packet.Data, 66);
     ToNetOrder(StartY, packet.Data, 68);
     ToNetOrder(StartZ, packet.Data, 70);
     ToNetOrder(EndX, packet.Data, 72);
     ToNetOrder(EndY, packet.Data, 74);
     ToNetOrder(EndZ, packet.Data, 76);
     ToNetOrder(R, packet.Data, 78);
     ToNetOrder(G, packet.Data, 80);
     ToNetOrder(B, packet.Data, 82);
     ToNetOrder(A, packet.Data, 84);
     return packet;
 }
Esempio n. 23
0
 internal static Packet MakeSetBlock( Vector3I coords, Block type )
 {
     Packet packet = new Packet( OpCode.SetBlockServer );
     ToNetOrder( coords.X, packet.Data, 1 );
     ToNetOrder( coords.Z, packet.Data, 3 );
     ToNetOrder( coords.Y, packet.Data, 5 );
     packet.Data[7] = (byte)type;
     return packet;
 }
Esempio n. 24
0
 internal static Packet MakeRotate( int id, Position pos )
 {
     Packet packet = new Packet( OpCode.Rotate );
     packet.Data[1] = (byte)id;
     packet.Data[2] = pos.R;
     packet.Data[3] = pos.L;
     return packet;
 }
Esempio n. 25
0
 internal static Packet MakeRemoveEntity( int id )
 {
     Packet packet = new Packet( OpCode.RemoveEntity );
     packet.Data[1] = (byte)id;
     return packet;
 }
Esempio n. 26
0
 internal static Packet MakeMoveRotate( int id, Position pos )
 {
     Packet packet = new Packet( OpCode.MoveRotate );
     packet.Data[1] = (byte)id;
     packet.Data[2] = (byte)(pos.X & 0xFF);
     packet.Data[3] = (byte)(pos.Z & 0xFF);
     packet.Data[4] = (byte)(pos.Y & 0xFF);
     packet.Data[5] = pos.R;
     packet.Data[6] = pos.L;
     return packet;
 }
Esempio n. 27
0
 /// <summary> Send packet (thread-safe, asynchronous, delayed queue).
 /// This is currently only used for block updates. </summary>
 public void SendLowPriority( Packet packet ) {
     if( canQueue ) outputQueue.Enqueue( packet );
 }
Esempio n. 28
0
 /// <summary> Send packet (thread-safe, async, priority queue).
 /// This is used for most packets (movement, chat, etc). </summary>
 public void Send( Packet packet ) {
     if( canQueue ) priorityOutputQueue.Enqueue( packet );
 }
Esempio n. 29
0
 internal void SendAllEnvColor(byte variable, int  value) {
 	Packet packet = PacketWriter.MakeEnvSetColor(variable, value);
     foreach (Player p in Players.Where(p => p.usesCPE))
         p.Send(packet);
 }
Esempio n. 30
0
        internal static Packet MakeSetPermission( [NotNull] Player player )
        {
            if( player == null ) throw new ArgumentNullException( "player" );

            Packet packet = new Packet( OpCode.SetPermission );
            packet.Data[1] = (byte)(player.Can( Permission.DeleteAdmincrete ) ? 100 : 0);
            return packet;
        }
Esempio n. 31
0
 internal void SendAllMapWeather() {
     Packet packet = PacketWriter.MakeEnvWeatherAppearance((byte)WeatherCC);
     foreach (Player p in Players.Where(p => p.usesCPE))
         p.Send(packet);
 }
Esempio n. 32
0
 internal static Packet MakeTeleport( int id, Position pos )
 {
     Packet packet = new Packet( OpCode.Teleport );
     packet.Data[1] = (byte)id;
     ToNetOrder( pos.X, packet.Data, 2 );
     ToNetOrder( pos.Z, packet.Data, 4 );
     ToNetOrder( pos.Y, packet.Data, 6 );
     packet.Data[8] = pos.R;
     packet.Data[9] = pos.L;
     return packet;
 }
Esempio n. 33
0
 internal void SendAllMapAppearance() {
     Packet packet = PacketWriter.MakeEnvSetMapAppearance(textureURL, SideBlock, EdgeBlock, EdgeLevel);
     foreach (Player p in Players.Where(p => p.usesCPE))
         p.Send(packet);
 }