diff --git a/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/EntitySpellProjectile.java b/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/EntitySpellProjectile.java index 39283517..45d3cdf2 100644 --- a/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/EntitySpellProjectile.java +++ b/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/EntitySpellProjectile.java @@ -2,6 +2,7 @@ package WayofTime.alchemicalWizardry.common.spell.complex; import java.util.ArrayList; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import net.minecraft.block.Block; @@ -13,7 +14,9 @@ import net.minecraft.entity.monster.EntityPigZombie; import net.minecraft.entity.monster.EntitySkeleton; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumMovingObjectType; @@ -40,9 +43,11 @@ public class EntitySpellProjectile extends Entity implements IProjectile //Custom variables private int maxRicochet = 0; + private float damage = 1; public List impactList = new ArrayList(); private boolean penetration = false; public List updateEffectList = new ArrayList(); + public List effectList = new LinkedList(); public EntitySpellProjectile(World par1World) { @@ -254,26 +259,52 @@ public class EntitySpellProjectile extends Entity implements IProjectile * (abstract) Protected helper method to write subclass entity data to NBT. */ @Override - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { par1NBTTagCompound.setShort("xTile", (short)xTile); par1NBTTagCompound.setShort("yTile", (short)yTile); par1NBTTagCompound.setShort("zTile", (short)zTile); par1NBTTagCompound.setByte("inTile", (byte)inTile); par1NBTTagCompound.setByte("inData", (byte)inData); par1NBTTagCompound.setByte("inGround", (byte)(inGround ? 1 : 0)); + + NBTTagList tagList = par1NBTTagCompound.getTagList("Effects"); + this.effectList = new LinkedList(); + for (int i = 0; i < tagList.tagCount(); i++) + { + NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(i); + + this.effectList.add(tag.getString("Class")); + } } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ @Override - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { xTile = par1NBTTagCompound.getShort("xTile"); yTile = par1NBTTagCompound.getShort("yTile"); zTile = par1NBTTagCompound.getShort("zTile"); inTile = par1NBTTagCompound.getByte("inTile") & 255; inData = par1NBTTagCompound.getByte("inData") & 255; inGround = par1NBTTagCompound.getByte("inGround") == 1; + + NBTTagList effectList = new NBTTagList(); + + for (String str : this.effectList) + { + if (str != null) + { + NBTTagCompound tag = new NBTTagCompound(); + + tag.setString("Class", str); + effectList.appendTag(tag); + } + } + + par1NBTTagCompound.setTag("Effects", effectList); } /** @@ -464,6 +495,11 @@ public class EntitySpellProjectile extends Entity implements IProjectile this.impactList = list; } + public void setUpdateEffectList(List list) + { + this.updateEffectList = list; + } + private void performEntityImpactEffects(Entity mop) { if(impactList!=null) @@ -501,4 +537,19 @@ public class EntitySpellProjectile extends Entity implements IProjectile { this.penetration = penetration; } + + public float getDamage() + { + return this.damage; + } + + public void setDamage(float damage) + { + this.damage = damage; + } + + public void setEffectList(List stringList) + { + this.effectList = stringList; + } } diff --git a/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/SpellParadigm.java b/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/SpellParadigm.java index 67b7700e..2eca17f9 100644 --- a/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/SpellParadigm.java +++ b/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/SpellParadigm.java @@ -1,6 +1,7 @@ package WayofTime.alchemicalWizardry.common.spell.complex; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import net.minecraft.entity.player.EntityPlayer; @@ -11,12 +12,15 @@ import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellEffect; public abstract class SpellParadigm { protected List bufferedEffectList = new ArrayList(); + protected List effectList = new LinkedList(); public void addBufferedEffect(SpellEffect effect) { if(effect!=null) { this.bufferedEffectList.add(effect); + + effectList.add(effect.getClass().getName()); } } @@ -26,23 +30,31 @@ public abstract class SpellParadigm if(effect!=null) { effect.modifyEffect(modifier); + + effectList.add(modifier.getClass().getName()); } } public void applyEnhancement(SpellEnhancement enh) { - if(bufferedEffectList.isEmpty()) + if(enh!=null) { - this.enhanceParadigm(enh); - } - else - { - SpellEffect effect = this.getBufferedEffect(); - if(effect!=null) + if(bufferedEffectList.isEmpty()) { - effect.enhanceEffect(enh); + this.enhanceParadigm(enh); } + else + { + SpellEffect effect = this.getBufferedEffect(); + if(effect!=null) + { + effect.enhanceEffect(enh); + } + } + + effectList.add(enh.getClass().getName()); } + } public abstract void enhanceParadigm(SpellEnhancement enh); diff --git a/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/SpellParadigmProjectile.java b/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/SpellParadigmProjectile.java index 45e995e1..af6e4930 100644 --- a/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/SpellParadigmProjectile.java +++ b/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/SpellParadigmProjectile.java @@ -1,12 +1,14 @@ package WayofTime.alchemicalWizardry.common.spell.complex; import java.util.ArrayList; +import java.util.LinkedList; 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; +import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellEffect; public class SpellParadigmProjectile extends SpellParadigm { @@ -14,6 +16,9 @@ public class SpellParadigmProjectile extends SpellParadigm public float damage = 1; public int cost = 0; public List impactList = new ArrayList(); + public List updateEffectList = new ArrayList(); + public boolean penetration = false; + @Override public void enhanceParadigm(SpellEnhancement enh) @@ -25,7 +30,62 @@ public class SpellParadigmProjectile extends SpellParadigm @Override public void castSpell(World world, EntityPlayer entityPlayer, ItemStack itemStack) { - // TODO Auto-generated method stub + EntitySpellProjectile proj = new EntitySpellProjectile(world, entityPlayer); } + + public static SpellParadigmProjectile getParadigmForStringArray(List 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(); + } + + return parad; + } + + public void prepareProjectile(EntitySpellProjectile proj) + { + proj.setDamage(damage); + proj.setImpactList(impactList); + proj.setUpdateEffectList(updateEffectList); + proj.setPenetration(penetration); + proj.setEffectList(effectList); + } + }