Search in sources :

Example 6 with SpellData

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

the class ModuleShapeCone method run.

@Override
public boolean run(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    World world = spell.world;
    float yaw = spell.getData(YAW, 0F);
    float pitch = spell.getData(PITCH, 0F);
    Vec3d position = spell.getData(ORIGIN);
    Entity caster = spell.getCaster();
    if (position == null)
        return false;
    double range = spellRing.getAttributeValue(AttributeRegistry.RANGE, spell);
    int chance = (int) (spellRing.getAttributeValue(AttributeRegistry.POTENCY, spell));
    spellRing.multiplyMultiplierForAll((float) (range / 8.0 * chance / 16.0));
    Vec3d origin = spell.getOriginHand();
    if (origin == null)
        return false;
    for (int i = 0; i < chance; i++) {
        double angle = range * 2;
        float newPitch = (float) (pitch + RandUtil.nextDouble(-angle, angle));
        float newYaw = (float) (yaw + RandUtil.nextDouble(-angle, angle));
        Vec3d target = PosUtils.vecFromRotations(newPitch, newYaw);
        SpellData newSpell = spell.copy();
        RayTraceResult result = new RayTrace(world, target.normalize(), origin, range).setSkipEntity(caster).trace();
        Vec3d lookFallback = spell.getData(LOOK);
        if (lookFallback != null)
            lookFallback.scale(range);
        newSpell.processTrace(result, lookFallback);
        sendRenderPacket(newSpell, spellRing);
        newSpell.addData(ORIGIN, result.hitVec);
        if (spellRing.getChildRing() != null) {
            spellRing.getChildRing().runSpellRing(newSpell.copy());
        }
    }
    return true;
}
Also used : Entity(net.minecraft.entity.Entity) SpellData(com.teamwizardry.wizardry.api.spell.SpellData) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) RayTraceResult(net.minecraft.util.math.RayTraceResult) World(net.minecraft.world.World) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

SpellData (com.teamwizardry.wizardry.api.spell.SpellData)6 Entity (net.minecraft.entity.Entity)4 BlockPos (net.minecraft.util.math.BlockPos)4 Vec3d (net.minecraft.util.math.Vec3d)4 World (net.minecraft.world.World)4 SpellRing (com.teamwizardry.wizardry.api.spell.SpellRing)2 Block (net.minecraft.block.Block)2 IBlockState (net.minecraft.block.state.IBlockState)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2 StaticInterp (com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp)1 InterpHelix (com.teamwizardry.librarianlib.features.math.interpolate.position.InterpHelix)1 ParticleBuilder (com.teamwizardry.librarianlib.features.particle.ParticleBuilder)1 ParticleSpawner (com.teamwizardry.librarianlib.features.particle.ParticleSpawner)1 InterpColorHSV (com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV)1 InterpFadeInOut (com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut)1 Wizardry (com.teamwizardry.wizardry.Wizardry)1 Constants (com.teamwizardry.wizardry.api.Constants)1 IWizardryCapability (com.teamwizardry.wizardry.api.capability.IWizardryCapability)1