I've been trying to make a sword that strikes lightning every time it hits a mob but the game just keeps on crashing.

Started by Meruto_ on

Topic category: Help with modding (Java Edition)

Last seen on 03:15, 23. Feb 2023
Joined Feb 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I've been trying to make a sword that strikes lightning every time it hits a mob but the game just keeps on crashing.

I don't know what I am doing. It just keeps crashing every time I hit a mob.

Last seen on 16:38, 6. Mar 2023
Joined Dec 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I have the same problem and…
Sat, 02/11/2023 - 10:38

I have the same problem and im working on it.

If I know what to do, I will try to help you.

Last seen on 03:15, 23. Feb 2023
Joined Feb 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks, I just wanna' make…
Sat, 02/11/2023 - 13:50

Thanks, I just wanna' make some simple mods for me and my brother to play with.

Last seen on 18:52, 23. Apr 2024
Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I tested it out and it is…
Sat, 02/11/2023 - 21:00

I tested it out and it is working, could you show me your procedure?

Last seen on 03:15, 23. Feb 2023
Joined Feb 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I followed a YT guide but in…
Mon, 02/13/2023 - 01:51

I followed a YT guide but in that guide, you were supposed to right click instead to hit every mob in the radius but I thought maybe with a few tweaks I could make it instead strike lightning with every sword hit(I don't know yet how to make RNG).

I reduced the size to just 1 and it kinda' works- but the user gets hit too(even when I'm 3 blocks away from the target).

Last seen on 18:52, 23. Apr 2024
Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Well, your procedure is…
Mon, 02/13/2023 - 04:05

Well, your procedure is correct and should work without crashing your game. A few questions:

How is this procedure called? For example, when you right click.

Where is the procedure that you tweaked?

 

I will probably try to recreate a woking procedure that strikes lightning when attacking, but how do you want it to work? Like, when the player hits the entity, just 1 lighting shall strike, or all nearby entities, and what chance of it happening?

Last seen on 03:15, 23. Feb 2023
Joined Feb 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Oh yeah it doesn't crash it…
Wed, 02/15/2023 - 04:39

Oh yeah it doesn't crash it anymore, I forgot I was using a different procedure for it that caused the crashing. The first pic I sent does not 'cause the crashing.

Its trigger is "when living entity is hit with tool".

The first pic I sent wasn't updated(I thought it was), but I reduced the radius to just 1 and had it give the player fire resistance so they won't die from the fire after the lightning strike(although they can still die from the lightning damage still).

Anyway this is an updated version- I messed around a bit and with my little knowledge of coding, came up with this. The potion effect is unnecessary, it's just there as a placeholder since I don't know how to cram this all in one 'if'.

What it's supposed to do is-
*Have only a 25% chance of activating(this works, I think)
*Only hit mobs that is not the player itself(doesn't work, still hits the player with lightning and causes the player to die)
*Damage the tool

It works overall, HOWEVER just now as I was typing this I was suddenly hit with more braincells.

What if the procedure is doing what I intended it to do, it's just that the lightning has a large radius of damage? But I'm hitting the mob 3 blocks away and I'm still getting damaged by lightning(although the lightning isn't directly hitting me).

Last seen on 03:15, 23. Feb 2023
Joined Feb 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If that is the case-I mean…
Wed, 02/15/2023 - 04:42

If that is the case-

I mean the lightning strike just has a large radius that it still hits the player. Then please disregard my problem then, I'm just being a bit of a dum dum.

But without that, my problem is still- how will I cram the RNG and 'Is Event/target entity tagged in entity tags as EntityPlayer = true' into one If?

Last seen on 18:52, 23. Apr 2024
Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Allright so i made a few…
Wed, 02/15/2023 - 15:30

Allright so i made a few options you can use. Feel free to use and play around with the numbers as you see fit. I will try to explain them as good as i can.

1. First one is very simple and aims to mimic a lighting strike.

As you can see, the Random [0.1) < 0.25 means 25%. Lightning strike only spawns the effect. Then add damage and set target on fire, change the numbers if you want it more powerful or weaker. And lastly, it deals 4 damage to the tool as you wanted. This is a safe option and very stright foward, only thing is that it does not set fire to blocks around and does not deal AoE damage.

 

2. This one summons a normal lightning strike and gives a buff to the player that prevents them from taking damage from the lighting strike. 

First create a "effect" and call it something you remember

Uncheck its visability in hud and inventory.

Then add this procedure to "when entity hit", it is pretty much the same as before, then change the duration to at or above 20 ticks.

Now we make a global trigger that cancels lighting stirke damage when we have this effect. Create a new procedure like this:

The "cancel event" is found in "advanced". 

Hopefully this will help you out!