Paper
                                
                                 Paper copied to clipboard
                                
                                    Paper copied to clipboard
                            
                            
                            
                        Allow using degrees for ArmorStand rotations
Introduces the new Rotations class that is used for storing rotations in degrees on each axis (X, Y, Z).
Currently, the patch adds usage for it for ArmorStand rotations, which makes manipulations easier and more precise (since it follows vanilla logic of using degrees instead of radians).
Example usage to set the right arm's rotation to 90 degrees on the X axis:
armorStand.setRightArmRotations(Rotations.ofDegrees(90, 0, 0));
Simple! Before you'd have to use EulerAngle with a workaround like Math.toRadians(90).
Feel free to give any feedback :)
Using the Vector class here doesn't really make sense
For me it just does the job of storing degrees for each axis 😅 Though I understand what you mean
Would you prefer a new class that would store 3 numbers? Possibly similar to EulerAngle, but for degrees? If so, any name/additional method suggestions?
Could just go with the Vanilla name of Rotations
Made a test version, open to suggestions.
Rotations could be a record in theory, but I'm not 100% on this.
Sure, making it a record would fit here
Should be ready now. Namings/javadocs can be tweaked if needed.
I’m curious what was the reasoning behind adding an entirely new type rather than just doing something like a new utility method? Because at least currently it doesn’t look immediately obvious what is the difference between these two classes… not to mention you now have to add getters and setters for each limb. Idk, just seems cluttered.
I’m curious what was the reasoning behind adding an entirely new type rather than just doing something like a new utility method? Because at least currently it doesn’t look immediately obvious what is the difference between these two classes… not to mention you now have to add getters and setters for each limb. Idk, just seems cluttered.
I'm not sure what you mean. What kind of utility method?
Currently, the only way to change ArmorStand's rotations is via EulerAngle class which uses radians. Newly added Rotations follows vanilla and works with degrees.
If you meant expanding EulerAngle then it'd require adding static fromDegrees() method with additional conversion methods for each axis as well as already present add/substruct (at least 9 in total) that would constantly rely on Math.toDegrees() and Math.toRadians(). I don't think this would be a better approach and I'd say would clutter EalerAngle instead.
Since we have plans on fixing the clusterfuck that are Location and Vector usage in Bukkit, use-specific classes that can also be used elsewhere are the way to go... tho also with that in mind, one last request: Please make Rotations an interface with a private inner record implementing it. Instead of the public constructor, you then use a static ofDegrees method on the interface. Please also move it from the /util package to /math
make
Rotationsan interface with a private inner record implementing it
I suppose you meant package-private implementation since it's not possible to have an inner private record inside the interface (classes are forced to be public static in there by default and records can't have a non-public constructor).
I tried to do it similarly to what adventure does. I'm open to any suggestions.
Might be a little late, but any reason why we use doubles instead of Floats? Minecraft uses floats for armor stand rotations.
Might be a little late, but any reason why we use doubles instead of Floats? Minecraft uses floats for armor stand rotations.
Just for ease of use. No need to specify that the value 45.5 is float 45.5F every time or cast (float) someValue wherever you have double in your code. In theory, Rotations can be used in other places too.