Search in sources :

Example 1 with GlowZombieVillager

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);
    }
}
Also used : Villager(org.bukkit.entity.Villager) GlowZombieVillager(net.glowstone.entity.monster.GlowZombieVillager) GlowVillager(net.glowstone.entity.passive.GlowVillager) GlowZombieVillager(net.glowstone.entity.monster.GlowZombieVillager) UUID(java.util.UUID)

Example 2 with GlowZombieVillager

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);
}
Also used : GlowVillager(net.glowstone.entity.passive.GlowVillager) GlowZombieVillager(net.glowstone.entity.monster.GlowZombieVillager)

Aggregations

GlowZombieVillager (net.glowstone.entity.monster.GlowZombieVillager)2 GlowVillager (net.glowstone.entity.passive.GlowVillager)2 UUID (java.util.UUID)1 Villager (org.bukkit.entity.Villager)1