blob: 0fa9bffa468568c89b0d09775ccfb4bba40c90c1 [file] [log] [blame] [raw]
package net.glowstone.io.entity;
import net.glowstone.entity.GlowHangingEntity;
import net.glowstone.entity.GlowHangingEntity.HangingFace;
import net.glowstone.util.nbt.CompoundTag;
import org.bukkit.entity.EntityType;
public abstract class HangingStore<T extends GlowHangingEntity> extends EntityStore<T> {
public HangingStore(Class<? extends T> clazz, EntityType type) {
super(clazz, type);
}
@Override
public void load(T entity, CompoundTag tag) {
super.load(entity, tag);
tag.readByte("Facing", facing ->
entity.setFacingDirection(HangingFace.values()[facing].getBlockFace()));
}
@Override
public void save(T entity, CompoundTag tag) {
super.save(entity, tag);
tag.putByte("Facing", HangingFace.getByBlockFace(entity.getFacing()).ordinal());
}
}