Search in sources :

Example 1 with ItemSpellBase

use of am2.api.spell.ItemSpellBase in project ArsMagica2 by Mithion.

the class Wall 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;
    int radius = SpellUtils.instance.getModifiedInt_Mul(3, stack, caster, target, world, 0, SpellModifiers.RADIUS);
    double gravity = SpellUtils.instance.getModifiedDouble_Add(0, stack, caster, target, world, 0, SpellModifiers.GRAVITY);
    int duration = SpellUtils.instance.getModifiedInt_Mul(100, stack, caster, target, world, 0, SpellModifiers.DURATION);
    EntitySpellEffect wall = new EntitySpellEffect(world);
    wall.setRadius(radius);
    wall.setTicksToExist(duration);
    wall.setGravity(gravity);
    wall.SetCasterAndStack(caster, SpellUtils.instance.popStackStage(stack));
    wall.setPosition(x, y, z);
    wall.setWall(caster.rotationYaw);
    world.spawnEntityInWorld(wall);
    return SpellCastResult.SUCCESS;
}
Also used : EntitySpellEffect(am2.entities.EntitySpellEffect)

Example 2 with ItemSpellBase

use of am2.api.spell.ItemSpellBase in project ArsMagica2 by Mithion.

the class Zone 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;
    int radius = SpellUtils.instance.getModifiedInt_Add(2, stack, caster, target, world, 0, SpellModifiers.RADIUS);
    double gravity = SpellUtils.instance.getModifiedDouble_Add(0, stack, caster, target, world, 0, SpellModifiers.GRAVITY);
    int duration = SpellUtils.instance.getModifiedInt_Mul(100, stack, caster, target, world, 0, SpellModifiers.DURATION);
    EntitySpellEffect zone = new EntitySpellEffect(world);
    zone.setRadius(radius);
    zone.setTicksToExist(duration);
    zone.setGravity(gravity);
    zone.SetCasterAndStack(caster, SpellUtils.instance.popStackStage(stack));
    zone.setPosition(x, y, z);
    world.spawnEntityInWorld(zone);
    return SpellCastResult.SUCCESS;
}
Also used : EntitySpellEffect(am2.entities.EntitySpellEffect)

Example 3 with ItemSpellBase

use of am2.api.spell.ItemSpellBase in project ArsMagica2 by Mithion.

the class Chain 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) {
    MovingObjectPosition mop = item.getMovingObjectPosition(caster, world, 8.0f, true, false);
    double range = SpellUtils.instance.getModifiedDouble_Mul(4, stack, caster, target, world, 0, SpellModifiers.RANGE);
    int num_targets = SpellUtils.instance.getModifiedInt_Add(3, stack, caster, target, world, 0, SpellModifiers.PROCS);
    ArrayList<EntityLivingBase> targets = new ArrayList<EntityLivingBase>();
    if (target != null) {
        mop = new MovingObjectPosition(target);
    }
    if (mop != null && mop.typeOfHit == MovingObjectType.ENTITY && mop.entityHit != null) {
        Entity e = mop.entityHit;
        if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
            e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
        if (e instanceof EntityLivingBase) {
            do {
                targets.add((EntityLivingBase) e);
                List<EntityLivingBase> nearby = world.getEntitiesWithinAABB(EntityLivingBase.class, e.boundingBox.expand(range, range, range));
                EntityLivingBase closest = null;
                for (EntityLivingBase near : nearby) {
                    if (targets.contains(near) || near == caster)
                        continue;
                    if (closest == null || closest.getDistanceSqToEntity(e) > near.getDistanceSqToEntity(e)) {
                        closest = near;
                    }
                }
                e = closest;
            } while (e != null && targets.size() < num_targets);
        }
    }
    ItemStack newItemStack = SpellUtils.instance.popStackStage(stack);
    boolean atLeastOneApplication = false;
    SpellCastResult result = SpellCastResult.SUCCESS;
    EntityLivingBase prevEntity = null;
    for (EntityLivingBase e : targets) {
        if (e == caster)
            continue;
        result = SpellHelper.instance.applyStageToEntity(stack, caster, world, e, 0, giveXP);
        SpellHelper.instance.applyStackStage(newItemStack, caster, e, e.posX, e.posY, e.posZ, 0, world, true, giveXP, 0);
        if (world.isRemote) {
            if (prevEntity == null)
                spawnChainParticles(world, x, y, z, e.posX, e.posY + e.getEyeHeight(), e.posZ, stack);
            else
                spawnChainParticles(world, prevEntity.posX, prevEntity.posY + e.getEyeHeight(), prevEntity.posZ, e.posX, e.posY + e.getEyeHeight(), e.posZ, stack);
        }
        prevEntity = e;
        if (result == SpellCastResult.SUCCESS) {
            atLeastOneApplication = true;
        }
    }
    if (atLeastOneApplication) {
        return SpellCastResult.SUCCESS;
    }
    return result;
}
Also used : Entity(net.minecraft.entity.Entity) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) EntityDragonPart(net.minecraft.entity.boss.EntityDragonPart) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ArrayList(java.util.ArrayList) SpellCastResult(am2.api.spell.enums.SpellCastResult) ItemStack(net.minecraft.item.ItemStack)

