From 8b94601269ba634b81cd1aac8cad5d84572dae71 Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 9 Jun 2016 12:20:30 +1000 Subject: [PATCH] Better map Zombie/Villager professions. --- .../java/org/bukkit/craftbukkit/entity/CraftVillager.java | 5 +++-- src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java index 04919b2c46..5fcf81c4b0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java @@ -39,12 +39,13 @@ public class CraftVillager extends CraftAgeable implements Villager, InventoryHo } public Profession getProfession() { - return Profession.values()[getHandle().getProfession()]; + return Profession.values()[getHandle().getProfession() + 1]; // Offset by 1 from the zombie types } public void setProfession(Profession profession) { Validate.notNull(profession); - getHandle().setProfession(profession.ordinal()); + Validate.isTrue(0 < profession.ordinal() && profession.ordinal() < Profession.HUSK.ordinal(), "This profession is reserved for Zombies: ", profession); + getHandle().setProfession(profession.ordinal() - 1); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java index 3e1fc532d7..ebae86f152 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java @@ -51,7 +51,6 @@ public class CraftZombie extends CraftMonster implements Zombie { @Override public Villager.Profession getVillagerProfession() { - if (!isVillager()) return Villager.Profession.NORMAL; return Villager.Profession.values()[getHandle().getVillagerType().ordinal()]; } }