Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Summoning lightning bolt entity
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 1
kenny2810

Summoning lightning bolt entity

By kenny2810, July 16, 2014 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

kenny2810    0

kenny2810

kenny2810    0

  • Stone Miner
  • kenny2810
  • Members
  • 0
  • 62 posts
Posted July 16, 2014

I basically have an item, that when right clicked summonses a lightning bolt entity. I have been trying a variety of methods but none seem to work. The latest method I used was this:

 

http://pastebin.com/bP4iY1j7 (Used a link as spoilers wouldn't work)

 

What am I doing wrong? Is it the method, a parameter, or am I just messing up?

 

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6688

diesieben07

diesieben07    6688

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6688
  • 45727 posts
Posted July 16, 2014

Lighting bolts are handled differently from normal entities. Use addWeatherEffect instead of spawnEntity.

  • Quote

Share this post


Link to post
Share on other sites

kenny2810    0

kenny2810

kenny2810    0

  • Stone Miner
  • kenny2810
  • Members
  • 0
  • 62 posts
Posted July 17, 2014

Lighting bolts are handled differently from normal entities. Use addWeatherEffect instead of spawnEntity.

 

Ah thanks for your help! :)

  • Quote

Share this post


Link to post
Share on other sites

kenny2810    0

kenny2810

kenny2810    0

  • Stone Miner
  • kenny2810
  • Members
  • 0
  • 62 posts
Posted July 17, 2014

Sorry to be a bother, but I am still having issues. The problem is, I cannot summon lightning unless it is raining (I checked the code). Is there a way to override this?

  • Quote

Share this post


Link to post
Share on other sites

kenoba10    6

kenoba10

kenoba10    6

  • Creeper Killer
  • kenoba10
  • Members
  • 6
  • 127 posts
Posted July 18, 2014

float f = 1.0f;

        float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
        float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;

        double d = (double)f;

        double d1 = player.prevPosX + (player.posX - player.prevPosX) * d;
        double d2 = (player.prevPosY + (player.posY - player.prevPosY) * d + 1.6200000000000001d) - (double)player.yOffset;
        double d3 = player.prevPosZ + (player.posZ - player.prevPosZ) * d;

        Vec3 vec1 = Vec3.createVectorHelper(d1, d2, d3);

        float f11 = MathHelper.cos(-f2 * 0.01745329f - 3.141593f);
        float f12 = MathHelper.sin(-f2 * 0.01745329f - 3.141593f);
        float f13 = -MathHelper.cos(-f1 * 0.01745329f);
        float f14 = MathHelper.sin(-f1 * 0.01745329f);

        float f15 = f12 * f13;
        float f16 = f14;
        float f17 = f11 * f13;

        double d11 = 5000d;

        Vec3 vec2 = vec1.addVector((double)f15 * d11, (double)f16 * d11, (double)f17 * d11);

        MovingObjectPosition position = world.func_147447_a(vec1, vec2, false, true, true);

        if(position != null && position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {

            int x = position.blockX;
            int y = position.blockY;
            int z = position.blockZ;

            EntityLightningBolt lightning = new EntityLightningBolt(world, x, y, z);

            world.spawnEntityInWorld(lightning);

        }

 

This is the code I use in my mod and it works just fine

 

world is a World and player is an EntityPlayer

  • Quote

Share this post


Link to post
Share on other sites

jgp22805    0

jgp22805

jgp22805    0

  • Tree Puncher
  • jgp22805
  • Members
  • 0
  • 12 posts
Posted August 15
On 7/17/2014 at 9:05 PM, kenoba10 said:

 


float f = 1.0f;

        float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
        float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;

        double d = (double)f;

        double d1 = player.prevPosX + (player.posX - player.prevPosX) * d;
        double d2 = (player.prevPosY + (player.posY - player.prevPosY) * d + 1.6200000000000001d) - (double)player.yOffset;
        double d3 = player.prevPosZ + (player.posZ - player.prevPosZ) * d;

        Vec3 vec1 = Vec3.createVectorHelper(d1, d2, d3);

        float f11 = MathHelper.cos(-f2 * 0.01745329f - 3.141593f);
        float f12 = MathHelper.sin(-f2 * 0.01745329f - 3.141593f);
        float f13 = -MathHelper.cos(-f1 * 0.01745329f);
        float f14 = MathHelper.sin(-f1 * 0.01745329f);

        float f15 = f12 * f13;
        float f16 = f14;
        float f17 = f11 * f13;

        double d11 = 5000d;

        Vec3 vec2 = vec1.addVector((double)f15 * d11, (double)f16 * d11, (double)f17 * d11);

        MovingObjectPosition position = world.func_147447_a(vec1, vec2, false, true, true);

        if(position != null && position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {

            int x = position.blockX;
            int y = position.blockY;
            int z = position.blockZ;

            EntityLightningBolt lightning = new EntityLightningBolt(world, x, y, z);

            world.spawnEntityInWorld(lightning);

        }
 

 

 

I know this is old but I couldn't find any new threads but I was wondering if anyone knows why mine crashes my game it is a java.lang.ExceptionInInitializerError

 

 

  • Quote

Share this post


Link to post
Share on other sites

Animefan8888    677

Animefan8888

Animefan8888    677

  • Reality Controller
  • Animefan8888
  • Forge Modder
  • 677
  • 5746 posts
Posted August 15
19 minutes ago, jgp22805 said:

I know this is old but I couldn't find any new threads but I was wondering if anyone knows why mine crashes my game it is a java.lang.ExceptionInInitializerError

Make a new thread dont necro.

  • Quote

Share this post


Link to post
Share on other sites

jgp22805    0

jgp22805

jgp22805    0

  • Tree Puncher
  • jgp22805
  • Members
  • 0
  • 12 posts
Posted August 15
On 7/17/2014 at 9:05 PM, kenoba10 said:

 


 
 

 

 

thanks for the reply I will do that

 
 

 

  • Quote

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • MarkNutt0
      [1.12.2] if blockpos is entity

      By MarkNutt0 · Posted 35 minutes ago

      hi, im looking for a way to check if is/contains an entity rather than a block, ive tried stuff like this but cant seem to get it to work:   if (mc.world.getBlockState(pos).getBlock() == null)   cheers
    • diesieben07
      Memory Heap Thingy!

      By diesieben07 · Posted 3 hours ago

      That's not what this thread is about... Make your own thread and post logs.
    • gudie73
      Memory Heap Thingy!

      By gudie73 · Posted 3 hours ago

      It gets stuck on that part and doesn’t change
    • gudie73
      Memory Heap Thingy!

      By gudie73 · Posted 3 hours ago

      Wym  
    • RaphGamingz
      ScreenGui does nothing

      By RaphGamingz · Posted 4 hours ago

      any errors?
  • Topics

    • MarkNutt0
      0
      [1.12.2] if blockpos is entity

      By MarkNutt0
      Started 35 minutes ago

    • Mizinov
      7
      Memory Heap Thingy!

      By Mizinov
      Started August 24

    • Jaffaaaaa
      2
      ScreenGui does nothing

      By Jaffaaaaa
      Started Wednesday at 07:03 PM

    • jun2040
      5
      Game crashing when the block is activated

      By jun2040
      Started 20 hours ago

    • Merthew
      5
      [1.12.2] Multiple Structure Generation

      By Merthew
      Started November 7, 2018

  • Who's Online (See full list)

    • Ewa Ja
    • Focamacho
    • Neverless013
    • AntonBespoiasov
    • Choonster
    • mixcristian_71
    • Legenes
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Summoning lightning bolt entity
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community