Jump to content

[1.7.2] [Solved] How to make a mob attack with lightning?


Gamer128

Recommended Posts

Hi

 

It should be relatively straightforward; I imagine your attack code just needs to spawn an EntityLightningBolt at the right location (of the enemy) - on the server side only

 

From WorldServer:

 

            this.theProfiler.endStartSection("thunder");
            int i1;
            int j1;
            int k1;
            int l1;

            if (provider.canDoLightning(chunk) && this.rand.nextInt(100000) == 0 && this.isRaining() && this.isThundering())
            {
                this.updateLCG = this.updateLCG * 3 + 1013904223;
                i1 = this.updateLCG >> 2;
                j1 = k + (i1 & 15);
                k1 = l + (i1 >> 8 & 15);
                l1 = this.getPrecipitationHeight(j1, k1);

                if (this.canLightningStrikeAt(j1, l1, k1))
                {
                    this.addWeatherEffect(new EntityLightningBolt(this, (double)j1, (double)l1, (double)k1));
                }
            }

            this.theProfiler.endStartSection("iceandsnow");

 

-TGG

Link to comment
Share on other sites

I believe summoning lightning at a player is easier.

 

int px = worldObj.getClosestPlayerToEntity(this, 64).posX;

 

That gives you the x position of the player.

Do the same with the other positions of the player (posY and posZ);

 

worldObj.addWeatherEffect(new EntityLightningBolt(worldObj, px, py, pz));

 

you could use that in your onUpdate() method.

Link to comment
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.
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.