Search in sources :

Example 1 with EntitySpellProjectile

use of am2.entities.EntitySpellProjectile in project ArsMagica2 by Mithion.

the class AoE method beginStackStage.

@Override
public SpellCastResult beginStackStage(ItemSpellBase item, ItemStack stack, EntityLivingBase caster, EntityLivingBase target, World world, double x, double y, double z, int side, boolean giveXP, int useCount) {
    double radius = SpellUtils.instance.getModifiedDouble_Add(1, stack, caster, target, world, 0, SpellModifiers.RADIUS);
    List<Entity> entities = world.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(x - radius, y - radius, z - radius, x + radius, y + radius, z + radius));
    boolean appliedToAtLeastOneEntity = false;
    for (Entity e : entities) {
        if (e == caster || e instanceof EntitySpellProjectile)
            continue;
        if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
            e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
        if (SpellHelper.instance.applyStageToEntity(stack, caster, world, e, 0, giveXP) == SpellCastResult.SUCCESS)
            appliedToAtLeastOneEntity = true;
    }
    if (side == 0 || side == 1) {
        //top/bottom
        if (world.isRemote)
            spawnAoEParticles(stack, caster, world, x + 0.5f, y + ((side == 1) ? 0.5f : (target != null ? target.getEyeHeight() : -2.0f)), z + 0.5f, (int) radius);
        int gravityMagnitude = SpellUtils.instance.countModifiers(SpellModifiers.GRAVITY, stack, 0);
        return applyStageHorizontal(stack, caster, world, (int) Math.floor(x), (int) Math.ceil(y), (int) Math.floor(z), side, (int) Math.floor(radius), gravityMagnitude, giveXP);
    } else if (side == 2 || side == 3) {
        //if (side == 3) z--;
        if (world.isRemote)
            spawnAoEParticles(stack, caster, world, x, y, (side == 2) ? z - 0.5f : z + 1.5f, (int) radius);
        return applyStageVerticalZ(stack, caster, world, (int) Math.floor(x), (int) Math.ceil(y), (int) Math.floor(z), side, (int) Math.floor(radius), giveXP);
    } else if (side == 4 || side == 5) {
        //if (side == 5) x--;
        if (world.isRemote)
            spawnAoEParticles(stack, caster, world, x, y, (side == 5) ? z - 0.5f : z + 1.5f, (int) radius);
        return applyStageVerticalX(stack, caster, world, (int) Math.floor(x), (int) Math.ceil(y), (int) Math.floor(z), side, (int) Math.floor(radius), giveXP);
    }
    if (appliedToAtLeastOneEntity) {
        if (world.isRemote)
            spawnAoEParticles(stack, caster, world, x, y + 1, z, (int) radius);
        return SpellCastResult.SUCCESS;
    }
    return SpellCastResult.EFFECT_FAILED;
}
Also used : Entity(net.minecraft.entity.Entity) EntityDragonPart(net.minecraft.entity.boss.EntityDragonPart) EntitySpellProjectile(am2.entities.EntitySpellProjectile) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 2 with EntitySpellProjectile

use of am2.entities.EntitySpellProjectile in project ArsMagica2 by Mithion.

the class Projectile method beginStackStage.

@Override
public SpellCastResult beginStackStage(ItemSpellBase item, ItemStack stack, EntityLivingBase caster, EntityLivingBase target, World world, double x, double y, double z, int side, boolean giveXP, int useCount) {
    if (!world.isRemote) {
        double projectileSpeed = SpellUtils.instance.getModifiedDouble_Mul(SpellModifiers.SPEED, stack, caster, target, world, 0);
        double projectileGravity = SpellUtils.instance.getModifiedDouble_Add(SpellModifiers.GRAVITY, stack, caster, target, world, 0);
        int projectileBounce = SpellUtils.instance.getModifiedInt_Add(SpellModifiers.BOUNCE, stack, caster, target, world, 0);
        int projectileLife = SpellUtils.instance.getModifiedInt_Mul(SpellModifiers.DURATION, stack, caster, target, world, 0);
        int pierces = SpellUtils.instance.getModifiedInt_Add(0, stack, caster, target, world, 0, SpellModifiers.PIERCING);
        int homing = SpellUtils.instance.getModifiedInt_Add(SpellModifiers.HOMING, stack, caster, target, world, 0);
        boolean tWater = SpellUtils.instance.modifierIsPresent(SpellModifiers.TARGET_NONSOLID_BLOCKS, stack, 0);
        EntitySpellProjectile projectile = new EntitySpellProjectile(world, caster, projectileSpeed);
        projectile.setShootingEntity(caster);
        projectile.setBounces(projectileBounce);
        projectile.setEffectStack(stack);
        if (tWater)
            projectile.setTargetWater();
        projectile.setGravity(projectileGravity);
        projectile.setNumPierces(pierces);
        projectile.setHoming(homing);
        world.spawnEntityInWorld(projectile);
    }
    return SpellCastResult.SUCCESS;
}
Also used : EntitySpellProjectile(am2.entities.EntitySpellProjectile)

Aggregations

EntitySpellProjectile (am2.entities.EntitySpellProjectile)2 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityDragonPart (net.minecraft.entity.boss.EntityDragonPart)1