Example #1
0
        public void Read(BinaryReader reader)
        {
            //flag
            bool isRecipeNotNull = reader.ReadBoolean();

            if (isRecipeNotNull)
            {
                recipe = new Recipe();
                recipe.Read(reader);
            }

            craftingTimeLeft = new Value <float>(reader.ReadSingle());
            multiplier       = new Value <int>(reader.ReadInt32());
            isCrafting       = new Value <bool>(reader.ReadBoolean());

            //flag2
            bool isRepairItemNotNull = reader.ReadBoolean();

            if (isRepairItemNotNull)
            {
                repairItem = new ItemValue();
                repairItem.Read(reader);
                amountToRepair = new Value <int>(reader.ReadInt32());
            }

            quality          = new Value <int>(reader.ReadInt32());
            startingEntityId = new Value <int>(reader.ReadInt32());
        }
Example #2
0
 public ItemStack Read(BinaryReader reader)
 {
     itemValue = new ItemValue();
     itemValue.Read(reader);
     count = new Value <int>((int)reader.ReadInt16());
     return(this);
 }
Example #3
0
        public void Read(BinaryReader reader)
        {
            entityCreationDataVersion = new Value <byte>(reader.ReadByte());
            entityClass = new Value <int>(reader.ReadInt32());

            id       = new Value <int>(reader.ReadInt32());
            lifetime = new Value <float>(reader.ReadSingle());

            pos   = new Vector3D <float>();
            pos.x = new Value <float>(reader.ReadSingle());
            pos.y = new Value <float>(reader.ReadSingle());
            pos.z = new Value <float>(reader.ReadSingle());

            rot   = new Vector3D <float>();
            rot.x = new Value <float>(reader.ReadSingle());
            rot.y = new Value <float>(reader.ReadSingle());
            rot.z = new Value <float>(reader.ReadSingle());

            onGround = new Value <bool>(reader.ReadBoolean());

            bodyDamage = new BodyDamage();
            bodyDamage.Read(reader);

            bool isStatsNotNull = reader.ReadBoolean();

            if (isStatsNotNull)
            {
                stats = new EntityStats();
                stats.Read(reader);
            }

            deathTime = new Value <int>((int)reader.ReadInt16());


            bool tileEntityNotNull = reader.ReadBoolean();

            if (tileEntityNotNull)
            {
                type          = new Value <int>(reader.ReadInt32());
                lootContainer = TileEntity.Instantiate((TileEntityType)(type.Get()));
                lootContainer.Read(reader);
            }

            homePosition   = new Vector3D <int>();
            homePosition.x = new Value <int>(reader.ReadInt32());
            homePosition.y = new Value <int>(reader.ReadInt32());
            homePosition.z = new Value <int>(reader.ReadInt32());

            unknownD      = new Value <int>((int)reader.ReadInt16());
            spawnerSource = (EnumSpawnerSource)reader.ReadByte();

            if (entityClass.Get() == Utils.GetMonoHash("item"))
            {
                belongsPlayerId = new Value <int>(reader.ReadInt32());
                itemStack.Read(reader);

                reader.ReadSByte();
            }

            else if (entityClass.Get() == Utils.GetMonoHash("fallingBlock"))
            {
                blockValueRawData = new Value <uint>(reader.ReadUInt32());
            }

            else if (entityClass.Get() == Utils.GetMonoHash("fallingTree"))
            {
                blockPosition   = new Vector3D <int>();
                blockPosition.x = new Value <int>(reader.ReadInt32());
                blockPosition.y = new Value <int>(reader.ReadInt32());
                blockPosition.z = new Value <int>(reader.ReadInt32());

                fallTreeDir   = new Vector3D <float>();
                fallTreeDir.x = new Value <float>(reader.ReadSingle());
                fallTreeDir.y = new Value <float>(reader.ReadSingle());
                fallTreeDir.z = new Value <float>(reader.ReadSingle());
            }

            else if ((entityClass.Get() == Utils.GetMonoHash("playerMale")) || (entityClass.Get() == Utils.GetMonoHash("playerFemale")))
            {
                holdingItem = new ItemValue();
                holdingItem.Read(reader);
                teamNumber  = new Value <int>((int)reader.ReadByte());
                entityName  = new Value <string>(reader.ReadString());
                skinTexture = new Value <string>(reader.ReadString());

                bool isPlayerProfileNotNull = reader.ReadBoolean();
                if (isPlayerProfileNotNull)
                {
                    playerProfile = PlayerProfile.Read(reader);
                }
                else
                {
                    playerProfile = null;
                }
            }

            //num2
            int entityDataLength = (int)reader.ReadUInt16();

            if (entityDataLength > 0)
            {
                byte[] buffer = reader.ReadBytes(entityDataLength);
                entityData = new MemoryStream(buffer);
            }

            isTraderEntity = new Value <bool>(reader.ReadBoolean());
        }