/// <summary> /// Builds an Entity subtree from the current data. /// </summary> /// <returns>The root node of an Entity subtree representing the current data.</returns> public TagNode BuildTree() { TagNodeCompound tree = new TagNodeCompound(); TagNodeList pos = new TagNodeList(TagType.TAG_DOUBLE); pos.Add(new TagNodeDouble(_pos.X)); pos.Add(new TagNodeDouble(_pos.Y)); pos.Add(new TagNodeDouble(_pos.Z)); tree["Pos"] = pos; TagNodeList motion = new TagNodeList(TagType.TAG_DOUBLE); motion.Add(new TagNodeDouble(_motion.X)); motion.Add(new TagNodeDouble(_motion.Y)); motion.Add(new TagNodeDouble(_motion.Z)); tree["Motion"] = motion; TagNodeList rotation = new TagNodeList(TagType.TAG_FLOAT); rotation.Add(new TagNodeFloat((float)_rotation.Yaw)); rotation.Add(new TagNodeFloat((float)_rotation.Pitch)); tree["Rotation"] = rotation; tree["FallDistance"] = new TagNodeFloat(_fallDistance); tree["Fire"] = new TagNodeShort(_fire); tree["Air"] = new TagNodeShort(_air); tree["OnGround"] = new TagNodeByte(_onGround); return(tree); }
/// <summary> /// Builds a Player subtree from the current data. /// </summary> /// <returns>The root node of a Player subtree representing the current data.</returns> public virtual new 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); tree["Dimension"] = new TagNodeInt(_dimension); tree["Sleeping"] = new TagNodeByte(_sleeping); tree["SleepTimer"] = new TagNodeShort(_sleepTimer); if (_spawnX != null && _spawnY != null && _spawnZ != null) { tree["SpawnX"] = new TagNodeInt(_spawnX ?? 0); tree["SpawnY"] = new TagNodeInt(_spawnY ?? 0); tree["SpawnZ"] = new TagNodeInt(_spawnZ ?? 0); } if (_world != null) { tree["World"] = new TagNodeString(_world); } tree["Inventory"] = _inventory.BuildTree(); return(tree); }
/// <inheritdoc/> public TagNode BuildTree() { TagNodeCompound tree = new TagNodeCompound(); tree["id"] = new TagNodeString(_id); tree["Count"] = new TagNodeByte(_count); tree["Damage"] = new TagNodeShort(_damage); if (_enchantments.Count > 0) { TagNodeList enchList = new TagNodeList(TagType.TAG_COMPOUND); foreach (Enchantment e in _enchantments) { enchList.Add(e.BuildTree()); } TagNodeCompound tagtree = new TagNodeCompound(); tagtree["ench"] = enchList; if (_source != null && _source.ContainsKey("tag")) { tagtree.MergeFrom(_source["tag"].ToTagCompound()); } tree["tag"] = tagtree; } if (_source != null) { tree.MergeFrom(_source); } 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["carried"] = new TagNodeShort(_carried); tree["carriedData"] = new TagNodeShort(_carryingData); return tree; }
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["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["Items"] = _items.BuildTree(); tree["BrewTime"] = new TagNodeShort(_brewTime); return(tree); }
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); tree["CanPickUpLoot"] = new TagNodeByte(_canPickUpLoot); tree["PersistenceRequired"] = new TagNodeByte(_persistenceRequired); tree["CustomName"] = new TagNodeString(_customName); tree["CustomNameVisible"] = new TagNodeByte(_customNameVisible); if (_activeEffects != null) { TagNodeList effects = new TagNodeList(TagType.TAG_COMPOUND); foreach (ActiveEffects effect in _activeEffects) { if (!effect.IsValid) { continue; } TagNodeCompound ae = new TagNodeCompound(); ae["Id"] = new TagNodeByte((byte)effect.Id); ae["Amplifier"] = new TagNodeByte((byte)effect.Amplifier); ae["Duration"] = new TagNodeInt(effect.Duration); ae["Ambient"] = new TagNodeByte(effect.Ambient ? (byte)1 : (byte)0); effects.Add(ae); } tree["ActiveEffects"] = effects; } if (_equipment != null) { TagNodeList equipment = new TagNodeList(TagType.TAG_COMPOUND); foreach (Item item in _equipment) { equipment.Add(item.BuildTree()); } tree["Equipment"] = equipment; } if (_dropChances != null) { TagNodeList dropChances = new TagNodeList(TagType.TAG_FLOAT); foreach (float dc in _dropChances) { dropChances.Add(new TagNodeFloat(dc)); } tree["DropChances"] = dropChances; } 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); }
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); }
/// <inheritdoc/> public TagNode BuildTree() { TagNodeCompound tree = new TagNodeCompound(); tree["id"] = new TagNodeShort(_id); tree["Count"] = new TagNodeByte(_count); tree["Damage"] = new TagNodeShort(_damage); return(tree); }
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["xTile"] = new TagNodeShort(_xTile); tree["yTile"] = new TagNodeShort(_yTile); tree["zTile"] = new TagNodeShort(_zTile); tree["inTile"] = new TagNodeByte(_inTile); tree["inGround"] = new TagNodeByte(_inGround); 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); }
/// <inheritdoc /> public TagNode BuildTree() { TagNodeCompound tree = new TagNodeCompound(); tree["id"] = new TagNodeShort(_id); tree["lvl"] = new TagNodeShort(_level); if (_source != null) { tree.MergeFrom(_source); } return(tree); }
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); }
/// <summary> /// Builds a Map subtree from the current data. /// </summary> /// <returns>The root node of a Map subtree representing the current data.</returns> public virtual TagNode BuildTree() { TagNodeCompound data = new TagNodeCompound(); data["scale"] = new TagNodeByte(_scale); data["dimension"] = new TagNodeByte(_dimension); data["height"] = new TagNodeShort(_height); data["width"] = new TagNodeShort(_width); data["xCenter"] = new TagNodeInt(_x); data["zCenter"] = new TagNodeInt(_z); data["colors"] = new TagNodeByteArray(_colors); if (_source != null) { data.MergeFrom(_source); } TagNodeCompound tree = new TagNodeCompound(); tree.Add("data", data); return(tree); }
/// <inheritdoc/> public TagNode BuildTree() { TagNodeCompound tree = new TagNodeCompound(); tree["id"] = new TagNodeShort(_id); tree["Count"] = new TagNodeByte(_count); tree["Damage"] = new TagNodeShort(_damage); TagNodeCompound tagtree = new TagNodeCompound(); if (_enchantments.Count > 0) { TagNodeList enchList = new TagNodeList(TagType.TAG_COMPOUND); foreach (Enchantment e in _enchantments) { enchList.Add(e.BuildTree()); } tagtree["ench"] = enchList; if (_source != null && _source.ContainsKey("tag")) { tagtree.MergeFrom(_source["tag"].ToTagCompound()); } } if (_storedEnchantments.Count > 0) { TagNodeList storedEnchList = new TagNodeList(TagType.TAG_COMPOUND); foreach (Enchantment e in _storedEnchantments) { storedEnchList.Add(e.BuildTree()); } tagtree["StoredEnchantments"] = storedEnchList; if (_source != null && _source.ContainsKey("tag")) { tagtree.MergeFrom(_source["tag"].ToTagCompound()); } } if (_name != null || _lore != null || _color != 0) { TagNodeCompound displayTag = new TagNodeCompound(); if (_color != 0) { displayTag.Add("color", new TagNodeInt(_color)); } if (_name != null) { displayTag.Add("Name", new TagNodeString(_name)); } if (_lore != null) { List <TagNode> LoreList = new List <TagNode>(); string[] lores = _lore.Split('\n'); foreach (string lore in lores) { LoreList.Add(new TagNodeString(lore)); } displayTag.Add("Lore", new TagNodeList(TagType.TAG_STRING, LoreList)); } tagtree["display"] = displayTag; } if (tagtree.Count > 0) { tree["tag"] = tagtree; } if (_source != null) { tree.MergeFrom(_source); } return(tree); }
/// <summary> /// Builds a Player subtree from the current data. /// </summary> /// <returns>The root node of a Player subtree representing the current data.</returns> public virtual new 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); tree["Dimension"] = new TagNodeInt(_dimension); tree["Sleeping"] = new TagNodeByte(_sleeping); tree["SleepTimer"] = new TagNodeShort(_sleepTimer); if (_spawnX != null && _spawnY != null && _spawnZ != null) { tree["SpawnX"] = new TagNodeInt(_spawnX ?? 0); tree["SpawnY"] = new TagNodeInt(_spawnY ?? 0); tree["SpawnZ"] = new TagNodeInt(_spawnZ ?? 0); } else { tree.Remove("SpawnX"); tree.Remove("SpawnY"); tree.Remove("SpawnZ"); } if (_world != null) { tree["World"] = new TagNodeString(_world); } if (_foodLevel != null) { tree["foodLevel"] = new TagNodeInt(_foodLevel ?? 0); } if (_foodTickTimer != null) { tree["foodTickTimer"] = new TagNodeInt(_foodTickTimer ?? 0); } if (_foodExhaustion != null) { tree["foodExhaustionLevel"] = new TagNodeFloat(_foodExhaustion ?? 0); } if (_foodSaturation != null) { tree["foodSaturation"] = new TagNodeFloat(_foodSaturation ?? 0); } if (_xpP != null) { tree["XpP"] = new TagNodeFloat(_xpP ?? 0); } if (_xpLevel != null) { tree["XpLevel"] = new TagNodeInt(_xpLevel ?? 0); } if (_xpTotal != null) { tree["XpTotal"] = new TagNodeInt(_xpTotal ?? 0); } if (_score != null) { tree["Score"] = new TagNodeInt(_score ?? 0); } if (_gameType != null) { tree["PlayerGameType"] = new TagNodeInt((int)(_gameType ?? PlayerGameType.Survival)); } if (AbilitiesSet()) { TagNodeCompound pb = new TagNodeCompound(); pb["flying"] = new TagNodeByte(_abilities.Flying ? (byte)1 : (byte)0); pb["instabuild"] = new TagNodeByte(_abilities.InstantBuild ? (byte)1 : (byte)0); pb["mayfly"] = new TagNodeByte(_abilities.MayFly ? (byte)1 : (byte)0); pb["invulnerable"] = new TagNodeByte(_abilities.Invulnerable ? (byte)1 : (byte)0); pb["mayBuild"] = new TagNodeByte(_abilities.MayBuild ? (byte)1 : (byte)0); pb["walkSpeed"] = new TagNodeFloat(_abilities.WalkSpeed); pb["flySpeed"] = new TagNodeFloat(_abilities.FlySpeed); tree["abilities"] = pb; } tree["Inventory"] = _inventory.BuildTree(); tree["EnderItems"] = _enderItems.BuildTree(); return(tree); }
/// <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 (EntityTyped 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(); }
public TagShortDataNode(TagNodeShort tag) : base(tag) { }