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 null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TileEntityFactory.Create(te);
|
return TileEntityFactory.CreateGeneric(te);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetTileEntity (int x, int y, int z, TileEntity te)
|
public void SetTileEntity (int x, int y, int z, TileEntity te)
|
||||||
|
|
|
@ -36,12 +36,13 @@ namespace Substrate
|
||||||
/// </summary>
|
/// </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>
|
/// <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>
|
/// <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();
|
string type = tree["id"].ToTagString();
|
||||||
|
|
||||||
Type t;
|
Type t;
|
||||||
if (!_registry.TryGetValue(type, out t)) {
|
if (!_registry.TryGetValue(type, out t))
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +51,27 @@ namespace Substrate
|
||||||
return te.LoadTreeSafe(tree);
|
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>
|
/// <summary>
|
||||||
/// Lookup a concrete <see cref="TileEntity"/> type by name.
|
/// Lookup a concrete <see cref="TileEntity"/> type by name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in a new issue