コード例 #1
0
        public IPacket WritePacket(IMinecraftStream stream)
        {
            stream.WriteVarInt(ID);
            stream.WriteVarInt(SharedSecret.Length);
            stream.WriteByteArray(SharedSecret);
            stream.WriteVarInt(VerificationToken.Length);
            stream.WriteByteArray(VerificationToken);
            stream.Purge();

            return this;
        }
コード例 #2
0
        public IPacket WritePacket(IMinecraftStream stream)
        {
            stream.WriteVarInt(ID);
            stream.WriteVarInt(SharedSecret.Length);
            stream.WriteByteArray(SharedSecret);
            stream.WriteVarInt(VerificationToken.Length);
            stream.WriteByteArray(VerificationToken);
            stream.Purge();

            return(this);
        }
コード例 #3
0
        public IPacket WritePacket(IMinecraftStream stream)
        {
            stream.WriteVarInt(ID);
            stream.WriteString(ServerId);
            stream.WriteVarInt(PublicKey.Length);
            stream.WriteByteArray(PublicKey);
            stream.WriteVarInt(VerificationToken.Length);
            stream.WriteByteArray(VerificationToken);
            stream.Purge();

            return(this);
        }
コード例 #4
0
        public IPacket WritePacket(IMinecraftStream stream)
        {
            stream.WriteVarInt(ID);
            stream.WriteString(ServerId);
            stream.WriteVarInt(PublicKey.Length);
            stream.WriteByteArray(PublicKey);
            stream.WriteVarInt(VerificationToken.Length);
            stream.WriteByteArray(VerificationToken);
            stream.Purge();

            return this;
        }
コード例 #5
0
        public IPacket WritePacket(IMinecraftStream stream)
        {
            stream.WriteVarInt(ID);
            stream.WriteString(Channel);
            stream.WriteVarInt(Data.Length);
            stream.WriteByteArray(Data);
            stream.Purge();

            return this;
        }
コード例 #6
0
        public IPacket WritePacket(IMinecraftStream stream)
        {
            stream.WriteVarInt(ID);
            stream.WriteVarInt(EntityID);
            stream.WriteVarInt(NBTTag.Length);
            stream.WriteByteArray(NBTTag);
            stream.Purge();

            return(this);
        }
コード例 #7
0
        public IPacket WritePacket(IMinecraftStream stream)
        {
            stream.WriteVarInt(ID);
            stream.WriteString(Channel);
            stream.WriteShort((short)Data.Length);
            stream.WriteByteArray(Data);
            stream.Purge();

            return(this);
        }
コード例 #8
0
        public IPacket WritePacket(IMinecraftStream stream)
        {
            stream.WriteVarInt(ID);
            stream.WriteVarInt(EntityID);
            stream.WriteVarInt(NBTTag.Length);
            stream.WriteByteArray(NBTTag);
            stream.Purge();

            return this;
        }
コード例 #9
0
        public IPacket WritePacket(IMinecraftStream stream)
        {
            stream.WriteByte(ID);
            stream.WriteShort(ChunkLength);
            stream.WriteByteArray(ChunkData);
            stream.WriteByte(PercentComplete);
            stream.Purge();

            return(this);
        }
コード例 #10
0
        public IPacket WritePacket(IMinecraftStream stream)
        {
            stream.WriteByte(ID);
            stream.WriteShort(ChunkLength);
            stream.WriteByteArray(ChunkData);
            stream.WriteByte(PercentComplete);
            stream.Purge();

            return this;
        }
コード例 #11
0
        public IPacket WritePacket(IMinecraftStream stream)
        {
            stream.WriteVarInt(ID);
            Location.ToStreamLong(stream);
            stream.WriteByte((byte) Action);
            stream.WriteVarInt(NBTData.Length);
            stream.WriteByteArray(NBTData);
            stream.Purge();

            return this;
        }
