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