Remove zombie-specific profession from VillagerProfession

This commit is contained in:
fullwall 2016-08-19 21:49:28 +08:00
parent 73854b8107
commit d9f31ffc84

View File

@ -20,6 +20,9 @@ public class VillagerProfession extends Trait {
public void load(DataKey key) throws NPCLoadException {
try {
profession = Profession.valueOf(key.getString(""));
if (profession == Profession.NORMAL) {
profession = Profession.FARMER;
}
} catch (IllegalArgumentException ex) {
throw new NPCLoadException("Invalid profession.");
}
@ -27,8 +30,9 @@ public class VillagerProfession extends Trait {
@Override
public void onSpawn() {
if (npc.getEntity() instanceof Villager)
if (npc.getEntity() instanceof Villager) {
((Villager) npc.getEntity()).setProfession(profession);
}
}
@Override
@ -37,9 +41,13 @@ public class VillagerProfession extends Trait {
}
public void setProfession(Profession profession) {
if (profession == Profession.NORMAL) {
profession = Profession.FARMER;
}
this.profession = profession;
if (npc.getEntity() instanceof Villager)
if (npc.getEntity() instanceof Villager) {
((Villager) npc.getEntity()).setProfession(profession);
}
}
@Override