Search in sources :

Example 1 with SpellCastEvent

use of com.teamwizardry.wizardry.api.events.SpellCastEvent in project Wizardry by TeamWizardry.

the class ModuleInstance method internalCastSpell.

private boolean internalCastSpell(@Nonnull World world, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    SpellCastEvent event = new SpellCastEvent(world, spellRing, spell);
    MinecraftForge.EVENT_BUS.post(event);
    return !event.isCanceled() && run(world, spell, spellRing);
}
Also used : SpellCastEvent(com.teamwizardry.wizardry.api.events.SpellCastEvent)

Example 2 with SpellCastEvent

use of com.teamwizardry.wizardry.api.events.SpellCastEvent in project Wizardry by TeamWizardry.

the class Module method castSpell.

/**
 * Use this to run the module properly without rendering.
 *
 * @param spell      The spellData associated with it.
 * @param spellRing The SpellRing made with this.
 * @return If the spellData has succeeded.
 */
public final boolean castSpell(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    if (spell.world.isRemote)
        return true;
    if (this instanceof ILingeringModule) {
        boolean alreadyLingering = false;
        for (SpellTicker.LingeringObject lingeringObject : SpellTicker.getStorageMap()) {
            if (lingeringObject.getSpellRing() == spellRing || lingeringObject.getSpellData() == spell) {
                alreadyLingering = true;
                break;
            }
        }
        if (!alreadyLingering)
            SpellTicker.addLingerSpell(spellRing, spell, ((ILingeringModule) this).getLingeringTime(spell, spellRing));
    }
    SpellCastEvent event = new SpellCastEvent(spellRing, spell);
    MinecraftForge.EVENT_BUS.post(event);
    return !event.isCanceled() && run(spell, spellRing);
}
Also used : SpellTicker(com.teamwizardry.wizardry.common.core.SpellTicker) SpellCastEvent(com.teamwizardry.wizardry.api.events.SpellCastEvent) ILingeringModule(com.teamwizardry.wizardry.api.spell.ILingeringModule)

Aggregations

SpellCastEvent (com.teamwizardry.wizardry.api.events.SpellCastEvent)2 ILingeringModule (com.teamwizardry.wizardry.api.spell.ILingeringModule)1 SpellTicker (com.teamwizardry.wizardry.common.core.SpellTicker)1