Help with lightning striking armor

Started by GauceBoss on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jan 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Help with lightning striking armor
Tue, 01/17/2023 - 00:23 (edited)

Hey there, just got Mcreator just 3 hours ago and have been trying to make a simple mod. I've been designing this copper armor that when you wear the helmet, there is a chance of striking lightning on your player when wearing it.

However I am having trouble making random times of lightning appearing on top of you. Usually nothing happens for a few seconds but then revs up and suddenly a ton of lightning strike you over and over.

I simply was lightning that appears at random times and does not spawn constantly over and over on you.

 

Edited by GauceBoss on Tue, 01/17/2023 - 00:23
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Here's my recommendation:…
Tue, 01/17/2023 - 19:58

Here's my recommendation:

  • Make a custom, player-lifetime variable. (I'll call it 'duration.') Set it to whatever you want the minimum duration between lightning strikes to be, in ticks. (Each tick is a 20th of a second.)
  • Make a procedure that triggers on player update tick. If the player is wearing your custom armor, and the 'duration' variable is greater than zero, set it to itself minus one. If the player isn't wearing your custom armor, reset the duration to its default value. If the player is wearing the custom armor and the 'duration' variable is greater than zero, give it a small chance to strike lightning and reset the duration variable.

...This sort of controlled randomization is helpful for a lot of stuff. Your procedure is probably working just fine in its current state; it's just that genuine randomness can often result in long periods of nothing and sudden bursts of way too many things all at once. 

Joined May 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Any way to do this only when…
Tue, 06/25/2024 - 18:04

Any way to do this only when there's a thunderstorm?