TUInt16.cs 440 B

1234567891011121314151617181920212223
  1. using System;
  2. using System.Buffers.Binary;
  3. namespace VeloeMinecraftLauncher.Utils.McProtocol;
  4. public class TUInt16
  5. {
  6. public ushort Value { set; get; }
  7. public TUInt16(ushort value) => Value = value;
  8. public byte[] GetBytes()
  9. {
  10. var v = this.Value;
  11. if (BitConverter.IsLittleEndian)
  12. {
  13. v = BinaryPrimitives.ReverseEndianness(v);
  14. }
  15. return BitConverter.GetBytes(v);
  16. }
  17. }