Started by
ktkyo_4
on
Topic category: Help with Minecraft modding (Java Edition)
Hello everyone, I am trying to get my custom armor to have a higher probability to get struck by lightning like vanilla lightning rods but I get lightning spammed onto me instead of them behaving like regular lightning bolts in thunder weather. How could I implement that mechanic? Also is it possible to avoid the lightning going through blocks like vanilla ones? Thanks in advance
while you are wearing each part of armor, use the random chance that mcreator has in procedure templates, or use the random number and if it equals a high number then strike lightning
Hey, thanks for the tip. I got it running. i thought of making it 1/100000 per tick like regular lightning but i figured that would make it really rare as regular lightning strike per chunk hence having more probability. I lowered it to 1/1000 and it's doing good. Only problem I have the lightning is still going through blocks. Is there any way to fix it?
you can check if the player can see the sky, but that might still strike you when under transparent blocks like glass, but you should test that out, using a higher chance to get struck will help with the tests
Worked just as you said. It still goes through transparent blocks. I'll have to think something out with solid block procedures I guess?
You could also check every block above the player using a counter, get the y level, subtract it from the max world height, and count up checking for any blocks not equal to air and strike if there is none, though this one is more work to make, and will be more intensive since it will be checking 4 times with each piece of armor.