コード例 #12
0
        public IPacket WritePacket(IMinecraftStream stream)
        {
            stream.WriteVarInt(ID);
            Location.ToStreamLong(stream);
            stream.WriteByte((byte)Action);
            stream.WriteVarInt(NBTData.Length);
            stream.WriteByteArray(NBTData);
            stream.Purge();

            return(this);
        }
コード例 #13
0
        public IPacket WritePacket(IMinecraftStream stream)
        {
            stream.WriteVarInt(ID);
            stream.WriteFloat(X);
            stream.WriteFloat(Y);
            stream.WriteFloat(Z);
            stream.WriteFloat(Radius);
            stream.WriteInt(RecordCount);
            stream.WriteByteArray(Records);
            stream.WriteFloat(PlayerMotionX);
            stream.WriteFloat(PlayerMotionY);
            stream.WriteFloat(PlayerMotionZ);
            stream.Purge();

            return this;
        }
コード例 #14
0
        public IPacket WritePacket(IMinecraftStream stream)
        {
            stream.WriteVarInt(ID);
            stream.WriteFloat(X);
            stream.WriteFloat(Y);
            stream.WriteFloat(Z);
            stream.WriteFloat(Radius);
            stream.WriteInt(RecordCount);
            stream.WriteByteArray(Records);
            stream.WriteFloat(PlayerMotionX);
            stream.WriteFloat(PlayerMotionY);
            stream.WriteFloat(PlayerMotionZ);
            stream.Purge();

            return(this);
        }
コード例 #15
0
        // TODO: Convert to RawData
        public void ToStream(IMinecraftStream stream)
        {
            var OverWorld = true; // TODO: From World class

            stream.WriteVarInt(Coordinates.X);
            stream.WriteVarInt(Coordinates.Z);
            stream.WriteBoolean(OverWorld);
            stream.WriteUShort(PrimaryBitMap);

            var sectionCount = GetSectionCount(PrimaryBitMap);

            var chunkRawBlocks      = new byte[sectionCount * TwoByteData];
            var chunkRawBlocksLight = new byte[sectionCount * HalfByteData];
            var chunkRawSkylight    = new byte[sectionCount * HalfByteData];

            var size = sectionCount * (TwoByteData + HalfByteData + (OverWorld ? HalfByteData : 0)) + (OverWorld ? Biomes.Length : 0);
            var data = new byte[size];

            for (int y = 0, i = 0; y < Sections.Length; y++)
            {
                var section = Sections[y];

                if (Sections[i].IsFilled)
                {
                    // Blocks & Metadata
                    //Array.Copy(section.RawBlocks, 0, chunkRawBlocks, i * section.RawBlocks.Length, section.RawBlocks.Length);
                    // Light
                    //Array.Copy(section.RawBlockLight, 0, chunkRawBlocksLight, i * section.RawBlockLight.Length, section.RawBlockLight.Length);
                    // Sky light
                    //if (OverWorld)
                    //    Array.Copy(section.RawSkyLight, 0, chunkRawSkylight, i  *section.RawSkyLight.Length, section.RawSkyLight.Length);

                    i++;
                }
            }

            Array.Copy(chunkRawBlocks, 0, data, 0, chunkRawBlocks.Length);
            Array.Copy(chunkRawBlocksLight, 0, data, chunkRawBlocks.Length, chunkRawBlocksLight.Length);
            Array.Copy(chunkRawSkylight, 0, data, chunkRawBlocks.Length + chunkRawBlocksLight.Length, chunkRawSkylight.Length);
            if (OverWorld)
            {
                Array.Copy(Biomes, 0, data, data.Length - Biomes.Length, Biomes.Length);
            }

            stream.WriteVarInt(size);
            stream.WriteByteArray(data);
        }
