Merge branch 'master' of github.com:jaquadro/Substrate

This commit is contained in:
Justin Aquadro 2012-11-10 12:12:09 -05:00
commit 8c771f3308
2 changed files with 25 additions and 3 deletions

View file

@ -43,7 +43,7 @@ namespace Substrate.Core
return null;
}
return TileEntityFactory.Create(te);
return TileEntityFactory.CreateGeneric(te);
}
public void SetTileEntity (int x, int y, int z, TileEntity te)

View file

@ -36,12 +36,13 @@ namespace Substrate
/// </summary>
/// <param name="tree">A <see cref="TagNodeCompound"/> representing a single Tile Entity, containing an 'id' field of the Tile Entity's registered name.</param>
/// <returns>A new instance of a concrete <see cref="TileEntity"/> type, or null if no type was registered with the given name.</returns>
public static TileEntity Create (TagNodeCompound tree)
public static TileEntity Create(TagNodeCompound tree)
{
string type = tree["id"].ToTagString();
Type t;
if (!_registry.TryGetValue(type, out t)) {
if (!_registry.TryGetValue(type, out t))
{
return null;
}
@ -50,6 +51,27 @@ namespace Substrate
return te.LoadTreeSafe(tree);
}
/// <summary>
/// Create a new instance of a concrete <see cref="TileEntity"/> type by NBT node.
/// </summary>
/// <param name="tree">A <see cref="TagNodeCompound"/> representing a single Tile Entity, containing an 'id' field of the Tile Entity's registered name.</param>
/// <returns>A new instance of a concrete <see cref="TileEntity"/> type, or null if no type was registered with the given name.</returns>
public static TileEntity CreateGeneric(TagNodeCompound tree)
{
string type = tree["id"].ToTagString();
Type t;
if (!_registry.TryGetValue(type, out t))
{
t = typeof (TileEntity);
}
TileEntity te = Activator.CreateInstance(t, true) as TileEntity;
return te.LoadTreeSafe(tree);
}
/// <summary>
/// Lookup a concrete <see cref="TileEntity"/> type by name.
/// </summary>