Search in sources :

Example 6 with SpellCastResult

use of am2.api.spell.enums.SpellCastResult in project ArsMagica2 by Mithion.

the class AoE method applyStageHorizontal.

private SpellCastResult applyStageHorizontal(ItemStack stack, EntityLivingBase caster, World world, int x, int y, int z, int face, int radius, int gravityMagnitude, boolean giveXP) {
    for (int i = -radius; i <= radius; ++i) {
        for (int j = -radius; j <= radius; ++j) {
            int searchY = y;
            Block block = world.getBlock(x + i, searchY, z + j);
            int searchDist = 0;
            if (gravityMagnitude > 0) {
                while (block == Blocks.air && searchDist < gravityMagnitude) {
                    searchY--;
                    searchDist++;
                    block = world.getBlock(x + i, searchY, z + j);
                }
            }
            if (block == Blocks.air)
                continue;
            SpellCastResult result = SpellHelper.instance.applyStageToGround(stack, caster, world, x + i, searchY, z + j, face, x + i, searchY, z + i, 0, giveXP);
            if (result != SpellCastResult.SUCCESS)
                return result;
        }
    }
    return SpellCastResult.SUCCESS;
}
Also used : Block(net.minecraft.block.Block) SpellCastResult(am2.api.spell.enums.SpellCastResult)

Example 7 with SpellCastResult

use of am2.api.spell.enums.SpellCastResult 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)

Example 8 with SpellCastResult

use of am2.api.spell.enums.SpellCastResult in project ArsMagica2 by Mithion.

the class Self 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) {
    SpellCastResult result = SpellHelper.instance.applyStageToEntity(stack, caster, world, caster, 0, giveXP);
    if (result != SpellCastResult.SUCCESS) {
        return result;
    }
    ItemStack newItemStack = SpellUtils.instance.popStackStage(stack);
    return SpellHelper.instance.applyStackStage(newItemStack, caster, target, x, y, z, 0, world, true, giveXP, 0);
}
Also used : SpellCastResult(am2.api.spell.enums.SpellCastResult) ItemStack(net.minecraft.item.ItemStack)

Example 9 with SpellCastResult

use of am2.api.spell.enums.SpellCastResult in project ArsMagica2 by Mithion.

the class Touch 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 (target != null) {
        Entity e = target;
        if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
            e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
        SpellCastResult result = SpellHelper.instance.applyStageToEntity(stack, caster, world, e, 0, giveXP);
        return result;
    }
    boolean targetWater = SpellUtils.instance.modifierIsPresent(SpellModifiers.TARGET_NONSOLID_BLOCKS, stack, 0);
    MovingObjectPosition mop = item.getMovingObjectPosition(caster, world, 2.5f, true, targetWater);
    if (mop == null) {
        return SpellCastResult.EFFECT_FAILED;
    } else {
        if (mop.typeOfHit == MovingObjectType.ENTITY) {
            Entity e = mop.entityHit;
            if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
                e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
            SpellCastResult result = SpellHelper.instance.applyStageToEntity(stack, caster, world, (target == null) ? e : target, 0, giveXP);
            if (result != SpellCastResult.SUCCESS) {
                return result;
            }
            ItemStack newItemStack = SpellUtils.instance.popStackStage(stack);
            return SpellHelper.instance.applyStackStage(newItemStack, caster, target, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord, 0, world, true, giveXP, 0);
        } else {
            SpellCastResult result = SpellHelper.instance.applyStageToGround(stack, caster, world, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord, 0, giveXP);
            if (result != SpellCastResult.SUCCESS) {
                return result;
            }
            ItemStack newItemStack = SpellUtils.instance.popStackStage(stack);
            return SpellHelper.instance.applyStackStage(newItemStack, caster, target, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit, world, true, giveXP, 0);
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityDragonPart(net.minecraft.entity.boss.EntityDragonPart) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) EntityLivingBase(net.minecraft.entity.EntityLivingBase) SpellCastResult(am2.api.spell.enums.SpellCastResult) ItemStack(net.minecraft.item.ItemStack)

Example 10 with SpellCastResult

use of am2.api.spell.enums.SpellCastResult in project ArsMagica2 by Mithion.

the class Wave 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)
        return SpellCastResult.SUCCESS;
    double radius = SpellUtils.instance.getModifiedDouble_Add(1, stack, caster, target, world, 0, SpellModifiers.RADIUS);
    int duration = SpellUtils.instance.getModifiedInt_Mul(20, stack, caster, target, world, 0, SpellModifiers.DURATION);
    double speed = SpellUtils.instance.getModifiedDouble_Add(1f, stack, caster, target, world, 0, SpellModifiers.SPEED) * 0.5f;
    int gravityModifiers = SpellUtils.instance.countModifiers(SpellModifiers.GRAVITY, stack, 0);
    boolean hasPiercing = SpellUtils.instance.modifierIsPresent(SpellModifiers.PIERCING, stack, 0);
    EntitySpellEffect wave = new EntitySpellEffect(world);
    wave.setRadius((float) radius);
    wave.setTicksToExist(duration);
    wave.SetCasterAndStack(caster, SpellUtils.instance.popStackStage(stack));
    wave.setPosition(x, y + 1, z);
    wave.setWave(caster.rotationYaw, (float) speed);
    wave.noClip = hasPiercing;
    wave.setGravity(gravityModifiers * 0.5f);
    world.spawnEntityInWorld(wave);
    return SpellCastResult.SUCCESS;
}
Also used : EntitySpellEffect(am2.entities.EntitySpellEffect)

Aggregations

SpellCastResult (am2.api.spell.enums.SpellCastResult)8 ItemStack (net.minecraft.item.ItemStack)5 Entity (net.minecraft.entity.Entity)4 EntityLivingBase (net.minecraft.entity.EntityLivingBase)4 EntityDragonPart (net.minecraft.entity.boss.EntityDragonPart)4 ISpellModifier (am2.api.spell.component.interfaces.ISpellModifier)3 ISpellShape (am2.api.spell.component.interfaces.ISpellShape)3 EntitySpellEffect (am2.entities.EntitySpellEffect)3 Colour (am2.spell.modifiers.Colour)3 Block (net.minecraft.block.Block)3 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)3 ISpellComponent (am2.api.spell.component.interfaces.ISpellComponent)2 EntitySpellProjectile (am2.entities.EntitySpellProjectile)2 SpellCastingEvent (am2.api.events.SpellCastingEvent)1 ItemSpellBase (am2.api.spell.ItemSpellBase)1 Affinity (am2.api.spell.enums.Affinity)1 AMDataWriter (am2.network.AMDataWriter)1 AMBeam (am2.particles.AMBeam)1 AMParticle (am2.particles.AMParticle)1 ParticleMoveOnHeading (am2.particles.ParticleMoveOnHeading)1