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