use of am2.api.spell.component.interfaces.ISpellModifier in project ArsMagica2 by Mithion.
the class SpellUtils method getModifiedInt_Add.
public int getModifiedInt_Add(int defaultValue, ItemStack stack, EntityLivingBase caster, Entity target, World world, int stage, SpellModifiers check) {
int ordinalCount = 0;
double modifiedValue = defaultValue;
for (ISpellModifier modifier : getModifiersForStage(stack, stage)) {
if (modifier.getAspectsModified().contains(check)) {
byte[] meta = getModifierMetadataFromStack(stack, modifier, stage, ordinalCount++);
modifiedValue += modifier.getModifier(check, caster, target, world, meta);
}
}
if (caster instanceof EntityPlayer) {
if (SkillData.For((EntityPlayer) caster).isEntryKnown(SkillTreeManager.instance.getSkillTreeEntry(SkillManager.instance.getSkill("AugmentedCasting")))) {
modifiedValue *= 1.1f;
}
}
ModifierCalculatedEvent event = new ModifierCalculatedEvent(stack, caster, check, defaultValue, modifiedValue, OperationType.ADD);
MinecraftForge.EVENT_BUS.post(event);
return (int) Math.ceil(event.modifiedValue);
}
use of am2.api.spell.component.interfaces.ISpellModifier in project ArsMagica2 by Mithion.
the class TileEntityInscriptionTable method GetUpdatePacketForServer.
private byte[] GetUpdatePacketForServer() {
AMDataWriter writer = new AMDataWriter();
writer.add(FULL_UPDATE);
writer.add(this.currentPlayerUsing == null);
if (this.currentPlayerUsing != null)
writer.add(this.currentPlayerUsing.getEntityId());
writer.add(this.currentRecipe.size());
for (int i = 0; i < this.currentRecipe.size(); ++i) {
ISpellPart part = this.currentRecipe.get(i);
int id = part.getID();
if (part instanceof ISpellComponent)
id += SkillManager.COMPONENT_OFFSET;
else if (part instanceof ISpellModifier)
id += SkillManager.MODIFIER_OFFSET;
writer.add(id);
}
writer.add(this.shapeGroups.size());
for (ArrayList<ISpellPart> shapeGroup : this.shapeGroups) {
int[] groupData = new int[shapeGroup.size()];
for (int i = 0; i < shapeGroup.size(); ++i) {
groupData[i] = SkillManager.instance.getShiftedPartID(shapeGroup.get(i));
}
writer.add(groupData);
}
writer.add(currentSpellName);
writer.add(currentSpellIsReadOnly);
return writer.generate();
}
use of am2.api.spell.component.interfaces.ISpellModifier in project ArsMagica2 by Mithion.
the class TileEntityInscriptionTable method countModifiersInList.
private void countModifiersInList(ArrayList<ISpellPart> currentStage) {
for (ISpellPart part : currentStage) {
if (part instanceof ISpellModifier) {
EnumSet<SpellModifiers> modifiers = ((ISpellModifier) part).getAspectsModified();
for (SpellModifiers modifier : modifiers) {
int count = modifierCount.get(modifier) + 1;
modifierCount.put(modifier, count);
}
}
}
}
use of am2.api.spell.component.interfaces.ISpellModifier in project ArsMagica2 by Mithion.
the class AoE method manaCostMultiplier.
@Override
public float manaCostMultiplier(ItemStack spellStack) {
int multiplier = 2;
int radiusMods = 0;
int stages = SpellUtils.instance.numStages(spellStack);
for (int i = 0; i < stages; ++i) {
if (SpellUtils.instance.getShapeForStage(spellStack, i).getID() != this.getID())
continue;
ISpellModifier[] mods = SpellUtils.instance.getModifiersForStage(spellStack, i);
for (ISpellModifier modifier : mods) {
if (modifier.getAspectsModified().contains(SpellModifiers.RADIUS)) {
radiusMods++;
}
}
}
return multiplier * (radiusMods + 1);
}
use of am2.api.spell.component.interfaces.ISpellModifier in project ArsMagica2 by Mithion.
the class AoE method spawnAoEParticles.
private void spawnAoEParticles(ItemStack stack, EntityLivingBase caster, World world, double x, double y, double z, int radius) {
String pfxName = AMParticleIcons.instance.getParticleForAffinity(SpellUtils.instance.mainAffinityFor(stack));
float speed = 0.08f * radius;
int color = 0xFFFFFF;
if (SpellUtils.instance.modifierIsPresent(SpellModifiers.COLOR, stack, 0)) {
ISpellModifier[] mods = SpellUtils.instance.getModifiersForStage(stack, 0);
int ordinalCount = 0;
for (ISpellModifier mod : mods) {
if (mod instanceof Colour) {
byte[] meta = SpellUtils.instance.getModifierMetadataFromStack(stack, mod, 0, ordinalCount++);
color = (int) mod.getModifier(SpellModifiers.COLOR, null, null, null, meta);
}
}
}
for (int i = 0; i < 360; i += AMCore.config.FullGFX() ? 20 : AMCore.config.LowGFX() ? 40 : 60) {
AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(world, pfxName, x, y + 1.5f, z);
if (effect != null) {
effect.setIgnoreMaxAge(true);
effect.AddParticleController(new ParticleMoveOnHeading(effect, i, 0, speed, 1, false));
effect.noClip = false;
effect.setRGBColorI(color);
effect.AddParticleController(new ParticleFadeOut(effect, 1, false).setFadeSpeed(0.05f).setKillParticleOnFinish(true));
effect.AddParticleController(new ParticleLeaveParticleTrail(effect, pfxName, false, 5, 1, false).addControllerToParticleList(new ParticleFadeOut(effect, 1, false).setFadeSpeed(0.1f).setKillParticleOnFinish(true)).setParticleRGB_I(color).addRandomOffset(0.2f, 0.2f, 0.2f));
}
}
}
Aggregations