public override void Decode(MinecraftStream stream) { EntityId = stream.ReadInt(); IsHardcore = stream.ReadBool(); Gamemode = (byte)stream.ReadByte(); PreviousGamemode = (byte)stream.ReadByte(); int worldCount = stream.ReadVarInt(); WorldNames = new string[worldCount]; for (int i = 0; i < worldCount; i++) { WorldNames[i] = stream.ReadString(); } DimensionCodec = stream.ReadNbtCompound(); Dimension = stream.ReadNbtCompound(); //stream.ReadString(); WorldName = stream.ReadString(); HashedSeed = stream.ReadLong(); //Difficulty = (byte) stream.ReadByte(); stream.ReadByte(); ViewDistance = stream.ReadVarInt(); ReducedDebugInfo = stream.ReadBool(); EnableRespawnScreen = stream.ReadBool(); IsDebug = stream.ReadBool(); IsFlat = stream.ReadBool(); }
public override void Decode(MinecraftStream stream) { ChunkX = stream.ReadInt(); ChunkZ = stream.ReadInt(); GroundUp = stream.ReadBool(); IgnoreOldData = stream.ReadBool(); PrimaryBitmask = stream.ReadVarInt(); HeightMaps = stream.ReadNbtCompound(); if (GroundUp) { //int biomeCount = stream.ReadVarInt(); int[] biomeIds = new int[1024]; for (int idx = 0; idx < biomeIds.Length; idx++) { biomeIds[idx] = stream.ReadInt(); } Biomes = biomeIds; } int i = stream.ReadVarInt(); Buffer = new Memory <byte>(new byte[i]); stream.Read(Buffer.Span, Buffer.Length); int tileEntities = stream.ReadVarInt(); for (int k = 0; k < tileEntities; k++) { TileEntities.Add(stream.ReadNbtCompound()); } }
public override void Decode(MinecraftStream stream) { Dimension = stream.ReadNbtCompound(); WorldName = stream.ReadString(); HashedSeed = stream.ReadLong(); Gamemode = (GameMode)stream.ReadByte(); PreviousGamemode = (GameMode)stream.ReadByte(); IsDebug = stream.ReadBool(); IsFlat = stream.ReadBool(); CopyMetadata = stream.ReadBool(); }
public override void Decode(MinecraftStream stream) { EntityId = stream.ReadInt(); Gamemode = (byte)stream.ReadByte(); Dimension = stream.ReadInt(); HashedSeed = stream.ReadLong(); //Difficulty = (byte) stream.ReadByte(); stream.ReadByte(); LevelType = stream.ReadString(); ReducedDebugInfo = stream.ReadBool(); EnableRespawnScreen = stream.ReadBool(); }
/// <inheritdoc /> public override void Decode(MinecraftStream stream) { Position = stream.ReadPosition(); Block = stream.ReadVarInt(); Status = (DigStatus)stream.ReadVarInt(); Successful = stream.ReadBool(); }
public override void Decode(MinecraftStream stream) { ChunkX = stream.ReadInt(); ChunkZ = stream.ReadInt(); GroundUp = stream.ReadBool(); PrimaryBitmask = stream.ReadVarInt(); HeightMaps = stream.ReadNbtCompound(); if (GroundUp) { int[] biomeIds = new int[1024]; for (int idx = 0; idx < biomeIds.Length; idx++) { biomeIds[idx] = stream.ReadInt(); } } int i = stream.ReadVarInt(); Buffer = new byte[i]; stream.Read(Buffer, 0, Buffer.Length); int tileEntities = stream.ReadVarInt(); for (int k = 0; k < tileEntities; k++) { TileEntities.Add(stream.ReadNbtCompound()); } }
public override void Decode(MinecraftStream stream) { EntityId = stream.ReadVarInt(); Yaw = (sbyte)stream.ReadByte(); Pitch = (sbyte)stream.ReadByte(); OnGround = stream.ReadBool(); }
public override void Decode(MinecraftStream stream) { X = stream.ReadDouble(); FeetY = stream.ReadDouble(); Z = stream.ReadDouble(); OnGround = stream.ReadBool(); }
public override void Decode(MinecraftStream stream) { EntityId = stream.ReadVarInt(); DeltaX = stream.ReadShort(); DeltaY = stream.ReadShort(); DeltaZ = stream.ReadShort(); OnGround = stream.ReadBool(); }
public override void Decode(MinecraftStream stream) { X = stream.ReadDouble(); Y = stream.ReadDouble(); Z = stream.ReadDouble(); Yaw = stream.ReadFloat(); Pitch = stream.ReadFloat(); OnGround = stream.ReadBool(); }
public override void Decode(MinecraftStream stream) { Locale = stream.ReadString(); ViewDistance = (byte)stream.ReadByte(); ChatMode = stream.ReadVarInt(); ChatColors = stream.ReadBool(); SkinParts = (byte)stream.ReadByte(); MainHand = stream.ReadVarInt(); }
public override void Decode(MinecraftStream stream) { EntityId = stream.ReadInt(); Gamemode = (byte)stream.ReadByte(); Dimension = stream.ReadInt(); Difficulty = (byte)stream.ReadByte(); stream.ReadByte(); LevelType = stream.ReadString(); ReducedDebugInfo = stream.ReadBool(); }
public override void Decode(MinecraftStream stream) { ParticleId = stream.ReadInt(); LongDistance = stream.ReadBool(); X = stream.ReadFloat(); Y = stream.ReadFloat(); Z = stream.ReadFloat(); OffsetX = stream.ReadFloat(); OffsetY = stream.ReadFloat(); OffsetZ = stream.ReadFloat(); ParticleData = stream.ReadFloat(); ParticleCount = stream.ReadInt(); //TODO: Read data, varies per particle tho... }
private void ReadAddPlayerEntries(int count, MinecraftStream stream) { AddPlayerEntries = new AddPlayerEntry[count]; for (int i = 0; i < count; i++) { var newEntry = new AddPlayerEntry(); newEntry.UUID = stream.ReadUuid(); newEntry.Name = stream.ReadString(); int propertyLength = stream.ReadVarInt(); newEntry.Properties = new PlayerListProperty[propertyLength]; for (int ii = 0; ii < propertyLength; ii++) { newEntry.Properties[ii] = new PlayerListProperty() { Name = stream.ReadString(), Value = stream.ReadString(), IsSigned = stream.ReadBool() }; if (newEntry.Properties[ii].IsSigned) { newEntry.Properties[ii].Signature = stream.ReadString(); } } newEntry.Gamemode = stream.ReadVarInt(); newEntry.Ping = stream.ReadVarInt(); newEntry.HasDisplayName = stream.ReadBool(); if (newEntry.HasDisplayName) { newEntry.DisplayName = stream.ReadString(); } AddPlayerEntries[i] = newEntry; } }
private void ReadUpdateDisplayNameEntries(int count, MinecraftStream stream) { UpdateDisplayNameEntries = new UpdateDisplayNameEntry[count]; for (int i = 0; i < count; i++) { var entry = new UpdateDisplayNameEntry(); entry.UUID = stream.ReadUuid(); entry.HasDisplayName = stream.ReadBool(); if (entry.HasDisplayName) { entry.DisplayName = stream.ReadString(); } UpdateDisplayNameEntries[i] = entry; } }
/// <inheritdoc /> public override void Decode(MinecraftStream stream) { AimWithHead = stream.ReadVarInt() == 1; var x = (float)stream.ReadDouble(); var y = (float)stream.ReadDouble(); var z = (float)stream.ReadDouble(); Target = new Vector3(x, y, z); IsEntity = stream.ReadBool(); if (IsEntity) { EntityId = stream.ReadVarInt(); LookAtEyes = stream.ReadVarInt() == 1; } }
public override void Decode(MinecraftStream stream) { TransactionId = stream.ReadVarInt(); Start = stream.ReadVarInt(); Length = stream.ReadVarInt(); int c = stream.ReadVarInt(); Matches = new TabCompleteMatch[c]; for (int i = 0; i < c; i++) { var entry = new TabCompleteMatch(); entry.Match = stream.ReadString(); entry.HasTooltip = stream.ReadBool(); if (entry.HasTooltip) { ChatObject.TryParse(stream.ReadString(), out entry.Tooltip); } Matches[i] = entry; } }
public override void Decode(MinecraftStream stream) { var chunkSectionPos = stream.ReadLong(); ChunkX = (int)(chunkSectionPos >> 42); var sectionY = (int)(chunkSectionPos << 44 >> 44); ChunkZ = (int)(chunkSectionPos << 22 >> 42); var inverse = stream.ReadBool(); //ChunkX = stream.ReadInt(); // ChunkZ = stream.ReadInt(); int recordCount = stream.ReadVarInt(); Records = new BlockUpdate[recordCount]; for (int i = 0; i < Records.Length; i++) { var encoded = stream.ReadVarLong(); // long encoded = rawId << 12 | (blockLocalX << 8 | blockLocalZ << 4 | blockLocalY) var rawId = encoded >> 12; var x = (int)((encoded >> 8) & 0xF); var y = (int)(encoded & 0xF); var z = (int)((encoded >> 4) & 0xF); //byte horizontalPos = (byte)stream.ReadByte(); BlockUpdate update = new BlockUpdate(); update.X = (ChunkX << 4) + x; update.Z = (ChunkZ << 4) + z; update.Y = (sectionY << 4) + y; update.BlockId = (uint)rawId; Records[i] = update; } }
public void FinishReading() { using (MemoryStream ms = new MemoryStream(Data)) using (MinecraftStream stream = new MinecraftStream(ms)) { byte index = 0; do { index = (byte)stream.ReadByte(); if (index == 0xff) { break; } MetadataType type = (MetadataType)stream.ReadVarInt(); MetaDataEntry meta = null; switch (type) { case MetadataType.Byte: meta = new MetadataByte(index, (byte)stream.ReadByte()); break; case MetadataType.Varint: meta = new MetadataVarInt(index, stream.ReadVarInt()); break; case MetadataType.Float: meta = new MetadataFloat(index, stream.ReadFloat()); break; case MetadataType.String: meta = new MetadataString(index, stream.ReadString()); break; case MetadataType.Chat: meta = new MetadataChat(index, stream.ReadChatObject()); break; case MetadataType.OptChat: var hasData = stream.ReadBool(); meta = new MetadataOptChat(index, hasData, hasData ? stream.ReadChatObject() : null); break; case MetadataType.Slot: meta = new MetadataSlot(index, stream.ReadSlot()); break; case MetadataType.Boolean: meta = new MetadataBool(index, stream.ReadBool()); break; case MetadataType.Rotation: stream.ReadFloat(); stream.ReadFloat(); stream.ReadFloat(); break; case MetadataType.Position: stream.ReadPosition(); break; case MetadataType.OptPosition: if (stream.ReadBool()) { stream.ReadPosition(); } break; case MetadataType.Direction: stream.ReadVarInt(); break; case MetadataType.OptUUID: if (stream.ReadBool()) { stream.ReadUuid(); } break; case MetadataType.OptBlockID: stream.ReadVarInt(); break; case MetadataType.NBT: stream.ReadNbtCompound(); break; case MetadataType.Particle: break; case MetadataType.VillagerData: stream.ReadVarInt(); stream.ReadVarInt(); stream.ReadVarInt(); break; case MetadataType.OptVarInt: stream.ReadVarInt(); break; case MetadataType.Pose: stream.ReadVarInt(); break; } if (meta != null) { Entries.Add(meta); } } while (index != 0xff); } }
public override void Decode(MinecraftStream stream) { WindowId = (byte)stream.ReadByte(); ActionNumber = stream.ReadShort(); Accepted = stream.ReadBool(); }
public override void Decode(MinecraftStream stream) { ChunkX = stream.ReadVarInt(); ChunkZ = stream.ReadVarInt(); TrustEdges = stream.ReadBool(); SkyLightMask = stream.ReadVarInt(); BlockLightMask = stream.ReadVarInt(); EmptySkyLightMask = stream.ReadVarInt(); EmptyBlockLightMask = stream.ReadVarInt(); // List<byte[]> skyLightList = new List<byte[]>(); SkyLightArrays = new byte[16][]; for (int i = 0; i < SkyLightArrays.Length + 1; i++) { if (((SkyLightMask & 1) != 0) /*&& ((EmptySkyLightMask & 1) == 0)*/) { stream.ReadVarInt(); byte[] data = stream.Read(2048); if (i != 0) { SkyLightArrays[i - 1] = data; } } else { if (i != 0) { SkyLightArrays[i - 1] = null; } } SkyLightMask = SkyLightMask >> 1; EmptySkyLightMask = EmptySkyLightMask >> 1; } //SkyLightArrays = skyLightList.ToArray(); // List<byte[]> blockLightList = new List<byte[]>(); BlockLightArrays = new byte[16][]; for (int i = 0; i < BlockLightArrays.Length + 1; i++) { if (((BlockLightMask & 1) != 0) /*&& ((EmptyBlockLightMask & 1) == 0)*/) { stream.ReadVarInt(); byte[] data = stream.Read(2048); if (i != 0) { BlockLightArrays[i - 1] = data; } } else { if (i != 0) { BlockLightArrays[i - 1] = null; } } BlockLightMask = BlockLightMask >> 1; EmptyBlockLightMask = EmptyBlockLightMask >> 1; } // BlockLightArrays = blockLightList.ToArray(); }
public void FinishReading() { using (MemoryStream ms = new MemoryStream(Data)) using (MinecraftStream stream = new MinecraftStream(ms)) { byte index = 0; do { index = (byte)stream.ReadByte(); if (index == 0xff) { break; } MetadataType type = (MetadataType)stream.ReadVarInt(); MetaDataEntry meta = null; switch (type) { case MetadataType.Byte: meta = new MetadataByte(index, (byte)stream.ReadByte()); break; case MetadataType.Varint: meta = new MetadataVarInt(index, stream.ReadVarInt()); break; case MetadataType.Float: meta = new MetadataFloat(index, stream.ReadFloat()); break; case MetadataType.String: meta = new MetadataString(index, stream.ReadString()); break; case MetadataType.Chat: meta = new MetadataChat(index, stream.ReadChatObject()); break; case MetadataType.OptChat: var hasData = stream.ReadBool(); meta = new MetadataOptChat(index, hasData, hasData ? stream.ReadChatObject() : null); break; case MetadataType.Slot: meta = new MetadataSlot(index, stream.ReadSlot()); break; case MetadataType.Boolean: meta = new MetadataBool(index, stream.ReadBool()); break; case MetadataType.Rotation: meta = new MetadataRotation(index, new Vector3(stream.ReadFloat(), stream.ReadFloat(), stream.ReadFloat())); break; case MetadataType.Position: meta = new MetadataPosition(index, stream.ReadPosition()); break; case MetadataType.OptPosition: { bool hasPosition = stream.ReadBool(); meta = new MetadataOptPosition( index, hasPosition, hasPosition ? stream.ReadPosition() : (Vector3?)null); } break; case MetadataType.Direction: meta = new MetadataDirection(index, (API.Utils.Direction)stream.ReadVarInt()); // stream.ReadVarInt(); break; case MetadataType.OptUUID: { var hasUUID = stream.ReadBool(); meta = new MetadataOptUUID(index, hasUUID, hasUUID ? new UUID(stream.ReadUuid().ToByteArray()) : null); // stream.ReadUuid(); } break; case MetadataType.OptBlockID: stream.ReadVarInt(); break; case MetadataType.NBT: meta = new MetadataNbt(index, stream.ReadNbtCompound()); break; case MetadataType.Particle: break; case MetadataType.VillagerData: meta = new MetadataVillagerData( index, (MetadataVillagerData.VillagerTypes)stream.ReadVarInt(), (MetadataVillagerData.VillagerProfession)stream.ReadVarInt(), (MetadataVillagerData.VillagerLevel)stream.ReadVarInt()); break; case MetadataType.OptVarInt: stream.ReadVarInt(); break; case MetadataType.Pose: stream.ReadVarInt(); break; } if (meta != null) { Entries.Add(meta); } } while (index != 0xff); } }