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-06-30 04:41:29 +00:00
|
|
|
|
using Substrate.Nbt;
|
2011-04-06 19:41:57 +00:00
|
|
|
|
|
|
|
|
|
public class TileEntityFurnace : TileEntity, IItemContainer
|
|
|
|
|
{
|
2011-06-28 03:41:44 +00:00
|
|
|
|
public static readonly SchemaNodeCompound FurnaceSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("")
|
2011-04-06 19:41:57 +00:00
|
|
|
|
{
|
2011-06-20 03:51:40 +00:00
|
|
|
|
new SchemaNodeString("id", "Furnace"),
|
|
|
|
|
new SchemaNodeScaler("BurnTime", TagType.TAG_SHORT),
|
|
|
|
|
new SchemaNodeScaler("CookTime", TagType.TAG_SHORT),
|
|
|
|
|
new SchemaNodeList("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-06-20 03:51:40 +00:00
|
|
|
|
public override TileEntity LoadTree (TagNode tree)
|
2011-04-06 19:41:57 +00:00
|
|
|
|
{
|
2011-06-20 03:51:40 +00:00
|
|
|
|
TagNodeCompound ctree = tree as TagNodeCompound;
|
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-06-20 03:51:40 +00:00
|
|
|
|
TagNodeList items = ctree["Items"].ToTagList();
|
2011-04-06 19:41:57 +00:00
|
|
|
|
_items = new ItemCollection(_CAPACITY).LoadTree(items);
|
|
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-20 03:51:40 +00:00
|
|
|
|
public override TagNode BuildTree ()
|
2011-04-06 19:41:57 +00:00
|
|
|
|
{
|
2011-06-20 03:51:40 +00:00
|
|
|
|
TagNodeCompound tree = base.BuildTree() as TagNodeCompound;
|
|
|
|
|
tree["BurnTime"] = new TagNodeShort(_burnTime);
|
|
|
|
|
tree["CookTime"] = new TagNodeShort(_cookTime);
|
2011-04-06 19:41:57 +00:00
|
|
|
|
tree["Items"] = _items.BuildTree();
|
|
|
|
|
|
|
|
|
|
return tree;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-20 03:51:40 +00:00
|
|
|
|
public override bool ValidateTree (TagNode tree)
|
2011-04-06 19:41:57 +00:00
|
|
|
|
{
|
2011-06-30 04:57:18 +00:00
|
|
|
|
return new NbtVerifier(tree, FurnaceSchema).Verify();
|
2011-04-06 19:41:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|