Unicopia/src/main/java/com/minelittlepony/unicopia/spell/AbstractSpell.java

90 lines
1.8 KiB
Java
Raw Normal View History

2018-09-12 01:29:49 +02:00
package com.minelittlepony.unicopia.spell;
import net.minecraft.nbt.NBTTagCompound;
2018-09-12 01:29:49 +02:00
public abstract class AbstractSpell implements IMagicEffect {
protected boolean isDead;
protected boolean isDirty;
2018-09-12 01:29:49 +02:00
@Override
public boolean isCraftable() {
return true;
}
2018-09-12 01:29:49 +02:00
@Override
public void setDead() {
isDead = true;
}
@Override
public boolean getDead() {
return isDead;
}
@Override
public boolean isDirty() {
return isDirty;
}
@Override
public void setDirty(boolean dirty) {
isDirty = dirty;
}
2019-02-06 09:31:31 +01:00
@Override
public int getMaxLevelCutOff(ICaster<?> source) {
return 1;
}
public float getMaxExhaustion(ICaster<?> caster) {
return 1;
}
public float getExhaustion(ICaster<?> caster) {
return 0;
}
@Override
public void writeToNBT(NBTTagCompound compound) {
compound.setBoolean("dead", isDead);
}
@Override
public void readFromNBT(NBTTagCompound compound) {
setDirty(false);
isDead = compound.getBoolean("dead");
2019-02-06 09:31:31 +01:00
}
public static abstract class RangedAreaSpell extends AbstractSpell {
@Override
public int getMaxLevelCutOff(ICaster<?> source) {
return 17;
}
@Override
public float getMaxExhaustion(ICaster<?> caster) {
return 1000;
}
@Override
public float getExhaustion(ICaster<?> caster) {
float max = getMaxLevelCutOff(caster);
float current = caster.getCurrentLevel();
if (current > max) {
float maxEc = getMaxExhaustion(caster);
current -= max;
current /= max;
current /= maxEc;
return maxEc - current;
}
return super.getExhaustion(caster);
}
}
2018-09-12 01:29:49 +02:00
}