mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-16 10:34:49 +00:00
Village mating produces added villagers, and the egg should place
added villagers too. Closes #97.
This commit is contained in:
1 parent
6394ee8714
commit
2cf4917ded
3 files changed
+48
No files matched your search
@@ -15,6 +15,7 @@ import net.minecraft.src.StructureVillagePieces;
|
|||||||
import net.minecraft.src.Tuple;
|
import net.minecraft.src.Tuple;
|
||||||
|
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ public class VillagerRegistry
|
|||||||
private Multimap<Integer, IVillageTradeHandler> tradeHandlers = ArrayListMultimap.create();
|
private Multimap<Integer, IVillageTradeHandler> tradeHandlers = ArrayListMultimap.create();
|
||||||
private Map<Class<?>, IVillageCreationHandler> villageCreationHandlers = Maps.newHashMap();
|
private Map<Class<?>, IVillageCreationHandler> villageCreationHandlers = Maps.newHashMap();
|
||||||
private Map<Integer, String> newVillagers = Maps.newHashMap();
|
private Map<Integer, String> newVillagers = Maps.newHashMap();
|
||||||
|
private List<Integer> newVillagerIds = Lists.newArrayList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow access to the {@link StructureVillagePieces} array controlling new village
|
* Allow access to the {@link StructureVillagePieces} array controlling new village
|
||||||
@@ -114,6 +116,7 @@ public class VillagerRegistry
|
|||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
newVillagers.put(villagerId, villagerSkin);
|
newVillagers.put(villagerId, villagerSkin);
|
||||||
|
newVillagerIds.add(villagerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -202,4 +205,11 @@ public class VillagerRegistry
|
|||||||
}
|
}
|
||||||
villager.func_70949_b(list, item.func_77612_l(), random, chance);
|
villager.func_70949_b(list, item.func_77612_l(), random, chance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void applyRandomTrade(EntityVillager villager, Random rand)
|
||||||
|
{
|
||||||
|
int extra = instance().newVillagerIds.size();
|
||||||
|
int trade = rand.nextInt(5 + extra);
|
||||||
|
villager.func_70938_b(trade < 5 ? trade : instance().newVillagerIds.get(trade - 5));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
--- ../src-base/common/net/minecraft/src/EntityAIVillagerMate.java
|
||||||
|
+++ ../src-work/common/net/minecraft/src/EntityAIVillagerMate.java
|
||||||
|
@@ -1,4 +1,6 @@
|
||||||
|
package net.minecraft.src;
|
||||||
|
+
|
||||||
|
+import cpw.mods.fml.common.registry.VillagerRegistry;
|
||||||
|
|
||||||
|
public class EntityAIVillagerMate extends EntityAIBase
|
||||||
|
{
|
||||||
|
@@ -104,7 +106,7 @@
|
||||||
|
this.field_75451_c.func_70873_a(6000);
|
||||||
|
this.field_75450_b.func_70873_a(6000);
|
||||||
|
var1.func_70873_a(-24000);
|
||||||
|
- var1.func_70938_b(this.field_75450_b.func_70681_au().nextInt(5));
|
||||||
|
+ VillagerRegistry.applyRandomTrade(var1, this.field_75450_b.func_70681_au());
|
||||||
|
var1.func_70012_b(this.field_75450_b.field_70165_t, this.field_75450_b.field_70163_u, this.field_75450_b.field_70161_v, 0.0F, 0.0F);
|
||||||
|
this.field_75448_d.func_72838_d(var1);
|
||||||
|
this.field_75448_d.func_72960_a(var1, (byte)12);
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
--- ../src-base/common/net/minecraft/src/ItemMonsterPlacer.java
|
||||||
|
+++ ../src-work/common/net/minecraft/src/ItemMonsterPlacer.java
|
||||||
|
@@ -2,6 +2,8 @@
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.Side;
|
||||||
|
import cpw.mods.fml.common.asm.SideOnly;
|
||||||
|
+import cpw.mods.fml.common.registry.VillagerRegistry;
|
||||||
|
+
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@@ -80,7 +82,7 @@
|
||||||
|
if (var8 instanceof EntityVillager)
|
||||||
|
{
|
||||||
|
EntityVillager var9 = (EntityVillager)var8;
|
||||||
|
- var9.func_70938_b(var9.func_70681_au().nextInt(5));
|
||||||
|
+ VillagerRegistry.applyRandomTrade(var9, var9.func_70681_au());
|
||||||
|
p_77840_0_.func_72838_d(var9);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user