Search in sources :

Example 6 with ModuleOverride

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

the class ModuleEffectTimeSlow method onRunZone.

@ModuleOverride("shape_zone_run")
public boolean onRunZone(World world, SpellData data, SpellRing ring, @ContextRing SpellRing childRing) {
    double aoe = ring.getAttributeValue(world, AttributeRegistry.AREA, data);
    double range = ring.getAttributeValue(world, AttributeRegistry.RANGE, data);
    Vec3d targetPos = data.getTarget(world);
    if (targetPos == null)
        return false;
    Vec3d min = targetPos.subtract(aoe, range, aoe);
    Vec3d max = targetPos.add(aoe, range, aoe);
    List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(min, max));
    for (Entity entity : entities) {
        if (entity instanceof EntityLivingBase) {
            if (!((EntityLivingBase) entity).isPotionActive(ModPotions.TIME_SLOW) && entity.getDistanceSq(targetPos.x, targetPos.y, targetPos.z) <= aoe * aoe) {
                data.processEntity(entity, false);
                runOnStart(world, data, childRing);
            }
        }
    }
    return true;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Vec3d(net.minecraft.util.math.Vec3d) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Example 7 with ModuleOverride

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

the class ModuleEffectFrost method onRunZone.

@ModuleOverride("shape_zone_run")
public boolean onRunZone(World world, SpellData data, SpellRing ring, @ContextRing SpellRing childRing) {
    if (!world.isRemote)
        return false;
    double aoe = ring.getAttributeValue(world, AttributeRegistry.AREA, data);
    double range = ring.getAttributeValue(world, AttributeRegistry.RANGE, data);
    Vec3d targetPos = data.getTarget(world);
    if (targetPos == null)
        return false;
    Vec3d min = targetPos.subtract(aoe, range, aoe);
    Vec3d max = targetPos.add(aoe, range, aoe);
    List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(min, max));
    for (Entity entity : entities) {
        entity.extinguish();
        if (entity instanceof EntityLivingBase) {
            if (!((EntityLivingBase) entity).isPotionActive(ModPotions.SLIPPERY) && entity.getDistanceSq(targetPos.x, targetPos.y, targetPos.z) <= aoe * aoe) {
                double time = childRing.getAttributeValue(world, AttributeRegistry.DURATION, data) * 10;
                world.playSound(null, entity.getPosition(), ModSounds.FROST_FORM, SoundCategory.NEUTRAL, 1, 1);
                ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(ModPotions.SLIPPERY, (int) time, 0, true, false));
            }
        }
    }
    return false;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) PotionEffect(net.minecraft.potion.PotionEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Vec3d(net.minecraft.util.math.Vec3d) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Example 8 with ModuleOverride

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

the class ModuleEffectLowGravity method onRunZone.

@ModuleOverride("shape_zone_run")
public boolean onRunZone(World world, SpellData data, SpellRing ring, @ContextRing SpellRing childRing) {
    double aoe = ring.getAttributeValue(world, AttributeRegistry.AREA, data);
    double range = ring.getAttributeValue(world, AttributeRegistry.RANGE, data);
    Vec3d targetPos = data.getTarget(world);
    if (targetPos == null)
        return false;
    Vec3d min = targetPos.subtract(aoe, range, aoe);
    Vec3d max = targetPos.add(aoe, range, aoe);
    List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(min, max));
    for (Entity entity : entities) {
        if (entity instanceof EntityLivingBase) {
            if (!((EntityLivingBase) entity).isPotionActive(ModPotions.LOW_GRAVITY) && entity.getDistanceSq(targetPos.x, targetPos.y, targetPos.z) <= aoe * aoe) {
                data.processEntity(entity, false);
                run(world, (ModuleInstanceEffect) childRing.getModule(), data, childRing);
            }
        }
    }
    return true;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Vec3d(net.minecraft.util.math.Vec3d) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Example 9 with ModuleOverride

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

the class ModuleEffectLightning method onRunTouch.

@ModuleOverride("shape_touch_run")
public void onRunTouch(@ContextSuper ModuleOverrideSuper ovdSuper, World world, SpellData data, SpellRing shape, @ContextRing SpellRing childRing) {
    if (ovdSuper.hasSuper())
        ovdSuper.invoke(true, world, data, shape);
    Vec3d look = data.getData(LOOK);
    Entity caster = data.getCaster(world);
    Vec3d origin = data.getOriginWithFallback(world);
    if (look == null || caster == null || origin == null)
        return;
    if (!childRing.taxCaster(world, data, true))
        return;
    double range = childRing.getAttributeValue(world, AttributeRegistry.RANGE, data);
    double potency = childRing.getAttributeValue(world, AttributeRegistry.POTENCY, data);
    double duration = childRing.getAttributeValue(world, AttributeRegistry.DURATION, data);
    RayTraceResult trace = new RayTrace(world, look, origin, caster instanceof EntityLivingBase ? ((EntityLivingBase) caster).getEntityAttribute(EntityPlayer.REACH_DISTANCE).getAttributeValue() : 5).setEntityFilter(input -> input != caster).setReturnLastUncollidableBlock(true).setIgnoreBlocksWithoutBoundingBoxes(true).trace();
    doLightning(RandUtil.nextLong(100, 100000), world, caster, origin, trace.hitVec, range, potency, duration);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ModuleInstanceEffect(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceEffect) ModuleOverrideSuper(com.teamwizardry.wizardry.api.spell.module.ModuleOverrideSuper) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride) PosUtils(com.teamwizardry.wizardry.api.util.PosUtils) PacketRenderLightningBolt(com.teamwizardry.wizardry.common.network.PacketRenderLightningBolt) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) RayTraceResult(net.minecraft.util.math.RayTraceResult) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) RandUtilSeed(com.teamwizardry.wizardry.api.util.RandUtilSeed) ModSounds(com.teamwizardry.wizardry.init.ModSounds) SpellData(com.teamwizardry.wizardry.api.spell.SpellData) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) IModuleEffect(com.teamwizardry.wizardry.api.spell.module.IModuleEffect) SoundCategory(net.minecraft.util.SoundCategory) Nonnull(javax.annotation.Nonnull) LightningGenerator(com.teamwizardry.wizardry.api.LightningGenerator) ContextRing(com.teamwizardry.wizardry.api.spell.annotation.ContextRing) Entity(net.minecraft.entity.Entity) PacketHandler(com.teamwizardry.librarianlib.features.network.PacketHandler) World(net.minecraft.world.World) ContextSuper(com.teamwizardry.wizardry.api.spell.annotation.ContextSuper) LOOK(com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) BlockPos(net.minecraft.util.math.BlockPos) AttributeRegistry(com.teamwizardry.wizardry.api.spell.attribute.AttributeRegistry) NetworkRegistry(net.minecraftforge.fml.common.network.NetworkRegistry) LightningTracker(com.teamwizardry.wizardry.common.core.LightningTracker) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) RegisterModule(com.teamwizardry.wizardry.api.spell.annotation.RegisterModule) EntityLightningProjectile(com.teamwizardry.wizardry.common.entity.projectile.EntityLightningProjectile) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) NotNull(org.jetbrains.annotations.NotNull) Entity(net.minecraft.entity.Entity) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) RayTraceResult(net.minecraft.util.math.RayTraceResult) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Vec3d(net.minecraft.util.math.Vec3d) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Example 10 with ModuleOverride

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

