Search in sources :

Example 1 with PacketRenderLightningBolt

use of com.teamwizardry.wizardry.common.network.PacketRenderLightningBolt 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)

Aggregations

RayTrace (com.teamwizardry.wizardry.api.util.RayTrace)1 PacketRenderLightningBolt (com.teamwizardry.wizardry.common.network.PacketRenderLightningBolt)1 Entity (net.minecraft.entity.Entity)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1 Vec3d (net.minecraft.util.math.Vec3d)1 World (net.minecraft.world.World)1 NetworkRegistry (net.minecraftforge.fml.common.network.NetworkRegistry)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1