forked from mirrors/NBTExplorer
Merge branch 'master' of github.com:jaquadro/Substrate
This commit is contained in:
commit
8c771f3308
2 changed files with 25 additions and 3 deletions
|
@ -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)
|
||||
|
|
|
@ -41,7 +41,8 @@ namespace Substrate
|
|||
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>
|
||||
|
|
Loading…
Reference in a new issue