Working on small parts of the spell system

This commit is contained in:
WayofTime 2014-01-31 17:21:03 -05:00
parent e159a6795c
commit 2bb7a5fffb
9 changed files with 339 additions and 10 deletions

View file

@ -13,11 +13,19 @@ public abstract class ExtrapolatedMeleeEntityEffect implements IMeleeSpellEntity
{
protected float range;
protected float radius;
protected int powerUpgrades;
protected int potencyUpgrades;
protected int costUpgrades;
protected int maxHit;
public ExtrapolatedMeleeEntityEffect(int range, int radius)
public ExtrapolatedMeleeEntityEffect(int power, int potency, int cost)
{
this.range = range;
this.radius = radius;
this.powerUpgrades = power;
this.potencyUpgrades = potency;
this.costUpgrades = cost;
this.range = 2;
this.radius = 2;
this.maxHit = 1;
}
@Override
@ -25,21 +33,29 @@ public abstract class ExtrapolatedMeleeEntityEffect implements IMeleeSpellEntity
{
Vec3 lookVec = entityPlayer.getLook(range);
double x = entityPlayer.posX + lookVec.xCoord;
double y = entityPlayer.posY + entityPlayer.getEyeHeight() + lookVec.yCoord;
double y = entityPlayer.posY + lookVec.yCoord;
double z = entityPlayer.posZ + lookVec.zCoord;
List<Entity> entities = world.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(x-0.5f, y-0.5f, z-0.5f, x + 0.5f, y + 0.5f, z + 0.5f).expand(radius, radius, radius));
int hit = 0;
if(entities!=null)
{
for(Entity entity : entities)
{
this.entityEffect(world, entity);
if(hit<maxHit)
{
if(this.entityEffect(world, entity))
{
hit++;
}
}
}
}
}
protected abstract void entityEffect(World world, Entity entity);
protected abstract boolean entityEffect(World world, Entity entity);
public void setRange(float range)
{
@ -50,4 +66,9 @@ public abstract class ExtrapolatedMeleeEntityEffect implements IMeleeSpellEntity
{
this.radius = radius;
}
public void setMaxNumberHit(int maxHit)
{
this.maxHit = maxHit;
}
}

View file

@ -0,0 +1,48 @@
package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.ice;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.common.PacketHandler;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.ExtrapolatedMeleeEntityEffect;
public class MeleeOffensiveIce extends ExtrapolatedMeleeEntityEffect
{
public MeleeOffensiveIce(int power, int potency, int cost)
{
super(power, potency, cost);
this.setMaxNumberHit(2);
this.setRadius(1);
this.setRange(2);
}
@Override
protected boolean entityEffect(World world, Entity entity)
{
Vec3 blockVector = SpellHelper.getEntityBlockVector(entity);
int posX = (int)(blockVector.xCoord);
int posY = (int)(blockVector.yCoord);
int posZ = (int)(blockVector.zCoord);
double yVel = 1*(0.4*this.powerUpgrades+0.75);
entity.motionY = yVel;
for(int i=0;i<2;i++)
{
if(world.isAirBlock(posX,posY+i,posZ))
{
world.setBlock(posX, posY+i, posZ, Block.ice.blockID);
}
}
entity.fallDistance = 0.0f;
return true;
}
}

View file

@ -0,0 +1,43 @@
package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.ice;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.common.PacketHandler;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.SelfSpellEffect;
public class SelfDefaultIce extends SelfSpellEffect
{
public SelfDefaultIce(int power, int potency, int cost)
{
super(power, potency, cost);
}
@Override
public void onSelfUse(World world, EntityPlayer player)
{
Vec3 blockVector = SpellHelper.getEntityBlockVector(player);
int posX = (int)(blockVector.xCoord);
int posY = (int)(blockVector.yCoord);
int posZ = (int)(blockVector.zCoord);
double yVel = 1*(0.4*this.powerUpgrades+0.75);
PacketDispatcher.sendPacketToPlayer(PacketHandler.getPlayerVelocitySettingPacket(player.motionX, yVel, player.motionZ),(Player)player);
for(int i=0;i<2;i++)
{
if(world.isAirBlock(posX,posY+i,posZ))
{
world.setBlock(posX, posY+i, posZ, Block.ice.blockID);
}
}
player.fallDistance = 0.0f;
}
}