2011-04-06 19:41:57 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
2011-04-06 21:20:35 +00:00
|
|
|
|
namespace Substrate.TileEntities
|
2011-04-06 19:41:57 +00:00
|
|
|
|
{
|
2011-04-06 21:20:35 +00:00
|
|
|
|
using Substrate.NBT;
|
2011-04-06 19:41:57 +00:00
|
|
|
|
|
|
|
|
|
public class TileEntityFurnace : TileEntity, IItemContainer
|
|
|
|
|
{
|
|
|
|
|
public static readonly NBTCompoundNode FurnaceSchema = BaseSchema.MergeInto(new NBTCompoundNode("")
|
|
|
|
|
{
|
|
|
|
|
new NBTStringNode("id", "Furnace"),
|
2011-04-09 02:50:42 +00:00
|
|
|
|
new NBTScalerNode("BurnTime", TagType.TAG_SHORT),
|
|
|
|
|
new NBTScalerNode("CookTime", TagType.TAG_SHORT),
|
2011-06-10 05:46:05 +00:00
|
|
|
|
new NBTListNode("Items", TagType.TAG_COMPOUND, ItemCollection.InventorySchema),
|
2011-04-06 19:41:57 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
private const int _CAPACITY = 3;
|
|
|
|
|
|
|
|
|
|
private short _burnTime;
|
|
|
|
|
private short _cookTime;
|
|
|
|
|
|
|
|
|
|
private ItemCollection _items;
|
|
|
|
|
|
|
|
|
|
public int BurnTime
|
|
|
|
|
{
|
|
|
|
|
get { return _burnTime; }
|
|
|
|
|
set { _burnTime = (short)value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int CookTime
|
|
|
|
|
{
|
|
|
|
|
get { return _cookTime; }
|
|
|
|
|
set { _cookTime = (short)value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TileEntityFurnace ()
|
|
|
|
|
: base("Furnace")
|
|
|
|
|
{
|
|
|
|
|
_items = new ItemCollection(_CAPACITY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TileEntityFurnace (TileEntity te)
|
|
|
|
|
: base(te)
|
|
|
|
|
{
|
|
|
|
|
TileEntityFurnace tec = te as TileEntityFurnace;
|
|
|
|
|
if (tec != null) {
|
|
|
|
|
_cookTime = tec._cookTime;
|
|
|
|
|
_burnTime = tec._burnTime;
|
|
|
|
|
_items = tec._items.Copy();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
_items = new ItemCollection(_CAPACITY);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region ICopyable<TileEntity> Members
|
|
|
|
|
|
|
|
|
|
public override TileEntity Copy ()
|
|
|
|
|
{
|
|
|
|
|
return new TileEntityFurnace(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region IItemContainer Members
|
|
|
|
|
|
|
|
|
|
public ItemCollection Items
|
|
|
|
|
{
|
|
|
|
|
get { return _items; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region INBTObject<TileEntity> Members
|
|
|
|
|
|
2011-04-09 02:50:42 +00:00
|
|
|
|
public override TileEntity LoadTree (TagValue tree)
|
2011-04-06 19:41:57 +00:00
|
|
|
|
{
|
2011-04-09 02:50:42 +00:00
|
|
|
|
TagCompound ctree = tree as TagCompound;
|
2011-04-06 19:41:57 +00:00
|
|
|
|
if (ctree == null || base.LoadTree(tree) == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-09 02:50:42 +00:00
|
|
|
|
_burnTime = ctree["BurnTime"].ToTagShort();
|
|
|
|
|
_cookTime = ctree["CookTime"].ToTagShort();
|
2011-04-06 19:41:57 +00:00
|
|
|
|
|
2011-04-09 02:50:42 +00:00
|
|
|
|
TagList items = ctree["Items"].ToTagList();
|
2011-04-06 19:41:57 +00:00
|
|
|
|
_items = new ItemCollection(_CAPACITY).LoadTree(items);
|
|
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-09 02:50:42 +00:00
|
|
|
|
public override TagValue BuildTree ()
|
2011-04-06 19:41:57 +00:00
|
|
|
|
{
|
2011-04-09 02:50:42 +00:00
|
|
|
|
TagCompound tree = base.BuildTree() as TagCompound;
|
|
|
|
|
tree["BurnTime"] = new TagShort(_burnTime);
|
|
|
|
|
tree["CookTime"] = new TagShort(_cookTime);
|
2011-04-06 19:41:57 +00:00
|
|
|
|
tree["Items"] = _items.BuildTree();
|
|
|
|
|
|
|
|
|
|
return tree;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-09 02:50:42 +00:00
|
|
|
|
public override bool ValidateTree (TagValue tree)
|
2011-04-06 19:41:57 +00:00
|
|
|
|
{
|
|
|
|
|
return new NBTVerifier(tree, FurnaceSchema).Verify();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|