An NBT node representing a signed short tag type.
Inheritance: TagNode
        public override TagNode BuildTree ()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
            tree["Anger"] = new TagNodeShort(_anger);

            return tree;
        }
        public override TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
            tree["Items"] = _items.BuildTree();
            tree["BrewTime"] = new TagNodeShort(_brewTime);

            return tree;
        }
        public override TagNode BuildTree ()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
            tree["carried"] = new TagNodeShort(_carried);
            tree["carriedData"] = new TagNodeShort(_carryingData);

            return tree;
        }
        public override TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
            tree["inData"] = new TagNodeShort(_inData);
            tree["player"] = new TagNodeShort(_player);

            return tree;
        }
        public override TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
            tree["EntityId"] = new TagNodeString(_entityID);
            tree["Delay"] = new TagNodeShort(_delay);

            return tree;
        }
        public override TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
            tree["PushX"] = new TagNodeDouble(_pushX);
            tree["PushZ"] = new TagNodeDouble(_pushZ);
            tree["Fuel"] = new TagNodeShort(_fuel);

            return tree;
        }
Exemple #7
0
        public override TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
            tree["Health"] = new TagNodeShort(_health);
            tree["Age"] = new TagNodeShort(_age);
            tree["Item"] = _item.BuildTree();

            return tree;
        }
        private void WriteShort(TagNodeShort val)
        {
            byte[] gzBytes = BitConverter.GetBytes(val.Data);

            if (BitConverter.IsLittleEndian)
            {
                Array.Reverse(gzBytes);
            }

            _stream.Write(gzBytes, 0, 2);
        }
        private TagNode ReadShort()
        {
            byte[] gzBytes = new byte[2];
            _stream.Read(gzBytes, 0, 2);

            if (BitConverter.IsLittleEndian)
            {
                Array.Reverse(gzBytes);
            }

            TagNodeShort val = new TagNodeShort(BitConverter.ToInt16(gzBytes, 0));

            return(val);
        }
        public override TagNode BuildTree ()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
            tree["Anger"] = new TagNodeShort(_anger);

            tree["IsVillager"] = new TagNodeByte((byte)((_villager ) ? 1 : 0));
            tree["IsBaby"] = new TagNodeByte((byte)((_baby) ? 1 : 0));
            tree["CanBreakDoors"] = new TagNodeByte((byte)((_breakDoors) ? 1 : 0));
            return tree;
        }
        public override TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
            tree["xTile"] = new TagNodeShort(_xTile);
            tree["yTile"] = new TagNodeShort(_yTile);
            tree["zTile"] = new TagNodeShort(_zTile);
            tree["inTile"] = new TagNodeByte(_inTile);
            tree["shake"] = new TagNodeByte(_shake);
            tree["inGround"] = new TagNodeByte(_inGround);

            return tree;
        }
 public TagShortDataNode(TagNodeShort tag)
     : base(tag)
 {
 }
        internal static void AddTagToNode(TreeNode node, int descriptionIndex, TagType type)
        {
            TagNode tag = GetTagNode(node);
            if (tag == null)
                return;

            if (tag.GetTagType() != TagType.TAG_COMPOUND &&
                tag.GetTagType() != TagType.TAG_LIST)
                return;

            if (tag.GetTagType() == TagType.TAG_LIST &&
                tag.ToTagList().ValueType != type &&
                tag.ToTagList().Count > 0)
                return;

            TagNode newNode = null;
            switch (type)
            {
                case TagType.TAG_BYTE:
                    newNode = new TagNodeByte();
                    break;
                case TagType.TAG_SHORT:
                    newNode = new TagNodeShort();
                    break;
                case TagType.TAG_INT:
                    newNode = new TagNodeInt();
                    break;
                case TagType.TAG_LONG:
                    newNode = new TagNodeLong();
                    break;
                case TagType.TAG_FLOAT:
                    newNode = new TagNodeFloat();
                    break;
                case TagType.TAG_DOUBLE:
                    newNode = new TagNodeDouble();
                    break;
                case TagType.TAG_BYTE_ARRAY:
                    newNode = new TagNodeByteArray();
                    break;
                case TagType.TAG_STRING:
                    newNode = new TagNodeString();
                    break;
                case TagType.TAG_LIST:
                    newNode = new TagNodeList(TagType.TAG_BYTE);
                    break;
                case TagType.TAG_COMPOUND:
                    newNode = new TagNodeCompound();
                    break;
                case TagType.TAG_INT_ARRAY:
                    newNode = new TagNodeIntArray();
                    break;
            }

            if (tag is TagNodeCompound)
            {
                TagNodeCompound ctag = tag as TagNodeCompound;

                EditValue form = new EditValue("");
                foreach (string key in ctag.Keys)
                {
                    form.InvalidNames.Add(key);
                }

                if (form.ShowDialog() != DialogResult.OK)
                    return;

                ctag.Add(form.NodeName, newNode);

                TreeNode tnode = NodeFromTag(newNode, descriptionIndex, form.NodeName);
                node.Nodes.Add(tnode);

                tnode.TreeView.SelectedNode = tnode;
                tnode.Expand();
            }
            else if (tag is TagNodeList)
            {
                var ltag = tag as TagNodeList;
                if (ltag.ValueType != type)
                    ltag.ChangeValueType(type);

                ltag.Add(newNode);

                TreeNode tnode = NodeFromTag(newNode, descriptionIndex);
                node.Nodes.Add(tnode);
                tnode.TreeView.SelectedNode = tnode;

                tnode.Expand();
            }

            node.Text = GetNodeText(node);

            TreeNode baseNode = BaseNode(node);
            if (baseNode != null)
            {
                (baseNode.Tag as DataNode).Modified = true;
            }
        }
