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

I need help, I need to know how to make a mob attack with lightning. (Sorry if there is already a thread for this I searched and didn't see one)

  • Author

Yeah I mean like shoot a lightning bolt down at the player / whatever it is fighting

I believe one of the modifiers in the Infernal Mobs mod makes the mob strike you with lightning so there must be a way

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

  • Author

Still having trouble, I'm not exactly sure how to use that code in the method for attacking with a ranged attack (although I may just be stupid and am missing something obvious)

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.

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.