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;
}
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;
}
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;
}
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);
}
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");
}
Aggregations