From 3409b06b938b0352ab40040800e366a241ec58d1 Mon Sep 17 00:00:00 2001 From: fullwall Date: Tue, 2 Aug 2022 23:06:56 +0800 Subject: [PATCH] Fix zombievillager error in 1.8 --- .../net/citizensnpcs/trait/VillagerProfession.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/main/src/main/java/net/citizensnpcs/trait/VillagerProfession.java b/main/src/main/java/net/citizensnpcs/trait/VillagerProfession.java index c5c1e0250..189dfe2ed 100644 --- a/main/src/main/java/net/citizensnpcs/trait/VillagerProfession.java +++ b/main/src/main/java/net/citizensnpcs/trait/VillagerProfession.java @@ -44,8 +44,16 @@ public class VillagerProfession extends Trait { return; if (npc.getEntity() instanceof Villager) { ((Villager) npc.getEntity()).setProfession(profession); - } else if (npc.getEntity() instanceof ZombieVillager) { - ((ZombieVillager) npc.getEntity()).setVillagerProfession(profession); + return; + } + if (SUPPORT_ZOMBIE_VILLAGER) { + try { + if (npc.getEntity() instanceof ZombieVillager) { + ((ZombieVillager) npc.getEntity()).setVillagerProfession(profession); + } + } catch (Throwable t) { + SUPPORT_ZOMBIE_VILLAGER = false; + } } } @@ -66,4 +74,6 @@ public class VillagerProfession extends Trait { public String toString() { return "Profession{" + profession + "}"; } + + private static boolean SUPPORT_ZOMBIE_VILLAGER = true; } \ No newline at end of file