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

122 lines
3 KiB
Java
Raw Normal View History

2014-01-18 00:59:31 +00:00
package WayofTime.alchemicalWizardry.common.spell.complex;
import java.util.ArrayList;
import java.util.LinkedList;
2014-01-18 00:59:31 +00:00
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
2014-01-19 01:29:20 +00:00
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.IProjectileImpactEffect;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.IProjectileUpdateEffect;
2014-01-18 16:45:31 +00:00
import WayofTime.alchemicalWizardry.common.spell.complex.enhancement.SpellEnhancement;
2014-01-18 00:59:31 +00:00
public class SpellParadigmProjectile extends SpellParadigm
{
public DamageSource damageSource = DamageSource.generic;
public float damage = 1;
public int cost = 0;
public List<IProjectileImpactEffect> impactList = new ArrayList();
public List<IProjectileUpdateEffect> updateEffectList = new ArrayList();
public boolean penetration = false;
2014-01-18 16:45:31 +00:00
public int ricochetMax = 0;
2014-01-18 00:59:31 +00:00
@Override
public void enhanceParadigm(SpellEnhancement enh)
{
}
@Override
public void castSpell(World world, EntityPlayer entityPlayer, ItemStack itemStack)
{
EntitySpellProjectile proj = new EntitySpellProjectile(world, entityPlayer);
2014-01-18 16:45:31 +00:00
this.prepareProjectile(proj);
world.spawnEntityInWorld(proj);
2014-01-19 01:29:20 +00:00
int cost = this.getTotalCost();
EnergyItems.syphonBatteries(itemStack, entityPlayer, cost);
}
public static SpellParadigmProjectile getParadigmForStringArray(List<String> stringList)
{
SpellParadigmProjectile parad = new SpellParadigmProjectile();
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();
}
2014-01-18 00:59:31 +00:00
return parad;
2014-01-18 00:59:31 +00:00
}
public void prepareProjectile(EntitySpellProjectile proj)
{
proj.setDamage(damage);
proj.setImpactList(impactList);
proj.setUpdateEffectList(updateEffectList);
proj.setPenetration(penetration);
proj.setEffectList(effectList);
2014-01-18 16:45:31 +00:00
proj.setRicochetMax(ricochetMax);
}
2014-01-19 01:29:20 +00:00
public void addImpactEffect(IProjectileImpactEffect eff)
{
if(eff!=null)
{
this.impactList.add(eff);
}
}
public void addUpdateEffect(IProjectileUpdateEffect eff)
{
if(eff!=null)
{
this.updateEffectList.add(eff);
}
}
2014-01-18 23:05:25 +00:00
@Override
public int getDefaultCost()
{
return 50;
}
2014-01-18 00:59:31 +00:00
}