Пример #1
0
        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();
        }
Пример #2
0
        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[biomeCount];
                for (int idx = 0; idx < biomeIds.Length; idx++)
                {
                    biomeIds[idx] = stream.ReadVarInt();
                }

                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());
            }
        }
Пример #3
0
        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());
            }
        }
Пример #4
0
 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();
 }
Пример #5
0
        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);
                }
        }
Пример #6
0
        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);
                }
        }
Пример #7
0
 /// <inheritdoc />
 public override void Decode(MinecraftStream stream)
 {
     Location = stream.ReadPosition();
     Action   = (byte)stream.ReadByte();
     Compound = stream.ReadNbtCompound();
 }