Example #1
0
 public static ClickWindow Deserialize(ref SpanReader br)
 {
     return(new ClickWindow
     {
         WindowId = br.ReadAsByte(),
         Slot = br.ReadAsShort(),
         Button = br.ReadAsByte(),
         ActionNumber = br.ReadAsShort(),
         Mode = br.ReadAsVarInt(out _),
         ClickedItem = br.ReadAsSlot()
     });
 }
Example #2
0
 public static ClientSettings Deserialize(ref SpanReader br)
 {
     return(new ClientSettings
     {
         Locale = br.ReadAsString(),
         ViewDistance = br.ReadAsByte(),
         ChatMode = br.ReadAsVarInt(out _),
         ChatColors = br.ReadAsBoolean(),
         DisplayedSkinParts = br.ReadAsByte(),
         MainHand = br.ReadAsVarInt(out _)
     });
 }
Example #3
0
 public static EntityLookAndRelativeMove Deserialize(ref SpanReader br)
 {
     return(new EntityLookAndRelativeMove
     {
         EID = br.ReadAsVarInt(out _),
         DeltaX = br.ReadAsShort(),
         DeltaY = br.ReadAsShort(),
         DeltaZ = br.ReadAsShort(),
         Yaw = br.ReadAsByte(),
         Pitch = br.ReadAsByte(),
         OnGround = br.ReadAsBoolean()
     });
 }
Example #4
0
 public static ServerboundCloseWindow Deserialize(ref SpanReader br)
 {
     return(new ServerboundCloseWindow
     {
         WindowId = br.ReadAsByte()
     });
 }
Example #5
0
        public static ChunkSection Deserialize(ref SpanReader br, bool isOverworld)
        {
            var result = new ChunkSection
            {
                BitsPerBlock  = br.ReadAsByte(),
                PaletteLength = br.ReadAsVarInt(out _)
            };

            if (result.PaletteLength != 0)
            {
                var paletteReader = br.ReadAsSubReader((int)result.PaletteLength);
                var palette       = new List <uint>();
                while (!paletteReader.IsCosumed)
                {
                    palette.Add(paletteReader.ReadAsVarInt(out _));
                }
                result.Palette = palette.ToArray();
            }

            result.DataArrayLength = br.ReadAsVarInt(out _);
            var dataArray = new ulong[result.DataArrayLength];

            for (int i = 0; i < dataArray.Length; i++)
            {
                dataArray[i] = br.ReadAsUnsignedLong();
            }
            result.DataArray  = dataArray;
            result.BlockLight = br.ReadAsByteArray(ChunkConstants.BlocksInSection / 2);
            if (isOverworld)
            {
                result.SkyLight = br.ReadAsByteArray(ChunkConstants.BlocksInSection / 2);
            }
            return(result);
        }
Example #6
0
 public static PrepareCraftingGrid Deserialize(ref SpanReader br)
 {
     return(new PrepareCraftingGrid
     {
         WindowId = br.ReadAsByte(),
         ActionNumber = br.ReadAsShort()
     });
 }
Example #7
0
 public static PlayerDigging Deserialize(ref SpanReader br)
 {
     return(new PlayerDigging
     {
         Status = (PlayerDiggingStatus)br.ReadAsVarInt(out _),
         Location = br.ReadAsPosition(),
         Face = (PlayerDiggingFace)br.ReadAsByte()
     });
 }
Example #8
0
 public static ServerboundConfirmTransaction Deserialize(ref SpanReader br)
 {
     return(new ServerboundConfirmTransaction
     {
         WindowId = br.ReadAsByte(),
         ActionNumber = br.ReadAsShort(),
         Accepted = br.ReadAsBoolean()
     });
 }
Example #9
0
 public static Respawn Deserialize(ref SpanReader br)
 {
     return(new Respawn
     {
         Dimension = br.ReadAsInt(),
         HashedSeed = br.ReadAsLong(),
         Gamemode = br.ReadAsByte(),
         LevelType = br.ReadAsString()
     });
 }
Example #10
0
        public static ChunkSection Deserialize(ref SpanReader br, bool isOverworld)
        {
            var result = new ChunkSection
            {
                BlockCount    = br.ReadAsShort(),
                BitsPerBlock  = br.ReadAsByte(),
                PaletteLength = br.ReadAsVarInt(out _)
            };

            if (result.BitsPerBlock < 4)
            {
                throw new InvalidDataException("ChunkSection: BitsPerBlock should be greater than or equal to 4.");
            }
            else if (result.BitsPerBlock >= 5 && result.BitsPerBlock < 9)
            {
                if (result.PaletteLength != 0)
                {
                    var paletteReader = br.ReadAsSubReader((int)result.PaletteLength);
                    var palette       = new List <uint>();
                    while (!paletteReader.IsCosumed)
                    {
                        palette.Add(paletteReader.ReadAsVarInt(out _));
                    }
                    result.Palette = palette.ToArray();
                }
            }

            result.DataArrayLength = br.ReadAsVarInt(out _);
            var dataArray = new ulong[result.DataArrayLength];

            for (int i = 0; i < dataArray.Length; i++)
            {
                dataArray[i] = br.ReadAsUnsignedLong();
            }
            result.DataArray = dataArray;
            return(result);
        }