Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

So.... I tried some things.... Screwed a lot of them up... And I finally thought of this. I wanted to spawn a lightning bolt in the world whenever my custom projectile hit a block. One problem. The lightning does not appear. Oh, it lights the stuff on fire, makes the noise, and all that great stuff, even spawns the smoke particles I didn't even know appeared... But it doesn't render... What am I doing wrong?

 

 

 

package net.CJCutrone.LegendofZelda.entity.Entity;

 

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.effect.EntityLightningBolt;

import net.minecraft.entity.player.EntityPlayerMP;

import net.minecraft.entity.projectile.EntityThrowable;

import net.minecraft.util.DamageSource;

import net.minecraft.util.MathHelper;

import net.minecraft.util.MovingObjectPosition;

import net.minecraft.world.World;

import net.minecraftforge.common.MinecraftForge;

import net.minecraftforge.event.entity.living.EnderTeleportEvent;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class EntityLightning extends EntityThrowable

{

    public EntityLightning(World par1World)

    {

        super(par1World);

    }

 

    public EntityLightning(World par1World, EntityLivingBase par2EntityLivingBase)

    {

        super(par1World, par2EntityLivingBase);

    }

 

    @SideOnly(Side.CLIENT)

    public EntityLightning(World par1World, double par2, double par4, double par6)

    {

        super(par1World, par2, par4, par6);

    }

 

    @Override

    protected void onImpact(MovingObjectPosition par1MovingObjectPosition)

    { 

       

        if (!this.worldObj.isRemote)

        {

        double i = par1MovingObjectPosition.blockX;

 

            double j = par1MovingObjectPosition.blockY;

 

            double k = par1MovingObjectPosition.blockZ;

 

            worldObj.spawnEntityInWorld(new EntityLightningBolt(worldObj, i, j, k));

           

            this.setDead();

        }

       

    }

 

    public void setVelocity(double par1, double par3, double par5)

    {

        this.motionX = par1;

        this.motionY = par3;

        this.motionZ = par5;

 

        if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)

        {

            float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5);

            this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI);

            this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)f) * 180.0D/ Math.PI);

            this.prevRotationPitch = this.rotationPitch;

            this.prevRotationYaw = this.rotationYaw;

            this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);

        }

    }

   

    @Override

    protected float getGravityVelocity()

    {

        return 0.005F;

    }

    public float getShadowSize()

    {

        return 0.0F;

    }

}

 

 

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.