BloodMagic/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/SpellParadigmSelf.java

103 lines
2.2 KiB
Java
Raw Normal View History

2014-01-18 00:59:31 +00:00
package WayofTime.alchemicalWizardry.common.spell.complex;
2014-01-19 01:29:20 +00:00
import java.util.ArrayList;
import java.util.List;
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellEffect;
2014-01-19 02:03:14 +00:00
import WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.ISelfSpellEffect;
2014-01-18 16:45:31 +00:00
import WayofTime.alchemicalWizardry.common.spell.complex.enhancement.SpellEnhancement;
2014-01-18 00:59:31 +00:00
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class SpellParadigmSelf extends SpellParadigm
{
2014-01-19 01:29:20 +00:00
public List<ISelfSpellEffect> selfSpellEffectList;
public SpellParadigmSelf()
{
selfSpellEffectList = new ArrayList();
}
2014-01-18 00:59:31 +00:00
@Override
public void enhanceParadigm(SpellEnhancement enh)
{
}
@Override
public void castSpell(World world, EntityPlayer entityPlayer, ItemStack itemStack)
{
this.applyAllSpellEffects();
2014-01-19 01:29:20 +00:00
for(ISelfSpellEffect eff : selfSpellEffectList)
{
eff.onSelfUse(world, entityPlayer);
}
int cost = this.getTotalCost();
2014-01-18 00:59:31 +00:00
2014-01-19 01:29:20 +00:00
EnergyItems.syphonBatteries(itemStack, entityPlayer, cost);
2014-01-18 00:59:31 +00:00
}
2014-01-18 23:05:25 +00:00
2014-01-19 01:29:20 +00:00
public void addSelfSpellEffect(ISelfSpellEffect eff)
{
if(eff!=null)
{
this.selfSpellEffectList.add(eff);
}
}
2014-01-18 23:05:25 +00:00
@Override
public int getDefaultCost()
{
2014-01-19 02:27:08 +00:00
return 100;
2014-01-18 23:05:25 +00:00
}
public static SpellParadigmSelf getParadigmForStringArray(List<String> stringList)
{
SpellParadigmSelf parad = new SpellParadigmSelf();
try
{
for(String str : stringList)
{
Class clazz = Class.forName(str);
if(clazz!=null)
{
Object obj = clazz.newInstance();
if(obj instanceof SpellEffect)
{
parad.addBufferedEffect((SpellEffect)obj);
continue;
}
if(obj instanceof SpellModifier)
{
parad.modifyBufferedEffect((SpellModifier)obj);
continue;
}
if(obj instanceof SpellEnhancement)
{
parad.applyEnhancement((SpellEnhancement)obj);
continue;
}
}
}
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return parad;
}
2014-01-18 00:59:31 +00:00
}