Exemple #14
0
        /// <summary>
        /// Exports the <see cref="Schematic"/> object to a schematic file.
        /// </summary>
        /// <param name="path">The path to write out the schematic file to.</param>
        public void Export(string path)
        {
            int xdim = _blockset.XDim;
            int ydim = _blockset.YDim;
            int zdim = _blockset.ZDim;

            byte[] blockData = new byte[xdim * ydim * zdim];
            byte[] dataData = new byte[xdim * ydim * zdim];

            YZXByteArray schemaBlocks = new YZXByteArray(_blockset.XDim, _blockset.YDim, _blockset.ZDim, blockData);
            YZXByteArray schemaData = new YZXByteArray(_blockset.XDim, _blockset.YDim, _blockset.ZDim, dataData);

            TagNodeList entities = new TagNodeList(TagType.TAG_COMPOUND);
            TagNodeList tileEntities = new TagNodeList(TagType.TAG_COMPOUND);

            for (int x = 0; x < xdim; x++) {
                for (int z = 0; z < zdim; z++) {
                    for (int y = 0; y < ydim; y++) {
                        AlphaBlock block = _blockset.GetBlock(x, y, z);
                        schemaBlocks[x, y, z] = (byte)block.ID;
                        schemaData[x, y, z] = (byte)block.Data;

                        TileEntity te = block.GetTileEntity();
                        if (te != null) {
                            te.X = x;
                            te.Y = y;
                            te.Z = z;

                            tileEntities.Add(te.BuildTree());
                        }
                    }
                }
            }

            foreach (TypedEntity e in _entityset) {
                entities.Add(e.BuildTree());
            }

            TagNodeCompound schematic = new TagNodeCompound();
            schematic["Width"] = new TagNodeShort((short)xdim);
            schematic["Length"] = new TagNodeShort((short)zdim);
            schematic["Height"] = new TagNodeShort((short)ydim);

            schematic["Entities"] = entities;
            schematic["TileEntities"] = tileEntities;

            schematic["Materials"] = new TagNodeString("Alpha");

            schematic["Blocks"] = new TagNodeByteArray(blockData);
            schematic["Data"] = new TagNodeByteArray(dataData);

            NBTFile schematicFile = new NBTFile(path);

            Stream nbtStream = schematicFile.GetDataOutputStream();
            if (nbtStream == null) {
                return;
            }

            NbtTree tree = new NbtTree(schematic, "Schematic");
            tree.WriteTo(nbtStream);

            nbtStream.Close();
        }
Exemple #15
0
        public override TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
            tree["AttackTime"] = new TagNodeShort(_attackTime);
            tree["DeathTime"] = new TagNodeShort(_deathTime);
            tree["Health"] = new TagNodeShort(_health);
            tree["HurtTime"] = new TagNodeShort(_hurtTime);

            if (_activeEffects != null) {
                TagNodeCompound ae = new TagNodeCompound();
                ae["Id"] = new TagNodeByte((byte)_activeEffects.Id);
                ae["Amplifier"] = new TagNodeByte((byte)_activeEffects.Amplifier);
                ae["Duration"] = new TagNodeInt(_activeEffects.Duration);

                tree["ActiveEffects"] = ae;
            }

            return tree;
        }
Exemple #16
0
        public override TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
            tree["AttackTime"] = new TagNodeShort(_attackTime);
            tree["DeathTime"] = new TagNodeShort(_deathTime);
            tree["Health"] = new TagNodeShort(_health);
            tree["HurtTime"] = new TagNodeShort(_hurtTime);

            return tree;
        }
        public override TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
            tree["EntityId"] = new TagNodeString(_entityID);
            tree["Delay"] = new TagNodeShort(_delay);

            if (_maxDelay != null)
                tree["MaxSpawnDelay"] = new TagNodeShort(_maxDelay ?? 0);
            if (_minDelay != null)
                tree["MinSpawnDelay"] = new TagNodeShort(_minDelay ?? 0);
            if (_spawnCount != null)
                tree["SpawnCount"] = new TagNodeShort(_spawnCount ?? 0);
            if (_spawnRange != null)
                tree["SpawnRange"] = new TagNodeShort(_spawnRange ?? 0);
            if (_maxNearbyEnemies != null)
                tree["MaxNearbyEnemies"] = new TagNodeShort(_maxNearbyEnemies ?? 0);
            if (_requiredPlayerRange != null)
                tree["RequiredPlayerRange"] = new TagNodeShort(_requiredPlayerRange ?? 0);
            if (_maxExperience != null)
                tree["MaxExperience"] = new TagNodeInt(_maxExperience ?? 0);
            if (_remainingExperience != null)
                tree["RemainingExperience"] = new TagNodeInt(_remainingExperience ?? 0);
            if (_experienceRegenTick != null)
                tree["ExperienceRegenTick"] = new TagNodeInt(_experienceRegenTick ?? 0);
            if (_experienceRegenRate != null)
                tree["ExperienceRegenRate"] = new TagNodeInt(_experienceRegenRate ?? 0);
            if (_experienceRegenAmount != null)
                tree["ExperienceRegenAmount"] = new TagNodeInt(_experienceRegenAmount ?? 0);

            if (_spawnData != null && _spawnData.Count > 0)
                tree["SpawnData"] = _spawnData;

            return tree;
        }
 public override TagNode BuildTree()
 {
     TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
     tree["EntityId"] = new TagNodeString(_entityID);
     tree["Delay"] = new TagNodeShort(_delay);
     tree["MaxSpawnDelay"] = new TagNodeShort(_maxDelay);
     tree["MinSpawnDelay"] = new TagNodeShort(_minDelay);
     tree["SpawnCount"] = new TagNodeShort(_spawnCount);
     tree["SpawnData"] = _spawnData.BuildTree();
     return tree;
 }