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;
}
Aggregations