diff --git a/fml/common/cpw/mods/fml/common/registry/VillagerRegistry.java b/fml/common/cpw/mods/fml/common/registry/VillagerRegistry.java index f59d46b79..ca64fb285 100644 --- a/fml/common/cpw/mods/fml/common/registry/VillagerRegistry.java +++ b/fml/common/cpw/mods/fml/common/registry/VillagerRegistry.java @@ -12,6 +12,8 @@ import com.google.common.collect.Multimap; import cpw.mods.fml.common.FMLLog; +import net.minecraft.src.ComponentVillage; +import net.minecraft.src.ComponentVillageStartPiece; import net.minecraft.src.EntityVillager; import net.minecraft.src.MapGenVillage; import net.minecraft.src.MerchantRecipeList; @@ -29,7 +31,7 @@ public class VillagerRegistry private static final VillagerRegistry INSTANCE = new VillagerRegistry(); private Multimap tradeHandlers = ArrayListMultimap.create(); - private List villageCreationHandlers = Lists.newArrayList(); + private Map, IVillageCreationHandler> villageCreationHandlers = Maps.newHashMap(); private Map newVillagers = Maps.newHashMap(); /** @@ -48,7 +50,30 @@ public class VillagerRegistry * @param i * @return */ - List getVillagePieces(Random random, int i); + StructureVillagePieceWeight getVillagePieceWeight(Random random, int i); + + /** + * The class of the root structure component to add to the village + * @return + */ + Class getComponentClass(); + + + /** + * Build an instance of the village component {@link StructureVillagePieces} + * @param villagePiece + * @param startPiece + * @param pieces + * @param random + * @param p1 + * @param p2 + * @param p3 + * @param p4 + * @param p5 + * @return + */ + Object buildComponent(StructureVillagePieceWeight villagePiece, ComponentVillageStartPiece startPiece, List pieces, Random random, int p1, + int p2, int p3, int p4, int p5); } /** @@ -98,7 +123,7 @@ public class VillagerRegistry */ public void registerVillageCreationHandler(IVillageCreationHandler handler) { - villageCreationHandlers.add(handler); + villageCreationHandlers.put(handler.getComponentClass(), handler); } /** @@ -147,10 +172,16 @@ public class VillagerRegistry public static void addExtraVillageComponents(ArrayList components, Random random, int i) { List parts = components; - for (IVillageCreationHandler handler : instance().villageCreationHandlers) + for (IVillageCreationHandler handler : instance().villageCreationHandlers.values()) { - parts.addAll(handler.getVillagePieces(random, i)); + parts.add(handler.getVillagePieceWeight(random, i)); } } + public static Object getVillageComponent(StructureVillagePieceWeight villagePiece, ComponentVillageStartPiece startPiece, List pieces, Random random, + int p1, int p2, int p3, int p4, int p5) + { + return instance().villageCreationHandlers.get(villagePiece.field_75090_a).buildComponent(villagePiece, startPiece, pieces, random, p1, p2, p3, p4, p5); + } + } diff --git a/fml/patches/common/net/minecraft/src/StructureVillagePieces.java.patch b/fml/patches/common/net/minecraft/src/StructureVillagePieces.java.patch index ea33c392b..2ecf588d6 100644 --- a/fml/patches/common/net/minecraft/src/StructureVillagePieces.java.patch +++ b/fml/patches/common/net/minecraft/src/StructureVillagePieces.java.patch @@ -18,3 +18,14 @@ Iterator var3 = var2.iterator(); while (var3.hasNext()) +@@ -91,6 +95,10 @@ + else if (var9 == ComponentVillageHouse3.class) + { + var10 = ComponentVillageHouse3.func_74921_a(p_75083_0_, p_75083_2_, p_75083_3_, p_75083_4_, p_75083_5_, p_75083_6_, p_75083_7_, p_75083_8_); ++ } ++ else ++ { ++ var10 = VillagerRegistry.getVillageComponent(p_75083_1_, p_75083_0_ , p_75083_2_, p_75083_3_, p_75083_4_, p_75083_5_, p_75083_6_, p_75083_7_, p_75083_8_); + } + + return (ComponentVillage)var10;