/// <summary> /// Reads the specified stream. /// </summary> /// <param name="stream">The stream.</param> /// <returns></returns> /// <remarks></remarks> public static ItemStack Read(BigEndianStream stream) { if (stream == null) throw new System.ArgumentNullException("stream"); var stack = new ItemStack(); if ((stack.ItemType = stream.ReadInt16()) >= 0) { stack.Count = stream.ReadByte(); stack.Durability = stream.ReadInt16(); } else return stack; if (((stream.Owner as PacketEndPoint).Version >=36 && stack.ItemType != -1) || (EnchantHelper.Enchantable.Contains(stack.ItemType) && !((stream.Owner as PacketEndPoint).Use12w18aFix && !(_12w18a.Contains(stack.ItemType)))))//12w18a fix { short hasData = stream.ReadInt16(); if (hasData > 0) { stack.AdditionalData = stream.ReadBytes(hasData); } } if (stack.AdditionalData == null) stack.AdditionalData = new byte[0]; return stack; }
/// <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"); ChunkX = reader.ReadInt32(); ChunkZ = reader.ReadInt32(); Size = reader.ReadInt16(); var coordinates = new List<short>(); var types = new List<byte>(); var metadata = new List<byte>(); for (int i = 0; i < Size; i++) { coordinates.Add(reader.ReadInt16()); } for (int i = 0; i < Size; i++) { types.Add(reader.ReadByte()); } for (int i = 0; i < Size; i++) { metadata.Add(reader.ReadByte()); } CoordiateArray = coordinates; TypeArray = types; MetadataArray = metadata; }
/// <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"); WindowId = reader.ReadByte(); ProgressBarType = reader.ReadInt16(); Value = reader.ReadInt16(); }
/// <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 (); }
/// <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"); Health = reader.ReadInt16(); Food = reader.ReadInt16(); FoodSaturation = reader.ReadSingle(); }
/// <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"); SharedKey = reader.ReadBytes(reader.ReadInt16 ()); if (version >= 37) VerifyToken = reader.ReadBytes(reader.ReadInt16 ()); }
/// <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"); ItemType = reader.ReadInt16 (); ItemId = reader.ReadInt16 (); InnerData = reader.ReadBytes(version >= 49 ? reader.ReadInt16() : reader.ReadByte()); }
/// <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"); XSize = reader.ReadInt16 (); YSize = reader.ReadInt16 (); ZSize = reader.ReadInt16 (); }
/// <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"); EntityId = reader.ReadInt32 (); VelocityX = reader.ReadInt16 (); VelocityY = reader.ReadInt16 (); VelocityZ = reader.ReadInt16 (); }
/// <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"); PositionX = reader.ReadInt16 (); PositionY = reader.ReadInt16 (); PositionZ = reader.ReadInt16 (); BlockType = reader.ReadByte (); }
/// <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"); WindowId = reader.ReadByte(); Slot = reader.ReadInt16(); RightClick = reader.ReadByte(); ActionNumber = reader.ReadInt16(); Shift = reader.ReadBoolean(); Item = ItemStack.Read(reader); }
/// <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"); PlayerID = reader.ReadByte (); PlayerName = reader.ReadClassicString (); PositionX = reader.ReadInt16 (); PositionY = reader.ReadInt16 (); PositionZ = reader.ReadInt16 (); Yaw = reader.ReadByte (); Pitch = reader.ReadByte (); }
/// <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"); PositionX = reader.ReadInt32 (); PositionY = reader.ReadInt16 (); PositionZ = reader.ReadInt32 (); Byte1 = reader.ReadByte (); Byte2 = reader.ReadByte (); if (version >= 38) UnknownInt16 = reader.ReadInt16 (); }
/// <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"); TeamName = reader.ReadString16(); Mode = reader.ReadByte(); if (Mode == 2 || Mode == 0) { TeamDisplayName = reader.ReadString16(); TeamPrefix = reader.ReadString16(); TeamSufix = reader.ReadString16(); if (version >= 60) FriendlyFire = reader.ReadByte(); else FriendlyFire = (byte) (reader.ReadBoolean() ? 1 : 0); } if (Mode == 0 || Mode == 3 || Mode == 4) { PlayerCount = reader.ReadInt16(); var collection = new List<string>(); for (int i = 0; i < PlayerCount; i++) { collection.Add(reader.ReadString16()); } Players = collection.ToArray(); } }
/// <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"); Slot = reader.ReadInt16 (); Item = ItemStack.Read(reader); }
/// <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"); Channel = reader.ReadString16(); InternalData = reader.ReadBytes(reader.ReadInt16()); }
/// <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"); ChunkData = reader.ReadBytes(reader.ReadInt16 ()); PercentComplete = reader.ReadByte (); }
/// <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"); PlayerName = reader.ReadString16(); Online = reader.ReadBoolean(); Ping = reader.ReadInt16(); }
public NewLevelWriter(Stream str, short sectorSize = 256) { CreateRegionFile(str, sectorSize); _filePointer = new BigEndianStream(str); _sectorSize = _filePointer.ReadInt16(); _headerSize = 32 * 32 * 16 * 4 + 2; }
/// <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"); WindowId = reader.ReadByte (); Count = reader.ReadInt16 (); Items = InventoryPacket.ParsePayload(reader, Count); }
/// <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"); WindowId = reader.ReadByte(); ActionNumber = reader.ReadInt16(); Accepted = 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 ArgumentNullException("reader"); EntityId = reader.ReadInt32(); EffectId = reader.ReadByte(); Amplifier = reader.ReadByte(); Duration = reader.ReadInt16(); }
/// <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"); ChunkX = reader.ReadInt32 (); ChunkZ = reader.ReadInt32 (); Unknown = reader.ReadInt16 (); DataArray = reader.ReadBytes(reader.ReadInt32 ()); }
/// <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"); Count = reader.ReadInt16(); DataLength = reader.ReadInt32(); ChunkData = reader.ReadBytes(DataLength); var list = new List<ChunkBulkMetaData>(); for (int i = 0; i < Count; i++) { list.Add(new ChunkBulkMetaData { PositionX = reader.ReadInt32(), PositionZ = reader.ReadInt32(), PrimaryBitmap = reader.ReadInt16(), AddBitmap = reader.ReadInt16(), }); } ChunkMetaData = list; }
/// <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"); EntityId = reader.ReadInt32 (); Slot = reader.ReadInt16 (); if (version >= 35) { Stack = ItemStack.Read(reader); } else { Stack = new ItemStack { ItemType = reader.ReadInt16 (), Durability = reader.ReadInt16 (), AdditionalData = new byte[0], Count = 1 }; } }
/// <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.ReadInt32(); PositionY = reader.ReadInt16(); PositionZ = reader.ReadInt32(); Line1 = reader.ReadString16(); Line2 = reader.ReadString16(); Line3 = reader.ReadString16(); Line4 = reader.ReadString16(); }
/// <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"); if (version >= 32 && reader.Context == PacketContext.Client) return; if (version >= 27) World = reader.ReadInt32(); else World = reader.ReadByte(); Difficulty = reader.ReadByte(); CreativeMode = reader.ReadByte(); WorldHeight = reader.ReadInt16(); if (version <= 27) MapSeed = reader.ReadInt64(); if (version >= 23) Generator = reader.ReadString16(); }
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}; }
/// <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"); EntityId = reader.ReadInt32(); ObjectType = reader.ReadByte(); PositionX = reader.ReadInt32(); PositionY = reader.ReadInt32(); PositionZ = reader.ReadInt32(); if ((ObjectData = reader.ReadInt32()) > 0) { UnknownX = reader.ReadInt16(); UnknownY = reader.ReadInt16(); UnknownZ = reader.ReadInt16(); } }
/// <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"); EntityId = reader.ReadInt32 (); MobType = reader.ReadByte (); PositionX = reader.ReadInt32 (); PositionY = reader.ReadInt32 (); PositionZ = reader.ReadInt32 (); Yaw = reader.ReadByte (); Pitch = reader.ReadByte (); if (version >= 24) HeadYaw = reader.ReadByte (); if (version >= 38) { Unknown1 = reader.ReadInt16 (); Unknown2 = reader.ReadInt16 (); Unknown3 = reader.ReadInt16 (); } DataStream = MetadataInfo.Read(reader, version); }