Skript icon indicating copy to clipboard operation
Skript copied to clipboard

Adds checks to not normalize zero vectors

Open Phill310 opened this issue 1 year ago • 4 comments

Description

Checks if a vector is zero before calling Vector#normalize() in order to avoid creating vectors with infinite components (stemming from dividing by 0). Currently, syntax that would cause an internal error now returns a zero vector which might be a breaking change according to sovde.


Target Minecraft Versions: any Requirements: none Related Issues: #6194

Phill310 avatar May 04 '24 23:05 Phill310

~~I think isZero is only available on Paper~~

No, it's just added very recently in spigot. 1.19.3+

sovdeeth avatar May 04 '24 23:05 sovdeeth

Oh shoot, i didnt even think about checking for that. Ill try to find a different method. Do you think it would be a bad idea to make my own isZero method that checks the x,y,z componenets? If thats the way to go would i just add it to each file where I use it or would i put it in some utils class

Phill310 avatar May 04 '24 23:05 Phill310

Oh shoot, i didnt even think about checking for that. Ill try to find a different method. Do you think it would be a bad idea to make my own isZero method that checks the x,y,z componenets? If thats the way to go would i just add it to each file where I use it or would i put it in some utils class

Sure, slap it in VectorMath

sovdeeth avatar May 05 '24 08:05 sovdeeth

~~Hm, it doesn't seem to be my new test failing and the branch seems to be up to date with dev/patch so I am not sure what the issue is here~~ Using the new error keyword in the assert statement seems to have been the issue. I guess it hasn't been added to dev/patch yet

Phill310 avatar May 09 '24 23:05 Phill310