blob: 63dc773acc6fb2e3187c1caac4dca3ddec237778 [file] [log] [blame] [raw]
package net.glowstone.io.entity;
import net.glowstone.entity.passive.GlowSheep;
import net.glowstone.util.nbt.CompoundTag;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
class SheepStore extends AgeableStore<GlowSheep> {
public static final String SHEARED_KEY = "Sheared";
public static final String COLOR_KEY = "Color";
public SheepStore() {
super(GlowSheep.class, EntityType.SHEEP, GlowSheep::new);
}
@Override
public GlowSheep createEntity(Location location, CompoundTag compound) {
return new GlowSheep(location);
}
@Override
public void load(GlowSheep entity, CompoundTag compound) {
super.load(entity, compound);
if (!compound.readByte(COLOR_KEY, color -> entity.setColor(DyeColor.values()[color]))) {
entity.setColor(DyeColor.WHITE);
}
entity.setSheared(compound.getBoolean(SHEARED_KEY, false));
}
@Override
public void save(GlowSheep entity, CompoundTag tag) {
super.save(entity, tag);
tag.putByte(COLOR_KEY, entity.getColor().ordinal());
tag.putBool(SHEARED_KEY, entity.isSheared());
}
}