2018-09-12 01:29:49 +02:00
|
|
|
package com.minelittlepony.unicopia.spell;
|
|
|
|
|
2019-02-05 13:44:35 +01:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
2018-09-12 01:29:49 +02:00
|
|
|
public abstract class AbstractSpell implements IMagicEffect {
|
|
|
|
|
2019-02-05 21:47:18 +01:00
|
|
|
protected boolean isDead;
|
|
|
|
protected boolean isDirty;
|
2018-09-12 01:29:49 +02:00
|
|
|
|
2019-02-04 19:29:37 +01:00
|
|
|
@Override
|
|
|
|
public boolean isCraftable() {
|
|
|
|
return true;
|
2019-01-22 17:39:30 +01:00
|
|
|
}
|
|
|
|
|
2018-09-12 01:29:49 +02:00
|
|
|
@Override
|
|
|
|
public void setDead() {
|
|
|
|
isDead = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean getDead() {
|
|
|
|
return isDead;
|
|
|
|
}
|
2019-02-05 13:44:35 +01:00
|
|
|
|
2019-02-05 21:47:18 +01:00
|
|
|
@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;
|
|
|
|
}
|
|
|
|
|
2019-02-05 13:44:35 +01:00
|
|
|
@Override
|
|
|
|
public void writeToNBT(NBTTagCompound compound) {
|
|
|
|
compound.setBoolean("dead", isDead);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void readFromNBT(NBTTagCompound compound) {
|
2019-02-05 21:47:18 +01:00
|
|
|
setDirty(false);
|
2019-02-05 13:44:35 +01:00
|
|
|
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);
|
|
|
|
}
|
2019-02-05 13:44:35 +01:00
|
|
|
}
|
2018-09-12 01:29:49 +02:00
|
|
|
}
|