diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/RenderZombieVillager.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/RenderZombieVillager.java.patch new file mode 100644 index 0000000000..4f8f88bb77 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/entity/RenderZombieVillager.java.patch @@ -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: diff --git a/patches/minecraft/net/minecraft/entity/monster/EntityZombieVillager.java.patch b/patches/minecraft/net/minecraft/entity/monster/EntityZombieVillager.java.patch index 7aba28025d..95c9a4f326 100644 --- a/patches/minecraft/net/minecraft/entity/monster/EntityZombieVillager.java.patch +++ b/patches/minecraft/net/minecraft/entity/monster/EntityZombieVillager.java.patch @@ -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 =====================================*/ + } diff --git a/patches/minecraft/net/minecraft/entity/passive/EntityVillager.java.patch b/patches/minecraft/net/minecraft/entity/passive/EntityVillager.java.patch index 5d46c87b69..7983c6c971 100644 --- a/patches/minecraft/net/minecraft/entity/passive/EntityVillager.java.patch +++ b/patches/minecraft/net/minecraft/entity/passive/EntityVillager.java.patch @@ -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; diff --git a/src/main/java/net/minecraftforge/fml/common/registry/VillagerRegistry.java b/src/main/java/net/minecraftforge/fml/common/registry/VillagerRegistry.java index 91d3391cc5..08b7308f12 100644 --- a/src/main/java/net/minecraftforge/fml/common/registry/VillagerRegistry.java +++ b/src/main/java/net/minecraftforge/fml/common/registry/VillagerRegistry.java @@ -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, IVillageCreationHandler> villageCreationHandlers = Maps.newHashMap(); diff --git a/src/test/java/net/minecraftforge/test/VillagerProfessionTest.java b/src/test/java/net/minecraftforge/test/VillagerProfessionTest.java new file mode 100644 index 0000000000..946830107c --- /dev/null +++ b/src/test/java/net/minecraftforge/test/VillagerProfessionTest.java @@ -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 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); + } +} diff --git a/src/test/resources/assets/professiontest/textures/entity/test_villager.png b/src/test/resources/assets/professiontest/textures/entity/test_villager.png new file mode 100644 index 0000000000..c96f96ff37 Binary files /dev/null and b/src/test/resources/assets/professiontest/textures/entity/test_villager.png differ diff --git a/src/test/resources/assets/professiontest/textures/entity/zombie_test_villager.png b/src/test/resources/assets/professiontest/textures/entity/zombie_test_villager.png new file mode 100644 index 0000000000..4951a52737 Binary files /dev/null and b/src/test/resources/assets/professiontest/textures/entity/zombie_test_villager.png differ