Factored TypeId out of TileEntity types, added Piston to TileEntity registry

This commit is contained in:
Justin Aquadro 2011-11-05 14:30:59 -04:00
parent 5997c362fd
commit c10ee4215f
12 changed files with 147 additions and 36 deletions

View file

@ -9,22 +9,32 @@ namespace Substrate.TileEntities
{ {
public static readonly SchemaNodeCompound BrewingStandSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("") public static readonly SchemaNodeCompound BrewingStandSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("")
{ {
new SchemaNodeString("id", "Cauldron"), new SchemaNodeString("id", TypeId),
new SchemaNodeList("Items", TagType.TAG_COMPOUND, ItemCollection.Schema), new SchemaNodeList("Items", TagType.TAG_COMPOUND, ItemCollection.Schema),
new SchemaNodeScaler("BrewTime", TagType.TAG_SHORT), new SchemaNodeScaler("BrewTime", TagType.TAG_SHORT),
}); });
public static string TypeId
{
get { return "Cauldron"; }
}
private const int _CAPACITY = 4; private const int _CAPACITY = 4;
private ItemCollection _items; private ItemCollection _items;
private short _brewTime; private short _brewTime;
public TileEntityBrewingStand () protected TileEntityBrewingStand (string id)
: base("Cauldron") : base(id)
{ {
_items = new ItemCollection(_CAPACITY); _items = new ItemCollection(_CAPACITY);
} }
public TileEntityBrewingStand ()
: this(TypeId)
{
}
public TileEntityBrewingStand (TileEntity te) public TileEntityBrewingStand (TileEntity te)
: base(te) : base(te)
{ {

View file

@ -9,20 +9,30 @@ namespace Substrate.TileEntities
{ {
public static readonly SchemaNodeCompound ChestSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("") public static readonly SchemaNodeCompound ChestSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("")
{ {
new SchemaNodeString("id", "Chest"), new SchemaNodeString("id", TypeId),
new SchemaNodeList("Items", TagType.TAG_COMPOUND, ItemCollection.Schema), new SchemaNodeList("Items", TagType.TAG_COMPOUND, ItemCollection.Schema),
}); });
public static string TypeId
{
get { return "Chest"; }
}
private const int _CAPACITY = 27; private const int _CAPACITY = 27;
private ItemCollection _items; private ItemCollection _items;
public TileEntityChest () protected TileEntityChest (string id)
: base("Chest") : base(id)
{ {
_items = new ItemCollection(_CAPACITY); _items = new ItemCollection(_CAPACITY);
} }
public TileEntityChest ()
: this(TypeId)
{
}
public TileEntityChest (TileEntity te) public TileEntityChest (TileEntity te)
: base(te) : base(te)
{ {

View file

@ -10,11 +10,21 @@ namespace Substrate.TileEntities
{ {
public static readonly SchemaNodeCompound EnchantTableSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("") public static readonly SchemaNodeCompound EnchantTableSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("")
{ {
new SchemaNodeString("id", "EnchantTable"), new SchemaNodeString("id", TypeId),
}); });
public static string TypeId
{
get { return "EnchantTable"; }
}
protected TileEntityEnchantmentTable (string id)
: base(id)
{
}
public TileEntityEnchantmentTable () public TileEntityEnchantmentTable ()
: base("EnchantTable") : this(TypeId)
{ {
} }

View file

@ -10,11 +10,21 @@ namespace Substrate.TileEntities
{ {
public static readonly SchemaNodeCompound EndPortalSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("") public static readonly SchemaNodeCompound EndPortalSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("")
{ {
new SchemaNodeString("id", "Airportal"), new SchemaNodeString("id", TypeId),
}); });
public static string TypeId
{
get { return "Airportal"; }
}
protected TileEntityEndPortal (string id)
: base(id)
{
}
public TileEntityEndPortal () public TileEntityEndPortal ()
: base("Airportal") : this(TypeId)
{ {
} }

View file

@ -9,12 +9,17 @@ namespace Substrate.TileEntities
{ {
public static readonly SchemaNodeCompound FurnaceSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("") public static readonly SchemaNodeCompound FurnaceSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("")
{ {
new SchemaNodeString("id", "Furnace"), new SchemaNodeString("id", TypeId),
new SchemaNodeScaler("BurnTime", TagType.TAG_SHORT), new SchemaNodeScaler("BurnTime", TagType.TAG_SHORT),
new SchemaNodeScaler("CookTime", TagType.TAG_SHORT), new SchemaNodeScaler("CookTime", TagType.TAG_SHORT),
new SchemaNodeList("Items", TagType.TAG_COMPOUND, ItemCollection.Schema), new SchemaNodeList("Items", TagType.TAG_COMPOUND, ItemCollection.Schema),
}); });
public static string TypeId
{
get { return "Furnace"; }
}
private const int _CAPACITY = 3; private const int _CAPACITY = 3;
private short _burnTime; private short _burnTime;
@ -34,12 +39,17 @@ namespace Substrate.TileEntities
set { _cookTime = (short)value; } set { _cookTime = (short)value; }
} }
public TileEntityFurnace () protected TileEntityFurnace (string id)
: base("Furnace") : base(id)
{ {
_items = new ItemCollection(_CAPACITY); _items = new ItemCollection(_CAPACITY);
} }
public TileEntityFurnace ()
: this(TypeId)
{
}
public TileEntityFurnace (TileEntity te) public TileEntityFurnace (TileEntity te)
: base(te) : base(te)
{ {

View file

@ -10,11 +10,16 @@ namespace Substrate.TileEntities
{ {
public static readonly SchemaNodeCompound MobSpawnerSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("") public static readonly SchemaNodeCompound MobSpawnerSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("")
{ {
new SchemaNodeString("id", "MobSpawner"), new SchemaNodeString("id", TypeId),
new SchemaNodeScaler("EntityId", TagType.TAG_STRING), new SchemaNodeScaler("EntityId", TagType.TAG_STRING),
new SchemaNodeScaler("Delay", TagType.TAG_SHORT), new SchemaNodeScaler("Delay", TagType.TAG_SHORT),
}); });
public static string TypeId
{
get { return "MobSpawner"; }
}
private short _delay; private short _delay;
private string _entityID; private string _entityID;
@ -30,8 +35,13 @@ namespace Substrate.TileEntities
set { _entityID = value; } set { _entityID = value; }
} }
protected TileEntityMobSpawner (string id)
: base(id)
{
}
public TileEntityMobSpawner () public TileEntityMobSpawner ()
: base("MobSpawner") : this(TypeId)
{ {
} }

View file

@ -10,10 +10,15 @@ namespace Substrate.TileEntities
{ {
public static readonly SchemaNodeCompound MusicSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("") public static readonly SchemaNodeCompound MusicSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("")
{ {
new SchemaNodeString("id", "Music"), new SchemaNodeString("id", TypeId),
new SchemaNodeScaler("note", TagType.TAG_BYTE), new SchemaNodeScaler("note", TagType.TAG_BYTE),
}); });
public static string TypeId
{
get { return "Music"; }
}
private byte _note; private byte _note;
public int Note public int Note
@ -22,8 +27,13 @@ namespace Substrate.TileEntities
set { _note = (byte)value; } set { _note = (byte)value; }
} }
protected TileEntityMusic (string id)
: base(id)
{
}
public TileEntityMusic () public TileEntityMusic ()
: base("Music") : this(TypeId)
{ {
} }

View file

@ -10,7 +10,7 @@ namespace Substrate.TileEntities
{ {
public static readonly SchemaNodeCompound PistonSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("") public static readonly SchemaNodeCompound PistonSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("")
{ {
new SchemaNodeString("id", "Piston"), new SchemaNodeString("id", TypeId),
new SchemaNodeScaler("blockId", TagType.TAG_INT), new SchemaNodeScaler("blockId", TagType.TAG_INT),
new SchemaNodeScaler("blockData", TagType.TAG_INT), new SchemaNodeScaler("blockData", TagType.TAG_INT),
new SchemaNodeScaler("facing", TagType.TAG_INT), new SchemaNodeScaler("facing", TagType.TAG_INT),
@ -18,6 +18,11 @@ namespace Substrate.TileEntities
new SchemaNodeScaler("extending", TagType.TAG_BYTE), new SchemaNodeScaler("extending", TagType.TAG_BYTE),
}); });
public static string TypeId
{
get { return "Piston"; }
}
private int? _record = null; private int? _record = null;
private byte _extending; private byte _extending;
@ -56,8 +61,13 @@ namespace Substrate.TileEntities
set { _progress = value; } set { _progress = value; }
} }
protected TileEntityPiston (string id)
: base(id)
{
}
public TileEntityPiston () public TileEntityPiston ()
: base("Piston") : this(TypeId)
{ {
} }

View file

@ -10,10 +10,15 @@ namespace Substrate.TileEntities
{ {
public static readonly SchemaNodeCompound RecordPlayerSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("") public static readonly SchemaNodeCompound RecordPlayerSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("")
{ {
new SchemaNodeString("id", "RecordPlayer"), new SchemaNodeString("id", TypeId),
new SchemaNodeScaler("Record", TagType.TAG_INT, SchemaOptions.OPTIONAL), new SchemaNodeScaler("Record", TagType.TAG_INT, SchemaOptions.OPTIONAL),
}); });
public static string TypeId
{
get { return "RecordPlayer"; }
}
private int? _record = null; private int? _record = null;
public int? Record public int? Record
@ -22,8 +27,13 @@ namespace Substrate.TileEntities
set { _record = value; } set { _record = value; }
} }
protected TileEntityRecordPlayer (string id)
: base(id)
{
}
public TileEntityRecordPlayer () public TileEntityRecordPlayer ()
: base("RecordPlayer") : this(TypeId)
{ {
} }

