Пример #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 Packet Read(byte[] data)
        {
            var             re = new Ping();
            MinecraftStream ms = new MinecraftStream(data);

            re.ID      = ms.ReadVarInt();
            re.Payload = ms.ReadLong();
            return(re);
        }
Пример #3
0
        public void Read(MinecraftStream ms)
        {
            var blockCount   = ms.ReadShort();
            var bitsPerBlock = (byte)ms.ReadByte();

            int palleteLength = 0;// = ms.ReadVarInt();

            if (bitsPerBlock <= 4)
            {
                bitsPerBlock = 4;
            }

            if (bitsPerBlock <= 8)
            {
                _bits = bitsPerBlock;

                palleteLength = ms.ReadVarInt();

                Pallette = new IntIdentityHashBiMap(palleteLength);
                Pallette.Add(Air);

                for (int id = 0; id < palleteLength; id++)
                {
                    uint       stateId = (uint)ms.ReadVarInt();
                    BlockState state   = BlockFactory.GetBlockState(stateId);
                    Pallette.Put(state, (uint)id);
                }
            }
            else
            {
                _bits    = (int)Math.Ceiling(Math.Log2(BlockFactory.AllBlockstates.Count));
                Pallette = new DirectPallete();
            }

            int length = ms.ReadVarInt();

            long[] dataArray = new long[length];
            for (int i = 0; i < dataArray.Length; i++)
            {
                dataArray[i] = ms.ReadLong();
            }

            Storage = new FlexibleStorage(_bits, 4096);
            var valueMask = (uint)((1L << _bits) - 1);

            for (int index = 0; index < 4096; index++)
            {
                var state = index / (64 / _bits);
                var data  = dataArray[state];

                var shiftedData = data >> (index % (64 / _bits) * _bits);

                Storage[index] = (uint)(shiftedData & valueMask);
            }
        }
Пример #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 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();
 }
Пример #6
0
        public void Read(MinecraftStream ms)
        {
            var blockCount   = ms.ReadShort();
            var bitsPerBlock = (byte)ms.ReadByte();

            int palleteLength = 0;// = ms.ReadVarInt();

            if (bitsPerBlock <= 4)
            {
                bitsPerBlock = 4;
            }

            if (bitsPerBlock <= 8)
            {
                _bits = bitsPerBlock;

                palleteLength = ms.ReadVarInt();

                Pallette = new IntIdentityHashBiMap <BlockState>(palleteLength);
                Pallette.Add(Air);

                //else
                //     palleteLength =

                for (int id = 0; id < palleteLength; id++)
                {
                    uint       stateId = (uint)ms.ReadVarInt();
                    BlockState state   = BlockFactory.GetBlockState(stateId);
                    Pallette.Put(state, (uint)id);
                    // idToState.Set(id, state);
                    // stateToId.Set(state, id);
                }
            }
            else
            {
                _bits    = (int)Math.Ceiling(Math.Log2(BlockFactory.AllBlockstates.Count));
                Pallette = new DirectPallete();
            }

            int length = ms.ReadVarInt();

            long[] dataArray = new long[length];
            for (int i = 0; i < dataArray.Length; i++)
            {
                dataArray[i] = ms.ReadLong();
            }

            Storage = new FlexibleStorage(_bits, dataArray);
            //Storage._data = dataArray;
        }
Пример #7
0
        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;
            }
        }
Пример #8
0
 public override void Decode(MinecraftStream stream)
 {
     KeepAliveid = stream.ReadLong();
 }
Пример #9
0
 public override void Decode(MinecraftStream stream)
 {
     WorldAge  = stream.ReadLong();
     TimeOfDay = stream.ReadLong();
 }
Пример #10
0
 public override void Decode(MinecraftStream stream)
 {
     Payload = stream.ReadLong();
 }