Started by
DuckyGK
on
Topic category: Help with Minecraft modding (Java Edition)
So I have some code that basicly when the sword is right clicked, it will shoot a sonic boom that deals damage. I got the sonic boom part with all the particles but I cant figure out why the damage is not working. Also, is it possible to only make it a certain range and if so how? Thanks in advance!
You'd need to find a unit vector to control range. To do that you'd calculate the magnitude of the vector, (find the differences between the player and their target's x/y/z positions, square them, add them together, and then take the square root.) If you divide the x/y/z components by the magnitude, you'll get a 'unit vector,' which has the same direction, but a length of exactly 1, meaning you can multiply it to control the range. (You could also just check if the magnitude exceeds a certain number.) TBH, I imagine you'll have more trouble targeting an entity, I'm pretty sure look angles are mostly just used for getting blocks.
Could you link a picture of the code, I’m really new to coding and dont understand much
Also, after I do that, how would I deal the damage?