Re-add some missing villager profession patches (#5200)

* Fix zombie villagers only spawning with vanilla professions
* Fix spawning modded villagers that do not have their own building
This commit is contained in:
Ben Staddon 2019-04-11 18:50:01 -04:00 committed by tterrag
parent 7c401e9a35
commit 7496e3dbdf
3 changed files with 18 additions and 10 deletions

View File

@ -32,7 +32,15 @@
if (p_70037_1_.func_150297_b("ConversionTime", 99) && p_70037_1_.func_74762_e("ConversionTime") > -1) {
this.func_191991_a(p_70037_1_.func_186855_b("ConversionPlayer") ? p_70037_1_.func_186857_a("ConversionPlayer") : null, p_70037_1_.func_74762_e("ConversionTime"));
}
@@ -145,7 +153,7 @@
@@ -77,6 +85,7 @@
@Nullable
public IEntityLivingData func_204210_a(DifficultyInstance p_204210_1_, @Nullable IEntityLivingData p_204210_2_, @Nullable NBTTagCompound p_204210_3_) {
this.func_190733_a(this.field_70170_p.field_73012_v.nextInt(6));
+ net.minecraftforge.fml.common.registry.VillagerRegistry.setRandomProfession(this, this.field_70170_p.field_73012_v);
return super.func_204210_a(p_204210_1_, p_204210_2_, p_204210_3_);
}
@@ -145,7 +154,7 @@
protected void func_190738_dp() {
EntityVillager entityvillager = new EntityVillager(this.field_70170_p);
entityvillager.func_82149_j(this);
@ -41,7 +49,7 @@
entityvillager.func_190672_a(this.field_70170_p.func_175649_E(new BlockPos(entityvillager)), (IEntityLivingData)null, (NBTTagCompound)null, false);
entityvillager.func_82187_q();
if (this.func_70631_g_()) {
@@ -224,4 +232,28 @@
@@ -224,4 +233,28 @@
protected ItemStack func_190732_dj() {
return ItemStack.field_190927_a;
}

View File

@ -64,22 +64,24 @@
}
}
@@ -1480,13 +1492,12 @@
@@ -1480,13 +1492,14 @@
EntityZombieVillager entityzombievillager = new EntityZombieVillager(p_74893_1_.func_201672_e());
entityzombievillager.func_70012_b((double)j + 0.5D, (double)k, (double)l + 0.5D, 0.0F, 0.0F);
entityzombievillager.func_204210_a(p_74893_1_.func_175649_E(new BlockPos(entityzombievillager)), (IEntityLivingData)null, (NBTTagCompound)null);
- entityzombievillager.func_190733_a(this.func_180779_c(i, 0));
+ entityzombievillager.setProfession(this.chooseForgeProfession(i, net.minecraftforge.fml.common.registry.VillagerRegistry.FARMER.orElseThrow(() -> new IllegalStateException("Farmer profession not initialized?"))));
entityzombievillager.func_110163_bv();
p_74893_1_.func_72838_d(entityzombievillager);
} else {
EntityVillager entityvillager = new EntityVillager(p_74893_1_.func_201672_e());
entityvillager.func_70012_b((double)j + 0.5D, (double)k, (double)l + 0.5D, 0.0F, 0.0F);
- entityvillager.func_70938_b(this.func_180779_c(i, p_74893_1_.func_201674_k().nextInt(6)));
+ net.minecraftforge.fml.common.registry.VillagerRegistry.setRandomProfession(entityvillager, p_74893_1_.func_201674_k());
+ entityvillager.setProfession(this.chooseForgeProfession(i, entityvillager.getProfessionForge()));
entityvillager.func_190672_a(p_74893_1_.func_175649_E(new BlockPos(entityvillager)), (IEntityLivingData)null, (NBTTagCompound)null, false);
p_74893_1_.func_72838_d(entityvillager);
}
@@ -1495,11 +1506,19 @@
@@ -1495,11 +1508,19 @@
}
}

View File

@ -320,12 +320,10 @@ public class VillagerRegistry
entity.setProfession(INSTANCE.REGISTRY.getRandom(rand));
}
public static void setRandomProfession(EntityZombieVillager entity, Random rand)
{
entity.setProfession(INSTANCE.REGISTRY.getRandom(rand));
}
//Below this is INTERNAL USE ONLY DO NOT USE MODDERS
public static void onSetProfession(EntityVillager entity, int network)