From 472ca8c8a9c19de4d2f5a2b7441c7ff092cada7e Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 22 Jan 2013 13:11:32 -0500 Subject: [PATCH] Add in a registry method to allow for alternative TileEntity names- they will be used to support loading maps containing the older definitions. --- .../fml/common/registry/GameRegistry.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/fml/common/cpw/mods/fml/common/registry/GameRegistry.java b/fml/common/cpw/mods/fml/common/registry/GameRegistry.java index 9e79f374a5..a2b66c188b 100644 --- a/fml/common/cpw/mods/fml/common/registry/GameRegistry.java +++ b/fml/common/cpw/mods/fml/common/registry/GameRegistry.java @@ -45,6 +45,7 @@ import cpw.mods.fml.common.IWorldGenerator; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.LoaderException; import cpw.mods.fml.common.LoaderState; +import cpw.mods.fml.common.ObfuscationReflectionHelper; import cpw.mods.fml.common.Mod.Block; import cpw.mods.fml.common.ModContainer; @@ -278,6 +279,27 @@ public class GameRegistry TileEntity.func_70306_a(tileEntityClass, id); } + /** + * Register a tile entity, with alternative TileEntity identifiers. Use with caution! + * This method allows for you to "rename" the 'id' of the tile entity. + * + * @param tileEntityClass The tileEntity class to register + * @param id The primary ID, this will be the ID that the tileentity saves as + * @param alternatives A list of alternative IDs that will also map to this class. These will never save, but they will load + */ + public static void registerTileEntityWithAlternatives(Class tileEntityClass, String id, String... alternatives) + { + TileEntity.func_70306_a(tileEntityClass, id); + Map teMappings = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_70326_a", "a"); + for (String s: alternatives) + { + if (!teMappings.containsKey(s)) + { + teMappings.put(s, tileEntityClass); + } + } + } + public static void addBiome(BiomeGenBase biome) { WorldType.field_77137_b.addNewBiome(biome);