Example 4 with ItemSpellBase

use of am2.api.spell.ItemSpellBase in project ArsMagica2 by Mithion.

the class SpellScrollRenderer method renderItem.

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    if (mc.thePlayer.isPotionActive(Potion.invisibility.id))
        return;
    ItemStack scrollStack = null;
    if (item.getItem() instanceof ItemSpellBase) {
        scrollStack = item;
    } else if (item.getItem() instanceof ItemSpellBook) {
        scrollStack = ((ItemSpellBook) item.getItem()).getActiveScrollInventory(item)[((ItemSpellBook) item.getItem()).GetActiveSlot(item)];
    }
    if (scrollStack == null)
        return;
    Affinity affinity = SpellUtils.instance.mainAffinityFor(scrollStack);
    renderEffect(affinity, true, data);
}
Also used : ItemSpellBase(am2.api.spell.ItemSpellBase) Affinity(am2.api.spell.enums.Affinity) ItemStack(net.minecraft.item.ItemStack) ItemSpellBook(am2.items.ItemSpellBook)

Example 5 with ItemSpellBase

use of am2.api.spell.ItemSpellBase in project ArsMagica2 by Mithion.

the class ItemSpellBook method addInformation.

@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
    ItemSpellBase activeScroll = GetActiveScroll(par1ItemStack);
    ItemStack stack = GetActiveItemStack(par1ItemStack);
    String s = StatCollector.translateToLocal("am2.tooltip.open");
    par3List.add((new StringBuilder()).append("\2477").append(s).toString());
    if (activeScroll != null) {
        activeScroll.addInformation(stack, par2EntityPlayer, par3List, par4);
    }
    par3List.add("\247c" + StatCollector.translateToLocal("am2.tooltip.spellbookWarning1") + "\247f");
    par3List.add("\247c" + StatCollector.translateToLocal("am2.tooltip.spellbookWarning2") + "\247f");
}
Also used : ItemSpellBase(am2.api.spell.ItemSpellBase) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemStack (net.minecraft.item.ItemStack)11 ItemSpellBase (am2.api.spell.ItemSpellBase)5 SpellCastResult (am2.api.spell.enums.SpellCastResult)5 Entity (net.minecraft.entity.Entity)4 EntityLivingBase (net.minecraft.entity.EntityLivingBase)4 EntityDragonPart (net.minecraft.entity.boss.EntityDragonPart)4 EntitySpellEffect (am2.entities.EntitySpellEffect)3 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)3 SpellCastingEvent (am2.api.events.SpellCastingEvent)2 Affinity (am2.api.spell.enums.Affinity)2 EntitySpellProjectile (am2.entities.EntitySpellProjectile)2 ItemSpellBook (am2.items.ItemSpellBook)2 Slot (net.minecraft.inventory.Slot)2 ManaCostEvent (am2.api.events.ManaCostEvent)1 AMVector2 (am2.api.math.AMVector2)1 ISpellModifier (am2.api.spell.component.interfaces.ISpellModifier)1 ISpellShape (am2.api.spell.component.interfaces.ISpellShape)1 ItemFocus (am2.items.ItemFocus)1 ItemFocusCharge (am2.items.ItemFocusCharge)1 ItemFocusMana (am2.items.ItemFocusMana)1