NBTExplorer/SubstrateCS/Source/Entities/EntityFallingSand.cs

90 lines
2.1 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Text;
namespace Substrate.Entities
{
2011-06-30 04:41:29 +00:00
using Substrate.Nbt;
2011-08-14 19:34:49 +00:00
public class EntityFallingSand : TypedEntity
{
2011-08-14 19:34:49 +00:00
public static readonly SchemaNodeCompound FallingSandSchema = TypedEntity.Schema.MergeInto(new SchemaNodeCompound("")
{
new SchemaNodeString("id", TypeId),
new SchemaNodeScaler("Tile", TagType.TAG_BYTE),
});
public static string TypeId
{
get { return "FallingSand"; }
}
private byte _tile;
public int Tile
{
get { return _tile; }
set { _tile = (byte)value; }
}
protected EntityFallingSand (string id)
: base(id)
{
}
public EntityFallingSand ()
: this(TypeId)
{
}
2011-08-14 19:34:49 +00:00
public EntityFallingSand (TypedEntity e)
: base(e)
{
EntityFallingSand e2 = e as EntityFallingSand;
if (e2 != null) {
_tile = e2._tile;
}
}
#region INBTObject<Entity> Members
2011-08-14 19:34:49 +00:00
public override TypedEntity LoadTree (TagNode tree)
{
TagNodeCompound ctree = tree as TagNodeCompound;
if (ctree == null || base.LoadTree(tree) == null) {
return null;
}
_tile = ctree["Tile"].ToTagByte();
return this;
}
public override TagNode BuildTree ()
{
TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
tree["Tile"] = new TagNodeByte(_tile);
return tree;
}
public override bool ValidateTree (TagNode tree)
{
2011-06-30 04:57:18 +00:00
return new NbtVerifier(tree, FallingSandSchema).Verify();
}
#endregion
#region ICopyable<Entity> Members
2011-08-14 19:34:49 +00:00
public override TypedEntity Copy ()
{
return new EntityFallingSand(this);
}
#endregion
}
}