Beispiel #1
0
 public override void read(BinaryReader reader)
 {
     try
     {
         this.name   = Util.readString(reader);
         this.number = TagFloat.readData(reader);
     }
     catch (IOException exception)
     {
         throw new FailedReadException(exception.Message, exception);
     }
 }
        private bool loadplayerFile()
        {
            this.path = saveTo + "/" + domainUpDown1.Text; ;
            try
            {
                 preader = new NBTFileReader(path);
                 proot = preader.compound;

                Health = (TagShort)proot.getNode(@"\Health");
                DeathTime = (TagShort)proot.getNode(@"\DeathTime");
                AttackTime = (TagShort)proot.getNode(@"\AttackTime");
                HurtTime = (TagShort)proot.getNode(@"\HurtTime");
                PDimension = (TagInt)proot.getNode(@"\Dimension");
                Sleeping = (TagByte)proot.getNode(@"\Sleeping");
                invulnerable = (TagByte)proot.getNode(@"\abilities\invulnerable");
                instabuild = (TagByte)proot.getNode(@"\abilities\instabuild");
                flying = (TagByte)proot.getNode(@"\abilities\flying");
                mayfly = (TagByte)proot.getNode(@"\abilities\mayfly");

                SleepTimer = (TagShort)proot.getNode(@"\SleepTimer");
                SpawnX = (TagInt)proot.getNode(@"\SpawnX");
                SpawnY = (TagInt)proot.getNode(@"\SpawnY");
                SpawnZ = (TagInt)proot.getNode(@"\SpawnZ");
                foodLevel = (TagInt)proot.getNode(@"\foodLevel");
                foodTickTimer = (TagInt)proot.getNode(@"\foodTickTimer");
                foodExhaustionLevel = (TagFloat)proot.getNode(@"\foodExhaustionLevel");
                foodSaturationLevel = (TagFloat)proot.getNode(@"\foodSaturationLevel");
                XpP = (TagFloat)proot.getNode(@"\XpP");
                XpLevel = (TagInt)proot.getNode(@"\XpLevel");
                XpTotal = (TagInt)proot.getNode(@"\XpTotal");
                /*  this.reader = new NBTFileReader(path);
                  this.root = this.reader.compound;
                  if (!((((this.loadColorsArray()))))) //&& this.loadScale()) && (this.loadDimension() && this.loadWidth())) && (this.loadHeight() && this.loadXCenter())) && this.loadZCenter()))
                  {
                      return false;
                  }*/
            }
            catch (FailedReadException exception)
            {
                if (exception.InnerException != null)
                {
                    MessageBox.Show(exception.InnerException.Message);
                }
                return false;
            }
            this.txtHealth.Text = this.Health.ToString();
            // this.txtDeathTime.Text = this.DeathTime.ToString();
            // this.txtAttackTime.Text = this.AttackTime.ToString();
            // this.txtHurtTime.Text = this.HurtTime.ToString();
            this.txtPDimension.Text = this.PDimension.ToString();
            if (this.Sleeping.ToString() == "1")
            { this.chkSleeping.Checked = true; }
            else { this.chkSleeping.Checked = false; }

            if (this.instabuild.ToString() == "1")
            { this.chkInstabuild.Checked = true; }
            else { this.chkInstabuild.Checked = false; }

            if (this.invulnerable.ToString() == "1")
            { this.chkInvulnerable.Checked = true; }
            else { this.chkInvulnerable.Checked = false; }

            if (this.mayfly.ToString() == "1")
            { this.chkMayfly.Checked = true; }
            else { this.chkMayfly.Checked = false; }

            if (this.flying.ToString() == "1")
            { this.chkFlying.Checked = true; }
            else { this.chkFlying.Checked = false; }

            // this.txtSleepTimer.Text = this.SleepTimer.ToString();
            this.txtSpawnX.Text = this.SpawnX.ToString();
            this.txtSpawnY.Text = this.SpawnY.ToString();
            this.txtSpawnZ.Text = this.SpawnZ.ToString();
            this.txtFoodLevel.Text = this.foodLevel.ToString();
            this.txtFoodTickTimer.Text = this.foodTickTimer.ToString();
            this.txtFoodExhaustionLevel.Text = this.foodExhaustionLevel.ToString();
            this.txtFoodSaturationLevel.Text = this.foodSaturationLevel.ToString();
            this.txtXpP.Text = this.XpP.ToString();
            this.txtXpLevel.Text = this.XpLevel.ToString();
            this.txtXpTotal.Text = this.XpTotal.ToString();
            return true;
        }
        public static List<Tag> readData(BinaryReader reader)
        {
            bool completed = false;
            List<Tag> compound = new List<Tag>();

            while (!completed)
            {
                byte tagType = reader.ReadByte();

                //Console.WriteLine("TagType: " + Util.getTypeName(tagType));

                switch (tagType)
                {
                    case 0:
                        completed = true;
                        break;
                    case 1:
                        TagByte tagByte = new TagByte();
                        tagByte.read(reader);
                        compound.Add(tagByte);
                        break;
                    case 2:
                        TagShort tagShort = new TagShort();
                        tagShort.read(reader);
                        compound.Add(tagShort);
                        break;
                    case 3:
                        TagInt tagInt = new TagInt();
                        tagInt.read(reader);
                        compound.Add(tagInt);
                        break;
                    case 4:
                        TagLong tagLong = new TagLong();
                        tagLong.read(reader);
                        compound.Add(tagLong);
                        break;
                    case 5:
                        TagFloat tagFloat = new TagFloat();
                        tagFloat.read(reader);
                        compound.Add(tagFloat);
                        break;
                    case 6:
                        TagDouble tagDouble = new TagDouble();
                        tagDouble.read(reader);
                        compound.Add(tagDouble);
                        break;
                    case 7:
                        TagByteArray tagByteArray = new TagByteArray();
                        tagByteArray.read(reader);
                        compound.Add(tagByteArray);
                        break;
                    case 8:
                        TagString tagString = new TagString();
                        tagString.read(reader);
                        compound.Add(tagString);
                        break;
                    case 9:
                        TagList tagList = new TagList();
                        tagList.read(reader);
                        compound.Add(tagList);
                        break;
                    case 10:
                        TagCompound tagCompound = new TagCompound();
                        tagCompound.read(reader);
                        compound.Add(tagCompound);
                        break;
                    default:
                        throw new InvalidTagException("An invalid tag type: " + tagType + ", was found while parsing a TAG_Compound");
                }
            }

            return compound;
        }
        public override void read(BinaryReader reader)
        {
            try
            {
                this.list  = new List <object>();
                this.name  = Util.readString(reader);
                this.tagId = reader.ReadSByte();
                int length = 0;

                if (BitConverter.IsLittleEndian)
                {
                    length = Util.readIntegerBigEndian(reader);
                }
                else
                {
                    length = reader.ReadInt32();
                }

                for (int a = 0; a < length; a++)
                {
                    switch (tagId)
                    {
                    case 1:
                        list.Add(TagByte.readData(reader));
                        break;

                    case 2:
                        list.Add(TagShort.readData(reader));
                        break;

                    case 3:
                        list.Add(TagInt.readData(reader));
                        break;

                    case 4:
                        list.Add(TagLong.readData(reader));
                        break;

                    case 5:
                        list.Add(TagFloat.readData(reader));
                        break;

                    case 6:
                        list.Add(TagDouble.readData(reader));
                        break;

                    case 7:
                        list.Add(TagByteArray.readData(reader));
                        break;

                    case 8:
                        list.Add(TagString.readData(reader));
                        break;

                    case 9:
                        TagList newList = new TagList();
                        newList.read(reader);
                        list.Add(newList);
                        break;

                    case 10:
                        List <Tag>  newTagList = TagCompound.readData(reader);
                        TagCompound compound   = new TagCompound("", newTagList);
                        list.Add(compound);
                        break;
                    }
                }
            }
            catch (IOException exception)
            {
                throw new FailedReadException(exception.Message, exception);
            }
        }
        public static List <Tag> readData(BinaryReader reader)
        {
            bool       completed = false;
            List <Tag> compound  = new List <Tag>();

            while (!completed)
            {
                byte tagType = reader.ReadByte();

                //Console.WriteLine("TagType: " + Util.getTypeName(tagType));

                switch (tagType)
                {
                case 0:
                    completed = true;
                    break;

                case 1:
                    TagByte tagByte = new TagByte();
                    tagByte.read(reader);
                    compound.Add(tagByte);
                    break;

                case 2:
                    TagShort tagShort = new TagShort();
                    tagShort.read(reader);
                    compound.Add(tagShort);
                    break;

                case 3:
                    TagInt tagInt = new TagInt();
                    tagInt.read(reader);
                    compound.Add(tagInt);
                    break;

                case 4:
                    TagLong tagLong = new TagLong();
                    tagLong.read(reader);
                    compound.Add(tagLong);
                    break;

                case 5:
                    TagFloat tagFloat = new TagFloat();
                    tagFloat.read(reader);
                    compound.Add(tagFloat);
                    break;

                case 6:
                    TagDouble tagDouble = new TagDouble();
                    tagDouble.read(reader);
                    compound.Add(tagDouble);
                    break;

                case 7:
                    TagByteArray tagByteArray = new TagByteArray();
                    tagByteArray.read(reader);
                    compound.Add(tagByteArray);
                    break;

                case 8:
                    TagString tagString = new TagString();
                    tagString.read(reader);
                    compound.Add(tagString);
                    break;

                case 9:
                    TagList tagList = new TagList();
                    tagList.read(reader);
                    compound.Add(tagList);
                    break;

                case 10:
                    TagCompound tagCompound = new TagCompound();
                    tagCompound.read(reader);
                    compound.Add(tagCompound);
                    break;

                default:
                    throw new InvalidTagException("An invalid tag type: " + tagType + ", was found while parsing a TAG_Compound");
                }
            }

            return(compound);
        }