Jump to content

Shoot Lightning out of Item


nayoshi12

Recommended Posts

Hi, I was trying to create an Item to shoot lightning as a projectile, I found these code and Implemented it onto mine. But I have some errors cannot find symbols here is the code:

LightningIngot.java

 

public class LightningIngot extends Item {

    private static final String name = "LightningIngot";

    public LightningIngot() {

        GameRegistry.registerItem(this, name);

        setUnlocalizedName(name);

        setTextureName("nayocraft" + ":" + name);

        setCreativeTab(Top.nayotab);

 

    }

    public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)

    {

        float f = 1.0F;

        float f1 = entityplayer.prevRotationPitch + (entityplayer.rotationPitch - entityplayer.prevRotationPitch) * f;

        float f2 = entityplayer.prevRotationYaw + (entityplayer.rotationYaw - entityplayer.prevRotationYaw) * f;

        double d = entityplayer.prevPosX + (entityplayer.posX - entityplayer.prevPosX) * (double)f;

        double d1 = (entityplayer.prevPosY + (entityplayer.posY - entityplayer.prevPosY) * (double)f + 1.6200000000000001D) - (double)entityplayer.yOffset;

        double d2 = entityplayer.prevPosZ + (entityplayer.posZ - entityplayer.prevPosZ) * (double)f;

        Vec3 vec3d = Vec3.createVectorHelper(d, d1, d2);

        float f3 = MathHelper.cos(-f2 * 0.01745329F - 3.141593F);

        float f4 = MathHelper.sin(-f2 * 0.01745329F - 3.141593F);

        float f5 = -MathHelper.cos(-f1 * 0.01745329F);

        float f6 = MathHelper.sin(-f1 * 0.01745329F);

        float f7 = f4 * f5;

        float f8 = f6;

        float f9 = f3 * f5;

        double d3 = 5000D;

        Vec3 vec3d1 = vec3d.addVector((double)f7 * d3, (double)f8 * d3, (double)f9 * d3);

        MovingObjectPosition movingobjectposition = world.rayTraceBlocks_do_do(vec3d, vec3d1, false, true);

        if (movingobjectposition == null)

        {

            return itemstack;

        }

        if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE)

        {

            int i = movingobjectposition.blockX;

            int j = movingobjectposition.blockY;

            int k = movingobjectposition.blockZ;

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

        }

        return itemstack;

    }

    }

 

}

 

 

Link to comment
Share on other sites

  • 2 months later...

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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