diff --git a/SubstrateCS/Source/Core/BlockTileEntities.cs b/SubstrateCS/Source/Core/BlockTileEntities.cs index 4876da6..a934a3b 100644 --- a/SubstrateCS/Source/Core/BlockTileEntities.cs +++ b/SubstrateCS/Source/Core/BlockTileEntities.cs @@ -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) diff --git a/SubstrateCS/Source/TileEntityFactory.cs b/SubstrateCS/Source/TileEntityFactory.cs index cb2f033..6704c64 100644 --- a/SubstrateCS/Source/TileEntityFactory.cs +++ b/SubstrateCS/Source/TileEntityFactory.cs @@ -36,12 +36,13 @@ namespace Substrate /// /// A representing a single Tile Entity, containing an 'id' field of the Tile Entity's registered name. /// A new instance of a concrete type, or null if no type was registered with the given name. - 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); } + /// + /// Create a new instance of a concrete type by NBT node. + /// + /// A representing a single Tile Entity, containing an 'id' field of the Tile Entity's registered name. + /// A new instance of a concrete type, or null if no type was registered with the given name. + 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); + } + /// /// Lookup a concrete type by name. ///