2014-11-13 08:42:49 -05:00
|
|
|
package WayofTime.alchemicalWizardry.api.spell;
|
2014-06-27 19:43:09 -04:00
|
|
|
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
|
|
import net.minecraft.util.Vec3;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2014-10-13 22:33:20 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
2014-06-27 19:43:09 -04:00
|
|
|
public abstract class ExtrapolatedMeleeEntityEffect implements IMeleeSpellEntityEffect
|
|
|
|
{
|
2014-10-13 22:33:20 +02:00
|
|
|
protected float range;
|
|
|
|
protected float radius;
|
|
|
|
protected int powerUpgrades;
|
|
|
|
protected int potencyUpgrades;
|
|
|
|
protected int costUpgrades;
|
|
|
|
protected int maxHit;
|
|
|
|
|
|
|
|
public ExtrapolatedMeleeEntityEffect(int power, int potency, int cost)
|
|
|
|
{
|
|
|
|
this.powerUpgrades = power;
|
|
|
|
this.potencyUpgrades = potency;
|
|
|
|
this.costUpgrades = cost;
|
|
|
|
this.range = 0;
|
|
|
|
this.radius = 0;
|
|
|
|
this.maxHit = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEntityImpact(World world, EntityPlayer entityPlayer)
|
|
|
|
{
|
|
|
|
Vec3 lookVec = entityPlayer.getLook(range);
|
|
|
|
double x = entityPlayer.posX + lookVec.xCoord;
|
|
|
|
double y = entityPlayer.posY + entityPlayer.getEyeHeight() + lookVec.yCoord;
|
|
|
|
double z = entityPlayer.posZ + lookVec.zCoord;
|
|
|
|
|
2015-07-29 08:23:01 -04:00
|
|
|
List<Entity> entities = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(x - 0.5f, y - 0.5f, z - 0.5f, x + 0.5f, y + 0.5f, z + 0.5f).expand(radius, radius, radius));
|
2014-06-27 19:43:09 -04:00
|
|
|
int hit = 0;
|
2014-10-13 22:33:20 +02:00
|
|
|
|
|
|
|
if (entities != null)
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2014-10-13 22:33:20 +02:00
|
|
|
for (Entity entity : entities)
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2014-10-13 22:33:20 +02:00
|
|
|
if (hit < maxHit && !entity.equals(entityPlayer))
|
|
|
|
{
|
|
|
|
if (this.entityEffect(world, entity, entityPlayer))
|
|
|
|
{
|
|
|
|
hit++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|
2014-10-13 22:33:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected abstract boolean entityEffect(World world, Entity entity, EntityPlayer player);
|
|
|
|
|
|
|
|
public void setRange(float range)
|
|
|
|
{
|
|
|
|
this.range = range;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setRadius(float radius)
|
|
|
|
{
|
|
|
|
this.radius = radius;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMaxNumberHit(int maxHit)
|
|
|
|
{
|
|
|
|
this.maxHit = maxHit;
|
|
|
|
}
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|