package club.kongkongmao.magicera.TEntity;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.MathHelper;

import static club.kongkongmao.magicera.TEntity.TEntityLaser.EnumEffect;

import club.kongkongmao.magicera.Main.Config;

public class TEntityLaserConfig extends TileEntity {

	public short checkInterval = 5;
	public int distanceMax = 32;
	public EnumEffect effect = EnumEffect.NONE;
	
	@Override
	public void readFromNBT(NBTTagCompound compound) {
		super.readFromNBT(compound);
		checkInterval = (short) MathHelper.clamp(compound.getShort("CheckInterval"), Config.laserCheckIntervalMin, Config.laserCheckIntervalMax);
		distanceMax = (short) MathHelper.clamp(compound.getShort("DistanceMax"), Config.laserTravelDistanceMin, Config.laserCheckIntervalMax);
		effect = EnumEffect.fromName(compound.getString("Effect"));
	}

	@Override
	public NBTTagCompound writeToNBT(NBTTagCompound compound) {
		super.writeToNBT(compound);
		compound.setShort("CheckInterval", checkInterval);
		compound.setInteger("DistanceMax", distanceMax);
		compound.setString("Effect", effect.getName());
		return compound;
	}

}
