Expose more of the village construction parts for building village
pieces
This commit is contained in:
parent
52d3f237af
commit
45175c0e94
2 changed files with 47 additions and 5 deletions
|
@ -12,6 +12,8 @@ import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
import cpw.mods.fml.common.FMLLog;
|
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.EntityVillager;
|
||||||
import net.minecraft.src.MapGenVillage;
|
import net.minecraft.src.MapGenVillage;
|
||||||
import net.minecraft.src.MerchantRecipeList;
|
import net.minecraft.src.MerchantRecipeList;
|
||||||
|
@ -29,7 +31,7 @@ public class VillagerRegistry
|
||||||
private static final VillagerRegistry INSTANCE = new VillagerRegistry();
|
private static final VillagerRegistry INSTANCE = new VillagerRegistry();
|
||||||
|
|
||||||
private Multimap<Integer, IVillageTradeHandler> tradeHandlers = ArrayListMultimap.create();
|
private Multimap<Integer, IVillageTradeHandler> tradeHandlers = ArrayListMultimap.create();
|
||||||
private List<IVillageCreationHandler> villageCreationHandlers = Lists.newArrayList();
|
private Map<Class<?>, IVillageCreationHandler> villageCreationHandlers = Maps.newHashMap();
|
||||||
private Map<Integer, String> newVillagers = Maps.newHashMap();
|
private Map<Integer, String> newVillagers = Maps.newHashMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +50,30 @@ public class VillagerRegistry
|
||||||
* @param i
|
* @param i
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<StructureVillagePieceWeight> 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)
|
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)
|
public static void addExtraVillageComponents(ArrayList components, Random random, int i)
|
||||||
{
|
{
|
||||||
List<StructureVillagePieceWeight> parts = components;
|
List<StructureVillagePieceWeight> 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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,3 +18,14 @@
|
||||||
Iterator var3 = var2.iterator();
|
Iterator var3 = var2.iterator();
|
||||||
|
|
||||||
while (var3.hasNext())
|
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;
|
||||||
|
|
Loading…
Reference in a new issue