Пример #1
0
 public static Packet MakeCustomBlockSupportLevel( byte level )
 {
     // Logger.Log( "Send: CustomBlockSupportLevel({0})", level );
     Packet packet = new Packet( OpCode.CustomBlockSupportLevel );
     packet.Bytes[1] = level;
     return packet;
 }
Пример #2
0
 public static Packet MakeExtInfo( short extCount )
 {
     // Logger.Log( "Send: ExtInfo({0},{1})", Server.VersionString, extCount );
     Packet packet = new Packet( OpCode.ExtInfo );
     Encoding.ASCII.GetBytes( Server.VersionString.PadRight( 64 ), 0, 64, packet.Bytes, 1 );
     ToNetOrder( extCount, packet.Bytes, 65 );
     return packet;
 }
Пример #3
0
 public static Packet MakeSetBlockPermission( Block block, bool canPlace, bool canDelete )
 {
     Packet packet = new Packet( OpCode.SetBlockPermission );
     packet.Bytes[1] = (byte)block;
     packet.Bytes[2] = (byte)(canPlace ? 1 : 0);
     packet.Bytes[3] = (byte)(canDelete ? 1 : 0);
     return packet;
 }
Пример #4
0
 public static Packet MakeExtEntry( [NotNull] string name, int version )
 {
     if( name == null ) throw new ArgumentNullException( "name" );
     // Logger.Log( "Send: ExtEntry({0},{1})", name, version );
     Packet packet = new Packet( OpCode.ExtEntry );
     Encoding.ASCII.GetBytes( name.PadRight( 64 ), 0, 64, packet.Bytes, 1 );
     ToNetOrder( version, packet.Bytes, 65 );
     return packet;
 }
Пример #5
0
 public static Packet MakeAddEntity( byte id, [NotNull] string name, Position pos )
 {
     if( name == null ) throw new ArgumentNullException( "name" );
     Packet packet = new Packet( OpCode.AddEntity );
     packet.Bytes[1] = 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;
 }
Пример #6
0
 // For non-extended players, use appropriate substitution
 void ProcessOutgoingSetBlock( ref Packet packet )
 {
     if( packet.Bytes[7] > (byte)Map.MaxLegalBlockType && !UsesCustomBlocks ) {
         packet.Bytes[7] = (byte)Map.GetFallbackBlock( (Block)packet.Bytes[7] );
     }
 }
Пример #7
0
 public void Send( Packet packet )
 {
     if( packet.OpCode == OpCode.SetBlockServer ) {
         lock( blockSendQueueLock ) {
             if( canQueue ) {
                 blockSendQueue.Enqueue( packet );
             }
         }
     } else {
         lock( sendQueueLock ) {
             if( canQueue ) {
                 sendQueue.Enqueue( packet );
             }
         }
     }
 }
Пример #8
0
 public static Packet MakeHandshake( bool isOp )
 {
     //Logger.Log( "Send: Handshake({0},{1},{2})", Config.ServerName, Config.MOTD, isOp ? (byte)100 : (byte)0 );
     Packet packet = new Packet( OpCode.Handshake );
     packet.Bytes[1] = ProtocolVersion;
     Encoding.ASCII.GetBytes( Config.ServerName.PadRight( 64 ), 0, 64, packet.Bytes, 2 );
     Encoding.ASCII.GetBytes( Config.MOTD.PadRight( 64 ), 0, 64, packet.Bytes, 66 );
     packet.Bytes[130] = isOp ? (byte)100 : (byte)0;
     return packet;
 }
Пример #9
0
 public static Packet MakeMove( int id, Position pos )
 {
     Packet packet = new Packet( OpCode.Move );
     packet.Bytes[1] = (byte)id;
     packet.Bytes[2] = (byte)pos.X;
     packet.Bytes[3] = (byte)pos.Z;
     packet.Bytes[4] = (byte)pos.Y;
     return packet;
 }
Пример #10
0
 public static Packet MakeTeleport( byte id, Position pos )
 {
     Packet packet = new Packet( OpCode.Teleport );
     packet.Bytes[1] = 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;
 }
Пример #11
0
 public static Packet MakeSetPermission( bool isOp )
 {
     Packet packet = new Packet( OpCode.SetPermission );
     if( isOp ) packet.Bytes[1] = 100;
     return packet;
 }
Пример #12
0
 public static Packet MakeSetBlock( int x, int y, int z, Block type )
 {
     Packet packet = new Packet( OpCode.SetBlockServer );
     ToNetOrder( (short)x, packet.Bytes, 1 );
     ToNetOrder( (short)z, packet.Bytes, 3 );
     ToNetOrder( (short)y, packet.Bytes, 5 );
     packet.Bytes[7] = (byte)type;
     return packet;
 }
Пример #13
0
 public static Packet MakeRotate( int id, Position pos )
 {
     Packet packet = new Packet( OpCode.Rotate );
     packet.Bytes[1] = (byte)id;
     packet.Bytes[2] = pos.R;
     packet.Bytes[3] = pos.L;
     return packet;
 }
Пример #14
0
 public static Packet MakeRemoveEntity( int id )
 {
     Packet packet = new Packet( OpCode.RemoveEntity );
     packet.Bytes[1] = (byte)id;
     return packet;
 }
Пример #15
0
 public static Packet MakeMoveRotate( int id, Position pos )
 {
     Packet packet = new Packet( OpCode.MoveRotate );
     packet.Bytes[1] = (byte)id;
     packet.Bytes[2] = (byte)( pos.X & 0xFF );
     packet.Bytes[3] = (byte)( pos.Z & 0xFF );
     packet.Bytes[4] = (byte)( pos.Y & 0xFF );
     packet.Bytes[5] = pos.R;
     packet.Bytes[6] = pos.L;
     return packet;
 }
Пример #16
0
 public static void Send( [NotNull] this IEnumerable<Player> source, [CanBeNull] Player except,
     Packet packet)
 {
     if( source == null ) throw new ArgumentNullException( "source" );
     foreach( Player player in source ) {
         if( player == except ) continue;
         player.Send( packet );
     }
 }
Пример #17
0
 public static Packet MakeKick( [NotNull] string reason )
 {
     if( reason == null ) throw new ArgumentNullException( "reason" );
     Packet packet = new Packet( OpCode.Kick );
     Encoding.ASCII.GetBytes( reason.PadRight( 64 ), 0, 64, packet.Bytes, 1 );
     return packet;
 }