View file

@ -10,13 +10,18 @@ namespace Substrate.TileEntities
{ {
public static readonly SchemaNodeCompound SignSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("") public static readonly SchemaNodeCompound SignSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("")
{ {
new SchemaNodeString("id", "Sign"), new SchemaNodeString("id", TypeId),
new SchemaNodeScaler("Text1", TagType.TAG_STRING), new SchemaNodeScaler("Text1", TagType.TAG_STRING),
new SchemaNodeScaler("Text2", TagType.TAG_STRING), new SchemaNodeScaler("Text2", TagType.TAG_STRING),
new SchemaNodeScaler("Text3", TagType.TAG_STRING), new SchemaNodeScaler("Text3", TagType.TAG_STRING),
new SchemaNodeScaler("Text4", TagType.TAG_STRING), new SchemaNodeScaler("Text4", TagType.TAG_STRING),
}); });
public static string TypeId
{
get { return "Sign"; }
}
private string _text1 = ""; private string _text1 = "";
private string _text2 = ""; private string _text2 = "";
private string _text3 = ""; private string _text3 = "";
@ -46,8 +51,13 @@ namespace Substrate.TileEntities
set { _text4 = value.Substring(0, 14); } set { _text4 = value.Substring(0, 14); }
} }
protected TileEntitySign (string id)
: base(id)
{
}
public TileEntitySign () public TileEntitySign ()
: base("Sign") : this(TypeId)
{ {
} }

View file

@ -9,20 +9,30 @@ namespace Substrate.TileEntities
{ {
public static readonly SchemaNodeCompound TrapSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("") public static readonly SchemaNodeCompound TrapSchema = TileEntity.Schema.MergeInto(new SchemaNodeCompound("")
{ {
new SchemaNodeString("id", "Trap"), new SchemaNodeString("id", TypeId),
new SchemaNodeList("Items", TagType.TAG_COMPOUND, ItemCollection.Schema), new SchemaNodeList("Items", TagType.TAG_COMPOUND, ItemCollection.Schema),
}); });
public static string TypeId
{
get { return "Trap"; }
}
private const int _CAPACITY = 8; private const int _CAPACITY = 8;
private ItemCollection _items; private ItemCollection _items;
public TileEntityTrap () protected TileEntityTrap (string id)
: base("Trap") : base(id)
{ {
_items = new ItemCollection(_CAPACITY); _items = new ItemCollection(_CAPACITY);
} }
public TileEntityTrap ()
: this(TypeId)
{
}
public TileEntityTrap (TileEntity te) public TileEntityTrap (TileEntity te)
: base(te) : base(te)
{ {

View file

@ -77,16 +77,17 @@ namespace Substrate
static TileEntityFactory () static TileEntityFactory ()
{ {
_registry["Airportal"] = typeof(TileEntityEndPortal); _registry[TileEntityEndPortal.TypeId] = typeof(TileEntityEndPortal);
_registry["Cauldron"] = typeof(TileEntityBrewingStand); _registry[TileEntityBrewingStand.TypeId] = typeof(TileEntityBrewingStand);
_registry["Chest"] = typeof(TileEntityChest); _registry[TileEntityChest.TypeId] = typeof(TileEntityChest);
_registry["EnchantTable"] = typeof(TileEntityEnchantmentTable); _registry[TileEntityEnchantmentTable.TypeId] = typeof(TileEntityEnchantmentTable);
_registry["Furnace"] = typeof(TileEntityFurnace); _registry[TileEntityFurnace.TypeId] = typeof(TileEntityFurnace);
_registry["MobSpawner"] = typeof(TileEntityMobSpawner); _registry[TileEntityMobSpawner.TypeId] = typeof(TileEntityMobSpawner);
_registry["Music"] = typeof(TileEntityMusic); _registry[TileEntityMusic.TypeId] = typeof(TileEntityMusic);
_registry["RecordPlayer"] = typeof(TileEntityRecordPlayer); _registry[TileEntityPiston.TypeId] = typeof(TileEntityPiston);
_registry["Sign"] = typeof(TileEntitySign); _registry[TileEntityRecordPlayer.TypeId] = typeof(TileEntityRecordPlayer);
_registry["Trap"] = typeof(TileEntityTrap); _registry[TileEntitySign.TypeId] = typeof(TileEntitySign);
_registry[TileEntityTrap.TypeId] = typeof(TileEntityTrap);
} }
} }