Search in sources :

Example 1 with EntitySpellProjectile

use of com.teamwizardry.wizardry.common.entity.projectile.EntitySpellProjectile in project Wizardry by TeamWizardry.

the class ModuleShapeProjectile method run.

/**
 * {@inheritDoc}
 */
@Override
public boolean run(@NotNull World world, ModuleInstanceShape instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    if (world.isRemote)
        return true;
    Vec3d origin = spell.getOriginWithFallback(world);
    if (origin == null)
        return false;
    double dist = spellRing.getAttributeValue(world, AttributeRegistry.RANGE, spell);
    double speed = spellRing.getAttributeValue(world, AttributeRegistry.SPEED, spell);
    if (!spellRing.taxCaster(world, spell, true))
        return false;
    IShapeOverrides overrides = spellRing.getOverrideHandler().getConsumerInterface(IShapeOverrides.class);
    EntitySpellProjectile proj = new EntitySpellProjectile(world, spellRing, spell, (float) dist, (float) speed, (float) 0.1, !overrides.onRunProjectile(world, spell, spellRing));
    proj.setPosition(origin.x, origin.y, origin.z);
    proj.velocityChanged = true;
    boolean success = world.spawnEntity(proj);
    if (success)
        world.playSound(null, new BlockPos(origin), ModSounds.PROJECTILE_LAUNCH, SoundCategory.PLAYERS, 1f, (float) RandUtil.nextDouble(1, 1.5));
    return success;
}
Also used : EntitySpellProjectile(com.teamwizardry.wizardry.common.entity.projectile.EntitySpellProjectile) BlockPos(net.minecraft.util.math.BlockPos) Vec3d(net.minecraft.util.math.Vec3d) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Aggregations

ModuleOverride (com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)1 EntitySpellProjectile (com.teamwizardry.wizardry.common.entity.projectile.EntitySpellProjectile)1 BlockPos (net.minecraft.util.math.BlockPos)1 Vec3d (net.minecraft.util.math.Vec3d)1