ReadSingle() public method

public ReadSingle ( ) : float
return float
Ejemplo n.º 1
0
        /// <summary>
        ///   Receives the specified reader.
        /// </summary>
        /// <param name="reader"> The reader. </param>
        /// <param name="version"> The version. </param>
        /// <remarks>
        /// </remarks>
        protected override void OnReceive(BigEndianStream reader, int version)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");
            if (version >= 32)
            {
                byte dataByte = reader.ReadByte ();
                Flying = (dataByte & 0x1) != 0;
                InstantBuild = (dataByte & 0x2) != 0;
                MayFly = (dataByte & 0x4) != 0;
                Invulnerable = (dataByte & 0x8) != 0;
                FlyingSpeed = version >= 72 ? reader.ReadSingle() : reader.ReadByte() /255f;
                WalkSpeed = version >= 72 ? reader.ReadSingle() : reader.ReadByte() / 255f;
            }
            else
            {
                Flying = reader.ReadBoolean ();
                InstantBuild = reader.ReadBoolean ();
                MayFly = reader.ReadBoolean ();
                Invulnerable = reader.ReadBoolean ();

                FlyingSpeed = version >= 72 ? 15 : 15 / 255f;
                WalkSpeed = version >= 72 ? 25 : 25 / 255f;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 ///   Receives the specified reader.
 /// </summary>
 /// <param name="reader"> The reader. </param>
 /// <param name="version"> The version. </param>
 /// <remarks>
 /// </remarks>
 protected override void OnReceive(BigEndianStream reader, int version)
 {
     if (reader == null)
         throw new ArgumentNullException("reader");
     Yaw = reader.ReadSingle ();
     Pitch = reader.ReadSingle ();
     OnGround = reader.ReadBoolean ();
 }
Ejemplo n.º 3
0
 /// <summary>
 ///   Receives the specified reader.
 /// </summary>
 /// <param name="reader"> The reader. </param>
 /// <param name="version"> The version. </param>
 /// <remarks>
 /// </remarks>
 protected override void OnReceive(BigEndianStream reader, int version)
 {
     if (reader == null)
         throw new ArgumentNullException("reader");
     Health = version >= 72 ? reader.ReadSingle() : reader.ReadInt16();
     Food = reader.ReadInt16();
     FoodSaturation = reader.ReadSingle();
 }
Ejemplo n.º 4
0
        /// <summary>
        ///   Receives the specified reader.
        /// </summary>
        /// <param name="reader"> The reader. </param>
        /// <param name="version"> The version. </param>
        /// <remarks>
        /// </remarks>
        protected override void OnReceive(BigEndianStream reader, int version)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            Sideways = reader.ReadSingle();
            Forward = reader.ReadSingle();
            Jump = reader.ReadBoolean();
            Unmount = reader.ReadBoolean();
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Receives the specified reader.
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <param name="version">The version.</param>
 /// <remarks></remarks>
 protected override void OnReceive(BigEndianStream reader, int version)
 {
     if (reader == null)
         throw new System.ArgumentNullException("reader");
     Unknown1 = reader.ReadSingle();
     Unknown2 = reader.ReadSingle();
     Unknown3 = reader.ReadSingle();
     Unknown4 = reader.ReadSingle();
     Unknown5 = reader.ReadBoolean();
     Unknown6 = reader.ReadBoolean();
 }
 /// <summary>
 /// Receives the specified reader.
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <param name="version">The version.</param>
 /// <remarks></remarks>
 protected override void OnReceive(BigEndianStream reader, int version)
 {
     if (reader == null)
         throw new System.ArgumentNullException("reader");
     PositionX = reader.ReadDouble();
     PositionY = reader.ReadDouble();
     Stance = reader.ReadDouble();
     PositionZ = reader.ReadDouble();
     Yaw = reader.ReadSingle();
     Pitch = reader.ReadSingle();
     OnGround = reader.ReadBoolean();
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Receives the specified reader.
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <param name="version">The version.</param>
 /// <remarks></remarks>
 protected override void OnReceive(BigEndianStream reader, int version)
 {
     if (reader == null)
         throw new System.ArgumentNullException("reader");
     PositionX = reader.ReadDouble();
     PositionY = reader.ReadDouble();
     PositionZ = reader.ReadDouble();
     Radius = reader.ReadSingle();
     var records = new ExplosionRecord[RecordCount = reader.ReadInt32()];
     for (int i = 0; i < RecordCount; i++)
     {
         var record = new ExplosionRecord();
         record.OffsetX = reader.ReadByte();
         record.OffsetY = reader.ReadByte();
         record.OffsetZ = reader.ReadByte();
         records[i] = record;
     }
     Records = records;
     if (version >= 36)
     {
         VelocityX = reader.ReadSingle();
         VelocityY = reader.ReadSingle();
         VelocityZ = reader.ReadSingle();
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 ///   Receives the specified reader.
 /// </summary>
 /// <param name="reader"> The reader. </param>
 /// <param name="version"> The version. </param>
 /// <remarks>
 /// </remarks>
 protected override void OnReceive(BigEndianStream reader, int version)
 {
     if (reader == null)
         throw new ArgumentNullException("reader");
     CurrentExperience = reader.ReadSingle ();
     Level = reader.ReadInt16 ();
     TotalExperience = reader.ReadInt16 ();
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Receives the specified reader.
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <param name="version">The version.</param>
 /// <remarks></remarks>
 protected override void OnReceive(BigEndianStream reader, int version)
 {
     if (reader == null)
         throw new System.ArgumentNullException("reader");
     Name = reader.ReadString16();
     PositionX = reader.ReadInt32();
     PositionY = reader.ReadInt32();
     PositionZ = reader.ReadInt32();
     if (version >= 37)
         Volume = reader.ReadSingle();
     else
         Volume = reader.ReadByte();
     Pitch = reader.ReadByte();
 }
Ejemplo n.º 10
0
 public static MetadataInfo Read(BigEndianStream reader, int version)
 {
     if (reader == null)
         throw new ArgumentNullException("reader");
     byte b = 0;
     var data = new Dictionary<byte, object> ();
     while ((b = reader.ReadByte ()) != 127)
     {
         switch (b >> 5)
         {
             case 0:
                 data.Add(b, reader.ReadByte ());
                 break;
             case 1:
                 data.Add(b, reader.ReadInt16 ());
                 break;
             case 2:
                 data.Add(b, reader.ReadInt32 ());
                 break;
             case 3:
                 data.Add(b, reader.ReadSingle ());
                 break;
             case 4:
                 data.Add(b, reader.ReadString16 ());
                 break;
             case 5:
                 data.Add(b, ItemStack.Read(reader));
                 break;
             case 6:
                 data.Add(b,
                          new EntityInformation
                              {
                                  Data1 = reader.ReadInt32 (),
                                  Data2 = reader.ReadInt32 (),
                                  Data3 = reader.ReadInt32 ()
                              });
                 break;
             default:
                 break;
         }
     }
     return new MetadataInfo {Data = data};
 }
        public void SingleTest()
        {
            MemoryStream memStream = new MemoryStream();
            BigEndianStream bigEndianStream = new BigEndianStream(memStream);

            var testByte1 = float.MaxValue;
            var testByte2 = float.MinValue;

            bigEndianStream.Write(testByte1);
            bigEndianStream.Write(testByte2);

            memStream.Seek(0, SeekOrigin.Begin);

            Assert.AreEqual(bigEndianStream.ReadSingle(), testByte1);
            Assert.AreEqual(bigEndianStream.ReadSingle(), testByte2);
            Assert.AreEqual(memStream.Position, memStream.Length);
        }