public static Packet MakeCustomBlockSupportLevel( byte level ) { // Logger.Log( "Send: CustomBlockSupportLevel({0})", level ); Packet packet = new Packet( OpCode.CustomBlockSupportLevel ); packet.Bytes[1] = level; return packet; }
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; }
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; }
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; }
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; }
// 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] ); } }
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 ); } } } }
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; }
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; }
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; }
public static Packet MakeSetPermission( bool isOp ) { Packet packet = new Packet( OpCode.SetPermission ); if( isOp ) packet.Bytes[1] = 100; return packet; }
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; }
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; }
public static Packet MakeRemoveEntity( int id ) { Packet packet = new Packet( OpCode.RemoveEntity ); packet.Bytes[1] = (byte)id; return packet; }
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; }
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 ); } }
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; }