use of com.teamwizardry.wizardry.api.util.RayTrace in project Wizardry by TeamWizardry.
the class ModuleEffectLightning method render.
@Override
@SideOnly(Side.CLIENT)
public void render(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
World world = spell.world;
float yaw = spell.getData(YAW, 0F);
float pitch = spell.getData(PITCH, 0F);
Entity caster = spell.getCaster();
Vec3d target = spell.getTarget();
long seed = spell.getData(SEED, 0L);
double range = spellRing.getAttributeValue(AttributeRegistry.RANGE, spell);
if (target == null)
return;
Vec3d origin = target;
if (caster != null) {
float offX = 0.5f * (float) Math.sin(Math.toRadians(-90.0f - yaw));
float offZ = 0.5f * (float) Math.cos(Math.toRadians(-90.0f - yaw));
origin = new Vec3d(offX, 0, offZ).add(target);
}
RayTraceResult traceResult = new RayTrace(world, PosUtils.vecFromRotations(pitch, yaw), target, range).setSkipBlocks(true).setSkipEntities(true).trace();
PacketHandler.NETWORK.sendToAllAround(new PacketRenderLightningBolt(origin, traceResult.hitVec, seed), new NetworkRegistry.TargetPoint(world.provider.getDimension(), origin.x, origin.y, origin.z, 256));
}
use of com.teamwizardry.wizardry.api.util.RayTrace 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;
}
use of com.teamwizardry.wizardry.api.util.RayTrace in project Wizardry by TeamWizardry.
the class ModuleShapeTouch method run.
@Override
public boolean run(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
Vec3d look = spell.getData(LOOK);
Entity caster = spell.getCaster();
Vec3d origin = spell.getOrigin();
if (look == null)
return false;
if (caster == null)
return false;
if (origin == null)
return false;
if (!spellRing.taxCaster(spell))
return false;
RayTraceResult result = new RayTrace(spell.world, look, origin, caster instanceof EntityLivingBase ? ((EntityLivingBase) caster).getEntityAttribute(EntityPlayer.REACH_DISTANCE).getAttributeValue() : 5).setSkipEntity(caster).setReturnLastUncollidableBlock(true).setIgnoreBlocksWithoutBoundingBoxes(false).trace();
spell.processBlock(result.getBlockPos(), result.sideHit, result.hitVec);
return true;
}
Aggregations