Search in sources :

Example 1 with IContinuousModule

use of com.teamwizardry.wizardry.api.spell.IContinuousModule in project Wizardry by TeamWizardry.

the class EventHandler method fairyAmbush.

@SubscribeEvent
public void fairyAmbush(SpellCastEvent event) {
    Entity caster = event.getSpellData().getData(SpellData.DefaultKeys.CASTER);
    int chance = 5;
    for (SpellRing spellRing : SpellUtils.getAllSpellRings(event.getSpellRing())) if (spellRing instanceof IContinuousModule) {
        chance = 1000;
        break;
    }
    if (RandUtil.nextInt(chance) == 0 && caster != null) {
        List<EntityFairy> fairyList = event.getSpellData().world.getEntitiesWithinAABB(EntityFairy.class, new AxisAlignedBB(caster.getPosition()).grow(64, 64, 64));
        if (fairyList.isEmpty())
            return;
        EntityFairy fairy = fairyList.get(RandUtil.nextInt(fairyList.size() - 1));
        if (fairy == null)
            return;
        fairy.ambush = true;
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) IContinuousModule(com.teamwizardry.wizardry.api.spell.IContinuousModule) EntityFairy(com.teamwizardry.wizardry.common.entity.EntityFairy) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

IContinuousModule (com.teamwizardry.wizardry.api.spell.IContinuousModule)1 SpellRing (com.teamwizardry.wizardry.api.spell.SpellRing)1 EntityFairy (com.teamwizardry.wizardry.common.entity.EntityFairy)1 Entity (net.minecraft.entity.Entity)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1