コード例 #16
0
        public IPacket WritePacket(IMinecraftStream stream)
        {
            stream.WriteVarInt(ID);
            stream.WriteVarInt(ItemDamage);
            stream.WriteSByte(Scale);
            IconList.ToStream(stream);
            stream.WriteSByte(Columns);
            if (Columns > 0)
            {
                stream.WriteSByte(Rows);
                stream.WriteSByte(X);
                stream.WriteSByte(Y);
                stream.WriteVarInt(Data.Length);
                stream.WriteByteArray(Data);
            }
            stream.Purge();

            return(this);
        }
コード例 #17
0
        public IPacket WritePacket(IMinecraftStream stream)
        {
            stream.WriteVarInt(ID);
            stream.WriteVarInt(ItemDamage);
            stream.WriteSByte(Scale);
            IconList.ToStream(stream);
            stream.WriteSByte(Columns);
            if (Columns > 0)
            {
                stream.WriteSByte(Rows);
                stream.WriteSByte(X);
                stream.WriteSByte(Y);
                stream.WriteVarInt(Data.Length);
                stream.WriteByteArray(Data);
            }
            stream.Purge();

            return this;
        }
コード例 #18
0
        // TODO: Convert to RawData
        public void ToStream(IMinecraftStream stream)
        {
            stream.WriteBoolean(GroundUp);
            Metadata.ToStream(stream);

            int totalSections = 0;

            foreach (var metadata in Metadata.GetMetadata())
            {
                totalSections += Chunk.GetSectionCount(metadata.PrimaryBitMap);
            }

            var size = totalSections * (Chunk.TwoByteData + Chunk.HalfByteData + (GroundUp ? Chunk.HalfByteData : 0)) + Metadata.Count * 256;
            var data = new byte[size];

            int i      = 0;
            int offset = 0;

            foreach (var metadata in _entries)
            {
                var sectionCount = Chunk.GetSectionCount(metadata.PrimaryBitMap);

                var chunkRawBlocks      = new byte[sectionCount * Chunk.TwoByteData];
                var chunkRawBlocksLight = new byte[sectionCount * Chunk.HalfByteData];
                var chunkRawSkylight    = new byte[sectionCount * Chunk.HalfByteData];

                var chunkLength = sectionCount * (Chunk.TwoByteData + Chunk.HalfByteData + (_entries[i].OverWorld ? Chunk.HalfByteData : 0)) + 256;
                var chunkData   = new byte[chunkLength];

                int j = 0;
                foreach (var section in _entries[i].Sections)
                {
                    if (_entries[i].Sections[j].IsFilled)
                    {
                        // Blocks & Metadata
                        //Array.Copy(section.RawBlocks, 0, chunkRawBlocks, j * section.RawBlocks.Length, section.RawBlocks.Length);
                        // Light
                        //Array.Copy(section.RawBlockLight, 0, chunkRawBlocksLight, j * section.RawBlockLight.Length, section.RawBlockLight.Length);
                        // Sky light
                        //if (_entries[i].OverWorld)
                        //    Array.Copy(section.RawSkyLight, 0, chunkRawSkylight, j * section.RawSkyLight.Length, section.RawSkyLight.Length);

                        j++;
                    }
                }

                Array.Copy(chunkRawBlocks, 0, chunkData, 0, chunkRawBlocks.Length);
                Array.Copy(chunkRawBlocksLight, 0, chunkData, chunkRawBlocks.Length, chunkRawBlocksLight.Length);
                Array.Copy(chunkRawSkylight, 0, chunkData, chunkRawBlocks.Length + chunkRawBlocksLight.Length, chunkRawSkylight.Length);
                if (_entries[i].OverWorld)
                {
                    Array.Copy(_entries[i].Biomes, 0, chunkData, chunkData.Length - _entries[i].Biomes.Length, _entries[i].Biomes.Length);
                }

                Array.Copy(chunkData, 0, data, offset, chunkData.Length);


                offset += chunkLength;
                i++;
            }

            stream.WriteVarInt(size);
            stream.WriteByteArray(data);
        }