Пример #1
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());
            }
        }
Пример #2
0
        public override void Decode(MinecraftStream stream)
        {
            Action = (ActionEnum)stream.ReadVarInt();
            switch (Action)
            {
            case ActionEnum.SetTitle:
                TitleText = stream.ReadChatObject();
                break;

            case ActionEnum.SetSubTitle:
                SubtitleText = stream.ReadChatObject();
                break;

            case ActionEnum.SetActionBar:
                ActionBarText = stream.ReadChatObject();
                break;

            case ActionEnum.SetTimesAndDisplay:
                FadeIn  = stream.ReadInt();
                Stay    = stream.ReadInt();
                FadeOut = stream.ReadInt();
                break;

            case ActionEnum.Hide:

                break;

            case ActionEnum.Reset:

                break;
            }
        }
Пример #3
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());
            }
        }
Пример #4
0
 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();
 }
Пример #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 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...
 }
Пример #7
0
        public void Read(MinecraftStream ms, int availableSections, bool groundUp, bool readSkylight)
        {
            try
            {
                //	Stopwatch s = Stopwatch.StartNew();
                //	Log.Debug($"Reading chunk data...");

                for (int sectionY = 0; sectionY < this.Sections.Length; sectionY++)
                {
                    var storage = (JavaChunkSection)this.Sections[sectionY];
                    if ((availableSections & (1 << sectionY)) != 0)
                    {
                        if (storage == null)
                        {
                            storage = new JavaChunkSection(this, sectionY, readSkylight);
                        }

                        storage.Read(ms);
                    }
                    else
                    {
                        if (groundUp && (storage == null || storage.Blocks > 0))
                        {
                            //if (storage == null)
                            //	storage = new ChunkSection(this, sectionY, readSkylight, 2);
                        }
                    }

                    if (storage != null)
                    {
                        storage.IsDirty = true;
                    }

                    this.Sections[sectionY] = storage;
                }

                if (groundUp)
                {
                    for (int x = 0; x < 16; x++)
                    {
                        for (int z = 0; z < 16; z++)
                        {
                            var biomeId = ms.ReadInt();
                            SetBiome(x, z, biomeId);
                        }
                    }
                }

                for (int i = 0; i < Sections.Length; i++)
                {
                    Sections[i]?.RemoveInvalidBlocks();
                }

                CalculateHeight();
            }
            catch (Exception e)
            {
                Log.Warn($"Received supposedly corrupted chunk:" + e);
            }
        }
Пример #8
0
 public override void Decode(MinecraftStream stream)
 {
     Dimension  = stream.ReadInt();
     Difficulty = (byte)stream.ReadByte();
     Gamemode   = (Gamemode)stream.ReadByte();
     LevelType  = stream.ReadString();
 }
Пример #9
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();
        }
Пример #10
0
        public override void Decode(MinecraftStream stream)
        {
            EntityId = stream.ReadVarInt();
            int count = stream.ReadInt();

            for (int i = 0; i < count; i++)
            {
                string key   = stream.ReadString();
                double value = stream.ReadDouble();

                int        propCount = stream.ReadVarInt();
                Modifier[] modifiers = new Modifier[propCount];

                for (int y = 0; y < modifiers.Length; y++)
                {
                    UUID         uuid   = new UUID(stream.ReadUuid().ToByteArray());
                    double       amount = stream.ReadDouble();
                    ModifierMode op     = (ModifierMode)stream.ReadByte();

                    modifiers[y] = EntityProperty.Factory.CreateModifier(uuid, amount, op);
                }

                EntityProperty prop = EntityProperty.Factory.Create(key, value, modifiers);

                if (!Properties.ContainsKey(prop.Key))
                {
                    Properties.Add(prop.Key, prop);
                }
            }
        }
Пример #11
0
        public override void Decode(MinecraftStream stream)
        {
            ChunkX = stream.ReadInt();
            ChunkZ = stream.ReadInt();

            int recordCount = stream.ReadVarInt();

            Records = new BlockUpdate[recordCount];
            for (int i = 0; i < Records.Length; i++)
            {
                byte horizontalPos = (byte)stream.ReadByte();

                BlockUpdate update = new BlockUpdate();
                update.X       = (horizontalPos >> 4 & 15) + (ChunkX * 16);
                update.Z       = (horizontalPos & 15) + (ChunkZ * 16);
                update.Y       = (byte)stream.ReadByte();
                update.BlockId = stream.ReadVarInt();

                Records[i] = update;
            }
        }
Пример #12
0
 public override void Decode(MinecraftStream stream)
 {
     EntityId  = stream.ReadVarInt();
     Uuid      = stream.ReadUuid();
     Type      = stream.ReadVarInt();
     X         = stream.ReadDouble();
     Y         = stream.ReadDouble();
     Z         = stream.ReadDouble();
     Yaw       = (byte)stream.ReadByte();
     Pitch     = (byte)stream.ReadByte();
     Data      = stream.ReadInt();
     VelocityX = stream.ReadShort();
     VelocityY = stream.ReadShort();
     VelocityZ = stream.ReadShort();
 }
