use of net.glowstone.entity.monster.GlowZombieVillager in project Glowstone by GlowstoneMC.
the class ZombieVillagerStore method save.
@Override
public void save(GlowZombie zombie, CompoundTag compound) {
checkArgument(zombie instanceof GlowZombieVillager);
GlowZombieVillager entity = (GlowZombieVillager) zombie;
super.save(entity, compound);
final Villager.Profession profession = entity.getVillagerProfession();
if (profession != null) {
compound.putInt(PROFESSION, profession.ordinal());
}
compound.putInt(CONVERSION_TIME, entity.getConversionTime());
final UUID conversionPlayer = entity.getConversionPlayerId();
if (conversionPlayer != null) {
compound.putUniqueId(CONVERSION_PLAYER, conversionPlayer);
}
}
use of net.glowstone.entity.monster.GlowZombieVillager in project Glowstone by GlowstoneMC.
the class ZombieVillagerStore method load.
@Override
public void load(GlowZombie zombie, CompoundTag compound) {
checkArgument(zombie instanceof GlowZombieVillager);
GlowZombieVillager entity = (GlowZombieVillager) zombie;
super.load(entity, compound);
entity.setVillagerProfession(compound.tryGetInt(PROFESSION).filter(GlowVillager::isValidProfession).map(GlowVillager::getProfessionById).orElseGet(() -> getRandomProfession(ThreadLocalRandom.current())));
entity.setConversionTime(compound.tryGetInt(CONVERSION_TIME).orElse(-1));
compound.readUniqueId(CONVERSION_PLAYER, entity::setConversionPlayerId);
}
Aggregations