-
-
Notifications
You must be signed in to change notification settings - Fork 400
Facing Relative Vector Offset #7925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev/feature
Are you sure you want to change the base?
Facing Relative Vector Offset #7925
Conversation
src/main/java/ch/njol/skript/expressions/ExprLocationVectorOffset.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLocationVectorOffset.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLocationVectorOffset.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test perchance?
src/main/java/ch/njol/skript/expressions/ExprLocationVectorOffset.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLocationVectorOffset.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprLocationVectorOffset.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still needs tests
private static Location getFacingRelativeOffset(Location loc, Vector offset) { | ||
float yawRad = (float) Math.toRadians(-loc.getYaw()); | ||
float pitchRad = (float) Math.toRadians(loc.getPitch()); | ||
float rollRad = 0f; | ||
|
||
Quaternionf rotation = new Quaternionf().rotateYXZ(yawRad, pitchRad, rollRad); | ||
Vector3f localOffset = offset.toVector3f(); | ||
rotation.transform(localOffset); | ||
|
||
return loc.add(localOffset.x, localOffset.y, localOffset.z); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it'd make the code a bit nicer and standard if this returned a vector instead of a location, so the .add is done in the same spot as the normal add.
Problem
There isn't a shorthand way to offset a location while considering rotation.
Solution
Adds a new pattern to the existing offset syntax. This can be compared to ^^^ in vanilla commands (like
/summon tnt ^1 ^2 ^3
)before:
with this PR:
and this isn't even showing the work you would've done to achieve an X or Y offset at the same time
I was going to update the syntax description but not sure how I should explain this
Testing Completed
Only manual testing was done, comparing the syntax to the vanilla Minecraft command
Completes: none
Related: none