the class ModuleEffectLightning method onRunZone.

@ModuleOverride("shape_zone_run")
public boolean onRunZone(@ContextSuper ModuleOverrideSuper ovdSuper, World world, SpellData data, SpellRing shape, @ContextRing SpellRing childRing) {
    if (ovdSuper.hasSuper())
        ovdSuper.invoke(true, world, data, shape);
    Entity caster = data.getCaster(world);
    Vec3d targetPos = data.getTargetWithFallback(world);
    if (targetPos == null)
        return true;
    if (!childRing.taxCaster(world, data, true))
        return true;
    double lightningRange = childRing.getAttributeValue(world, AttributeRegistry.RANGE, data);
    double lightningPotency = childRing.getAttributeValue(world, AttributeRegistry.POTENCY, data);
    double lightningDuration = childRing.getAttributeValue(world, AttributeRegistry.DURATION, data);
    double zoneAoE = shape.getAttributeValue(world, AttributeRegistry.AREA, data);
    double zoneRange = shape.getAttributeValue(world, AttributeRegistry.RANGE, data);
    Vec3d min = targetPos.subtract(zoneAoE / 2, zoneRange / 2, zoneAoE / 2);
    Vec3d max = targetPos.add(zoneAoE / 2, zoneRange / 2, zoneAoE / 2);
    RandUtilSeed rand = new RandUtilSeed(RandUtil.nextLong(100, 100000));
    Vec3d from = new Vec3d(rand.nextDouble(min.x, max.x), rand.nextDouble(min.y, max.y), rand.nextDouble(min.z, max.z));
    float pitch = (float) (180 * Math.asin(2 * rand.nextDouble() - 1) / Math.PI);
    float yaw = (float) rand.nextDouble(360);
    Vec3d to = Vec3d.fromPitchYaw(pitch, yaw).normalize().scale(lightningRange).add(from);
    doLightning(rand.nextLong(100, 100000), world, caster, from, to, lightningRange, lightningPotency, lightningDuration);
    return true;
}
Also used : Entity(net.minecraft.entity.Entity) RandUtilSeed(com.teamwizardry.wizardry.api.util.RandUtilSeed) Vec3d(net.minecraft.util.math.Vec3d) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Aggregations

ModuleOverride (com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)11 Vec3d (net.minecraft.util.math.Vec3d)10 Entity (net.minecraft.entity.Entity)9 EntityLivingBase (net.minecraft.entity.EntityLivingBase)5 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)5 RandUtilSeed (com.teamwizardry.wizardry.api.util.RandUtilSeed)4 RayTrace (com.teamwizardry.wizardry.api.util.RayTrace)2 EntityLightningProjectile (com.teamwizardry.wizardry.common.entity.projectile.EntityLightningProjectile)2 RayTraceResult (net.minecraft.util.math.RayTraceResult)2 PacketHandler (com.teamwizardry.librarianlib.features.network.PacketHandler)1 LightningGenerator (com.teamwizardry.wizardry.api.LightningGenerator)1 SpellData (com.teamwizardry.wizardry.api.spell.SpellData)1 LOOK (com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK)1 SpellRing (com.teamwizardry.wizardry.api.spell.SpellRing)1 ContextRing (com.teamwizardry.wizardry.api.spell.annotation.ContextRing)1 ContextSuper (com.teamwizardry.wizardry.api.spell.annotation.ContextSuper)1 RegisterModule (com.teamwizardry.wizardry.api.spell.annotation.RegisterModule)1 AttributeRegistry (com.teamwizardry.wizardry.api.spell.attribute.AttributeRegistry)1 IModuleEffect (com.teamwizardry.wizardry.api.spell.module.IModuleEffect)1 ModuleInstanceEffect (com.teamwizardry.wizardry.api.spell.module.ModuleInstanceEffect)1