Пример #13
0
        public override void Decode(MinecraftStream stream)
        {
            Event = (CombatEvent)stream.ReadVarInt();
            switch (Event)
            {
            case CombatEvent.EnterCombat:

                break;

            case CombatEvent.EndCombat:
                Duration = stream.ReadVarInt();
                EntityId = stream.ReadInt();
                break;

            case CombatEvent.EntityDead:
                PlayerId = stream.ReadVarInt();
                EntityId = stream.ReadInt();
                Message  = stream.ReadString();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #14
0
        public override void Decode(MinecraftStream stream)
        {
            EntityId = stream.ReadVarInt();
            int count = stream.ReadInt();

            for (int i = 0; i < count; i++)
            {
                Property prop  = new Property();
                string   key   = stream.ReadString();
                double   value = stream.ReadDouble();

                int        propCount = stream.ReadVarInt();
                Modifier[] modifiers = new Modifier[propCount];
                for (int y = 0; y < modifiers.Length; y++)
                {
                    UUID   uuid   = new UUID(stream.ReadUuid().ToByteArray());
                    double amount = stream.ReadDouble();
                    byte   op     = (byte)stream.ReadByte();

                    modifiers[y] = new Modifier()
                    {
                        Amount    = amount,
                        Operation = op,
                        Uuid      = uuid
                    };
                }

                prop.Value     = value;
                prop.Modifiers = modifiers;
                prop.Key       = key;

                if (!Properties.ContainsKey(key))
                {
                    Properties.Add(key, prop);
                }
            }
        }
Пример #15
0
 public override void Decode(MinecraftStream stream)
 {
     EntityId     = stream.ReadInt();
     EntityStatus = (byte)stream.ReadByte();
 }
Пример #16
0
 public override void Decode(MinecraftStream stream)
 {
     X = stream.ReadInt();
     Z = stream.ReadInt();
 }
Пример #17
0
        public void Read(MinecraftStream ms, int availableSections, bool groundUp, bool readSkylight)
        {
            try
            {
                //	Stopwatch s = Stopwatch.StartNew();
                //	Log.Debug($"Reading chunk data...");

                for (int sectionY = 0; sectionY < this.Sections.Length; sectionY++)
                {
                    var storage = (ChunkSection)this.Sections[sectionY];
                    if ((availableSections & (1 << sectionY)) != 0)
                    {
                        if (storage == null)
                        {
                            storage = new ChunkSection(this, sectionY, readSkylight);
                        }

                        storage.Read(ms);
                        //var blockCount = ms.ReadShort();
                        //byte bitsPerBlock = (byte) ms.ReadByte();
                        //storage.

                        /*
                         * for (int y = 0; y < 16; y++)
                         * {
                         *      for (int z = 0; z < 16; z++)
                         *      {
                         *              for (int x = 0; x < 16; x += 2)
                         *              {
                         *                      // Note: x += 2 above; we read 2 values along x each time
                         *                      byte value = (byte)ms.ReadByte();
                         *
                         *                      storage.SetExtBlocklightValue(x, y, z, (byte)(value & 0xF));
                         *                      storage.SetExtBlocklightValue(x + 1, y, z, (byte)((value >> 4) & 0xF));
                         *              }
                         *      }
                         * }
                         *
                         * //if (currentDimension.HasSkylight())
                         * if (readSkylight)
                         * {
                         *      for (int y = 0; y < 16; y++)
                         *      {
                         *              for (int z = 0; z < 16; z++)
                         *              {
                         *                      for (int x = 0; x < 16; x += 2)
                         *                      {
                         *                              // Note: x += 2 above; we read 2 values along x each time
                         *                              byte value = (byte)ms.ReadByte();
                         *
                         *                              storage.SetExtSkylightValue(x, y, z, value & 0xF);
                         *                              storage.SetExtSkylightValue(x + 1, y, z, (value >> 4) & 0xF);
                         *                      }
                         *              }
                         *      }
                         * }*/
                    }
                    else
                    {
                        if (groundUp && (storage == null || !storage.IsEmpty()))
                        {
                            if (storage == null)
                            {
                                storage = new ChunkSection(this, sectionY, readSkylight, 2);
                            }
                        }
                    }

                    storage.IsDirty         = true;
                    this.Sections[sectionY] = storage;
                }

                if (groundUp)
                {
                    for (int x = 0; x < 16; x++)
                    {
                        for (int z = 0; z < 16; z++)
                        {
                            var biomeId = ms.ReadInt();
                            SetBiome(x, z, biomeId);
                        }
                    }
                }

                for (int i = 0; i < Sections.Length; i++)
                {
                    Sections[i]?.RemoveInvalidBlocks();
                }

                CalculateHeight();
            }
            catch (Exception e)
            {
                Log.Warn($"Received supposedly corrupted chunk:" + e);
            }
        }