[1.11.2] Fixed Zombie Villagers not setting and getting professions correctly (#3678)

This commit is contained in:
Madsthunder 2017-05-01 00:59:57 -04:00 committed by LexManos
parent 460a2189d6
commit 93a4e13837
7 changed files with 97 additions and 8 deletions

View file

@ -0,0 +1,10 @@
--- ../src-base/minecraft/net/minecraft/client/renderer/entity/RenderZombieVillager.java
+++ ../src-work/minecraft/net/minecraft/client/renderer/entity/RenderZombieVillager.java
@@ -25,6 +25,7 @@
protected ResourceLocation func_110775_a(EntityZombieVillager p_110775_1_)
{
+ if (true) return p_110775_1_.getForgeProfession().getZombieSkin();
switch (p_110775_1_.func_190736_dl())
{
case 0:

View file

@ -1,17 +1,58 @@
--- ../src-base/minecraft/net/minecraft/entity/monster/EntityZombieVillager.java
+++ ../src-work/minecraft/net/minecraft/entity/monster/EntityZombieVillager.java
@@ -48,6 +48,7 @@
@@ -48,11 +48,14 @@
public void func_190733_a(int p_190733_1_)
{
this.field_70180_af.func_187227_b(field_190739_c, Integer.valueOf(p_190733_1_));
+ net.minecraftforge.fml.common.registry.VillagerRegistry.onSetProfession(this, p_190733_1_);
}
+ //Use Forge Variant below
+ @Deprecated
public int func_190736_dl()
@@ -85,6 +86,21 @@
return super.func_180482_a(p_180482_1_, p_180482_2_);
{
- return Math.max(((Integer)this.field_70180_af.func_187225_a(field_190739_c)).intValue() % 6, 0);
+ return Math.max(((Integer)this.field_70180_af.func_187225_a(field_190739_c)).intValue(), 0);
}
public static void func_190737_b(DataFixer p_190737_0_)
@@ -64,6 +67,7 @@
{
super.func_70014_b(p_70014_1_);
p_70014_1_.func_74768_a("Profession", this.func_190736_dl());
+ p_70014_1_.func_74778_a("ProfessionName", this.getForgeProfession().getRegistryName().toString());
p_70014_1_.func_74768_a("ConversionTime", this.func_82230_o() ? this.field_82234_d : -1);
}
@@ -71,6 +75,12 @@
{
super.func_70037_a(p_70037_1_);
this.func_190733_a(p_70037_1_.func_74762_e("Profession"));
+ if (p_70037_1_.func_74764_b("ProfessionName"))
+ {
+ net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession p = net.minecraftforge.fml.common.registry.VillagerRegistry.instance().getRegistry().getValue(new net.minecraft.util.ResourceLocation(p_70037_1_.func_74779_i("ProfessionName")));
+ if (p == null) p = net.minecraftforge.fml.common.registry.VillagerRegistry.FARMER;
+ this.setForgeProfession(p);
+ }
if (p_70037_1_.func_150297_b("ConversionTime", 99) && p_70037_1_.func_74762_e("ConversionTime") > -1)
{
@@ -164,7 +174,7 @@
{
EntityVillager entityvillager = new EntityVillager(this.field_70170_p);
entityvillager.func_82149_j(this);
- entityvillager.func_70938_b(this.func_190736_dl());
+ entityvillager.setProfession(this.getForgeProfession());
entityvillager.func_190672_a(this.field_70170_p.func_175649_E(new BlockPos(entityvillager)), (IEntityLivingData)null, false);
entityvillager.func_82187_q();
@@ -256,4 +266,37 @@
{
return ItemStack.field_190927_a;
}
+
+ /* ======================================== FORGE START =====================================*/
+
+ @Nullable
+ private net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession prof;
+ public void setForgeProfession(net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession prof)
@ -20,13 +61,26 @@
+ this.func_190733_a(net.minecraftforge.fml.common.registry.VillagerRegistry.getId(prof));
+ }
+
+ @Nullable
+ public net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession getForgeProfession()
+ {
+ if (this.prof == null)
+ {
+ this.prof = net.minecraftforge.fml.common.registry.VillagerRegistry.getById(this.func_190736_dl());
+ if (this.prof == null)
+ return net.minecraftforge.fml.common.registry.VillagerRegistry.FARMER;
+ }
+ return this.prof;
+ }
+
+ @Override
+ public void func_184206_a(DataParameter<?> key)
+ {
+ super.func_184206_a(key);
+ if (key.equals(field_190739_c))
+ {
+ net.minecraftforge.fml.common.registry.VillagerRegistry.onSetProfession(this, this.field_70180_af.func_187225_a(field_190739_c));
+ }
+ }
+
public void func_70071_h_()
{
if (!this.field_70170_p.field_72995_K && this.func_82230_o())
+ /* ======================================== FORGE END =====================================*/
}

View file

@ -51,7 +51,8 @@
+ @Deprecated //Use Forge Variant below
public int func_70946_n()
{
return Math.max(((Integer)this.field_70180_af.func_187225_a(field_184752_bw)).intValue() % 6, 0);
- return Math.max(((Integer)this.field_70180_af.func_187225_a(field_184752_bw)).intValue() % 6, 0);
+ return Math.max(((Integer)this.field_70180_af.func_187225_a(field_184752_bw)).intValue(), 0);
}
+ private net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession prof;

View file

@ -37,6 +37,7 @@ import net.minecraft.world.gen.structure.StructureComponent;
import net.minecraft.world.gen.structure.StructureVillagePieces;
import net.minecraft.world.gen.structure.StructureVillagePieces.PieceWeight;
import net.minecraft.world.gen.structure.StructureVillagePieces.Village;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
import javax.annotation.Nullable;
@ -46,6 +47,8 @@ import javax.annotation.Nullable;
public class VillagerRegistry
{
public static final ResourceLocation PROFESSIONS = new ResourceLocation("minecraft:villagerprofessions");
@ObjectHolder("minecraft:farmer")
public static final VillagerProfession FARMER = null;
private static final VillagerRegistry INSTANCE = new VillagerRegistry();
private Map<Class<?>, IVillageCreationHandler> villageCreationHandlers = Maps.newHashMap();

View file

@ -0,0 +1,21 @@
package net.minecraftforge.test;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer;
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession;
@Mod(modid = "professiontest", name = "ProfessionTest2000", version = "1.0", acceptableRemoteVersions = "*")
@EventBusSubscriber
public class VillagerProfessionTest
{
@SubscribeEvent
public static void registerVillagers(RegistryEvent.Register<VillagerProfession> event)
{
VillagerProfession profession = new VillagerProfession("professiontest:test_villager", "professiontest:textures/entity/test_villager.png", "professiontest:textures/entity/zombie_test_villager.png");
new VillagerCareer(profession, "professiontest:test_villager");
event.getRegistry().register(profession);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB