diff --git a/Substrate/SubstrateCS/Source/TileEntities/TileEntityMusic.cs b/Substrate/SubstrateCS/Source/TileEntities/TileEntityMusic.cs index a3aa274..c89a8e3 100644 --- a/Substrate/SubstrateCS/Source/TileEntities/TileEntityMusic.cs +++ b/Substrate/SubstrateCS/Source/TileEntities/TileEntityMusic.cs @@ -56,7 +56,7 @@ namespace Substrate.TileEntities return null; } - _note = ctree["Note"].ToTagByte(); + _note = ctree["note"].ToTagByte(); return this; } @@ -64,7 +64,7 @@ namespace Substrate.TileEntities public override TagValue BuildTree () { TagCompound tree = base.BuildTree() as TagCompound; - tree["Note"] = new TagByte(_note); + tree["note"] = new TagByte(_note); return tree; } diff --git a/Substrate/SubstrateCS/Source/TileEntities/TileEntityRecordPlayer.cs b/Substrate/SubstrateCS/Source/TileEntities/TileEntityRecordPlayer.cs new file mode 100644 index 0000000..e9b5ffb --- /dev/null +++ b/Substrate/SubstrateCS/Source/TileEntities/TileEntityRecordPlayer.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Substrate.TileEntities +{ + using Substrate.NBT; + + public class TileEntityRecordPlayer : TileEntity + { + public static readonly NBTCompoundNode RecordPlayerSchema = BaseSchema.MergeInto(new NBTCompoundNode("") + { + new NBTStringNode("id", "RecordPlayer"), + new NBTScalerNode("Record", TagType.TAG_INT, NBTOptions.OPTIONAL), + }); + + private int? _record = null; + + public int? Record + { + get { return _record; } + set { _record = value; } + } + + public TileEntityRecordPlayer () + : base("RecordPlayer") + { + } + + public TileEntityRecordPlayer (TileEntity te) + : base(te) + { + TileEntityRecordPlayer tes = te as TileEntityRecordPlayer; + if (tes != null) { + _record = tes._record; + } + } + + + #region ICopyable Members + + public override TileEntity Copy () + { + return new TileEntityRecordPlayer(this); + } + + #endregion + + + #region INBTObject Members + + public override TileEntity LoadTree (TagValue tree) + { + TagCompound ctree = tree as TagCompound; + if (ctree == null || base.LoadTree(tree) == null) { + return null; + } + + if (ctree.ContainsKey("Record")) { + _record = ctree["Record"].ToTagInt(); + } + + return this; + } + + public override TagValue BuildTree () + { + TagCompound tree = base.BuildTree() as TagCompound; + + if (_record != null) { + tree["Record"] = new TagInt((int)_record); + } + + return tree; + } + + public override bool ValidateTree (TagValue tree) + { + return new NBTVerifier(tree, RecordPlayerSchema).Verify(); + } + + #endregion + } +} diff --git a/Substrate/SubstrateCS/Source/TileEntityFactory.cs b/Substrate/SubstrateCS/Source/TileEntityFactory.cs index eeeeb83..4353644 100644 --- a/Substrate/SubstrateCS/Source/TileEntityFactory.cs +++ b/Substrate/SubstrateCS/Source/TileEntityFactory.cs @@ -58,6 +58,7 @@ namespace Substrate _registry["Furnace"] = typeof(TileEntityFurnace); _registry["MobSpawner"] = typeof(TileEntityMobSpawner); _registry["Music"] = typeof(TileEntityMusic); + _registry["RecordPlayer"] = typeof(TileEntityRecordPlayer); _registry["Sign"] = typeof(TileEntitySign); _registry["Trap"] = typeof(TileEntityTrap); } diff --git a/Substrate/SubstrateCS/Substrate.csproj b/Substrate/SubstrateCS/Substrate.csproj index f07b4d9..5dc035e 100644 --- a/Substrate/SubstrateCS/Substrate.csproj +++ b/Substrate/SubstrateCS/Substrate.csproj @@ -68,6 +68,7 @@ + @@ -138,6 +139,7 @@ +