Spell Work

Need to work on how the EntitySpellProjectile saves its data. Does not
work properly. Perhaps it was not registered?
This commit is contained in:
WayofTime 2014-01-25 09:22:59 -05:00
parent 5dcef131dc
commit 112b4e6b53
15 changed files with 314 additions and 92 deletions

View file

@ -1,5 +1,6 @@
package WayofTime.alchemicalWizardry.common.spell.complex.effect;
import net.minecraft.nbt.NBTTagCompound;
import WayofTime.alchemicalWizardry.common.spell.complex.SpellModifier;
import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigm;
import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigmMelee;
@ -169,4 +170,49 @@ public abstract class SpellEffect
{
return this.potencyEnhancement;
}
public NBTTagCompound getTag()
{
NBTTagCompound tag = new NBTTagCompound();
tag.setString("Class", this.getClass().getName());
tag.setInteger("power", powerEnhancement);
tag.setInteger("cost", costEnhancement);
tag.setInteger("potency", potencyEnhancement);
return tag;
}
public static SpellEffect getEffectFromTag(NBTTagCompound tag)
{
try {
Class clazz = Class.forName(tag.getString("Class"));
if(clazz !=null)
{
try {
Object obj = clazz.newInstance();
if(obj instanceof SpellEffect)
{
SpellEffect eff = (SpellEffect) obj;
eff.powerEnhancement = tag.getInteger("power");
eff.costEnhancement = tag.getInteger("cost");
eff.potencyEnhancement = tag.getInteger("potency");
return eff;
}
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}