forked from mirrors/NBTExplorer
Added TileEntity for jukebox (Record Player), a new change in 1.6. Fixed bug in note block TileEntity.
This commit is contained in:
parent
4097b44c22
commit
da05301983
4 changed files with 89 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<TileEntity> Members
|
||||
|
||||
public override TileEntity Copy ()
|
||||
{
|
||||
return new TileEntityRecordPlayer(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region INBTObject<TileEntity> 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
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Source\BlockFluid.cs" />
|
||||
<Compile Include="Source\Data.cs" />
|
||||
<Compile Include="Source\ItemInfo.cs" />
|
||||
<Compile Include="Source\ChunkCache.cs" />
|
||||
|
@ -138,6 +139,7 @@
|
|||
<Compile Include="Source\TileEntities\TileEntityFurnace.cs" />
|
||||
<Compile Include="Source\TileEntities\TileEntityMobSpawner.cs" />
|
||||
<Compile Include="Source\TileEntities\TileEntityMusic.cs" />
|
||||
<Compile Include="Source\TileEntities\TileEntityRecordPlayer.cs" />
|
||||
<Compile Include="Source\TileEntities\TileEntitySign.cs" />
|
||||
<Compile Include="Source\TileEntities\TileEntityTrap.cs" />
|
||||
<Compile Include="Source\TileEntity.cs" />
|
||||
|
|
Loading…
Reference in a new issue