Search in sources :

Example 6 with RayTrace

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));
}
Also used : Entity(net.minecraft.entity.Entity) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) NetworkRegistry(net.minecraftforge.fml.common.network.NetworkRegistry) RayTraceResult(net.minecraft.util.math.RayTraceResult) World(net.minecraft.world.World) PacketRenderLightningBolt(com.teamwizardry.wizardry.common.network.PacketRenderLightningBolt) Vec3d(net.minecraft.util.math.Vec3d) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 7 with RayTrace

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;
}
Also used : Entity(net.minecraft.entity.Entity) SpellData(com.teamwizardry.wizardry.api.spell.SpellData) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) RayTraceResult(net.minecraft.util.math.RayTraceResult) World(net.minecraft.world.World) Vec3d(net.minecraft.util.math.Vec3d)

Example 8 with RayTrace

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;
}
Also used : 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)

Aggregations

RayTrace (com.teamwizardry.wizardry.api.util.RayTrace)8 RayTraceResult (net.minecraft.util.math.RayTraceResult)8 Vec3d (net.minecraft.util.math.Vec3d)8 Entity (net.minecraft.entity.Entity)7 World (net.minecraft.world.World)5 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 BlockPos (net.minecraft.util.math.BlockPos)2 TileMod (com.teamwizardry.librarianlib.features.base.block.tile.TileMod)1 StaticInterp (com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp)1 InterpBezier3D (com.teamwizardry.librarianlib.features.math.interpolate.position.InterpBezier3D)1 ParticleBuilder (com.teamwizardry.librarianlib.features.particle.ParticleBuilder)1 ParticleSpawner (com.teamwizardry.librarianlib.features.particle.ParticleSpawner)1 InterpFadeInOut (com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut)1 Module (com.teamwizardry.librarianlib.features.saving.Module)1 Save (com.teamwizardry.librarianlib.features.saving.Save)1 ClientRunnable (com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable)1 Wizardry (com.teamwizardry.wizardry.Wizardry)1 ConfigValues (com.teamwizardry.wizardry.api.ConfigValues)1 Constants (com.teamwizardry.wizardry.api.Constants)1 LightningGenerator (com.teamwizardry.wizardry.api.LightningGenerator)1