Started by
Gabry_2317
on
Topic category: Help with Minecraft modding (Java Edition)
I'm creating a jujutsu kaisen mod and I wanted to create an object/block/entity that sums up the red revers or that repels all the mobs within a radius of 5 blocks and 10 blocks away. I tried to use an explosion but it pushes back and also does damage to the player how can I do it so that I can push back and do damage only to mobs
Here's a 'basic' example of how to launch entities away from a point, though fair warning, it involves some math, and can be kind of annoying to balance properly. In your case, you would want to run this example on the player's update tick if they have your custom effect, and make sure to also check that the entity iterator DOES NOT equal the player. (Otherwise it will launch the player as well, or cause a bug since the outwards force will be centered on their position.) I promise this is relavant:
(Code] Trying to make block with bounce on all sides of block. | MCreator
For the part where you also damage the mobs, you would simply want to add a function inside the entity iterator with a random chance of damaging the entities. Random, (and very low), because the procedure is going to be running 20 times per second. If you really want to you could also configure it to deal more damage based on proximity, but it will kind of do this by default since things closer to the player will take longer to get outside the radius of the effect, and thus be more likely to be dealt damage.
Thank you. as you said there is a way to inflict more damage based on proximity if you can inform me how to do it, thanks
how do i send images or files? i have a procedure if you want it
Can i see it ?