Search in sources :

Example 1 with ORIGIN

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

the class ModuleEffectZoom method run.

@Override
public boolean run(@NotNull World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    Entity entityHit = spell.getVictim(world);
    Vec3d look = spell.getData(LOOK);
    Vec3d origin = spell.getData(ORIGIN);
    if (entityHit == null)
        return true;
    else {
        if (!spellRing.taxCaster(world, spell, true))
            return false;
        if (look == null)
            return true;
        if (origin == null)
            return true;
        double range = spellRing.getAttributeValue(world, AttributeRegistry.RANGE, spell);
        RayTraceResult trace = new RayTrace(world, look, origin, range).setEntityFilter(input -> input != entityHit).setIgnoreBlocksWithoutBoundingBoxes(true).setReturnLastUncollidableBlock(false).trace();
        spell.addData(ORIGINAL_LOC, entityHit.getPositionVector());
        entityHit.setPositionAndUpdate(trace.hitVec.x, trace.hitVec.y, trace.hitVec.z);
        entityHit.motionX = 0;
        entityHit.motionY = 0;
        entityHit.motionZ = 0;
        entityHit.velocityChanged = true;
    }
    if (entityHit instanceof EntityLivingBase) {
        ((EntityLivingBase) entityHit).addPotionEffect(new PotionEffect(ModPotions.NULLIFY_GRAVITY, 2, 1, true, false));
        ((EntityLivingBase) entityHit).addPotionEffect(new PotionEffect(ModPotions.NULL_MOVEMENT, 2, 1, true, false));
    }
    return true;
}
Also used : StaticInterp(com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp) ORIGIN(com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.ORIGIN) ModuleInstanceEffect(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceEffect) SpellData.constructField(com.teamwizardry.wizardry.api.spell.SpellData.constructField) ParticleSpawner(com.teamwizardry.librarianlib.features.particle.ParticleSpawner) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) PotionEffect(net.minecraft.potion.PotionEffect) RayTraceResult(net.minecraft.util.math.RayTraceResult) InterpLine(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpLine) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) SpellData(com.teamwizardry.wizardry.api.spell.SpellData) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) IModuleEffect(com.teamwizardry.wizardry.api.spell.module.IModuleEffect) Nonnull(javax.annotation.Nonnull) Entity(net.minecraft.entity.Entity) DataField(com.teamwizardry.wizardry.api.spell.SpellData.DataField) World(net.minecraft.world.World) LOOK(com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK) Wizardry(com.teamwizardry.wizardry.Wizardry) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) ModPotions(com.teamwizardry.wizardry.init.ModPotions) InterpColorHSV(com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV) AttributeRegistry(com.teamwizardry.wizardry.api.spell.attribute.AttributeRegistry) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ResourceLocation(net.minecraft.util.ResourceLocation) RegisterModule(com.teamwizardry.wizardry.api.spell.annotation.RegisterModule) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) NBTConstants(com.teamwizardry.wizardry.api.NBTConstants) NotNull(org.jetbrains.annotations.NotNull) Entity(net.minecraft.entity.Entity) PotionEffect(net.minecraft.potion.PotionEffect) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) RayTraceResult(net.minecraft.util.math.RayTraceResult) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

StaticInterp (com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp)1 InterpFloatInOut (com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut)1 InterpLine (com.teamwizardry.librarianlib.features.math.interpolate.position.InterpLine)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 Wizardry (com.teamwizardry.wizardry.Wizardry)1 NBTConstants (com.teamwizardry.wizardry.api.NBTConstants)1 SpellData (com.teamwizardry.wizardry.api.spell.SpellData)1 DataField (com.teamwizardry.wizardry.api.spell.SpellData.DataField)1 LOOK (com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK)1 ORIGIN (com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.ORIGIN)1 SpellData.constructField (com.teamwizardry.wizardry.api.spell.SpellData.constructField)1 SpellRing (com.teamwizardry.wizardry.api.spell.SpellRing)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 RandUtil (com.teamwizardry.wizardry.api.util.RandUtil)1 RayTrace (com.teamwizardry.wizardry.api.util.RayTrace)1