예제 #1
0
 public bool loadColorsArray()
 {
     try
     {
         Tag tag = this.root.getNode(@"\data\colors");
         if (tag.tagType != 7)
         {
             MessageBox.Show("Colors tag found, but it is a " + NBTSharp.Util.getTypeName(tag.tagType) + " where Tag_Byte_Array was expected");
             return false;
         }
         this.colours = (TagByteArray)tag;
     }
     catch (InvalidPathException exception)
     {
         MessageBox.Show("Couldn't find the colors tag\n" + exception.Message);
         return false;
     }
     return true;
 }
예제 #2
0
 public void defaultTagValues(bool resetColors)
 {
     this.root = new TagCompound();
     TagCompound tag = new TagCompound("data");
     this.root.addTag(tag);
       this.scale = new TagByte("scale", 0);
       this.dimension = new TagInt("dimension", 0);
       this.width = new TagShort("width", 0x80);
       this.height = new TagShort("height", 0x80);
       this.xCenter = new TagInt("xCenter", 0x2710);
       this.zCenter = new TagInt("zCenter", 0x2710);
     if (resetColors)
     {
         byte[] bytes = new byte[0x4000];
         for (int i = 0; i < 0x4000; i++)
         {
             bytes[i] = 0;
         }
         this.colours = new TagByteArray("colors", 0x4000, bytes);
     }
      tag.addTag(this.scale);
      tag.addTag(this.dimension);
      tag.addTag(this.width);
      tag.addTag(this.height);
      tag.addTag(this.xCenter);
      tag.addTag(this.zCenter);
     tag.addTag(this.colours);
 }
예제 #3
0
 public void clearTags()
 {
     this.root = null;
     this.colours = null;
     /*  this.scale = null;
       this.dimension = null;
       this.width = null;
       this.height = null;
       this.xCenter = null;
       this.zCenter = null;
       this.txtScale.Text = "";
       this.txtDimension.Text = "";
       this.txtWidth.Text = "";
       this.txtHeight.Text = "";
       this.txtXCenter.Text = "";
       this.txtZCenter.Text = "";*/
     // this.Text = "Map Item Editor";
 }
예제 #4
0
        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;
        }
        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);
        }