-
-
Notifications
You must be signed in to change notification settings - Fork 18
[Feature, Improvement]: Disable converging, prevent IllegalArgumentException #141
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1fa5c1c
Merge pull request #2 from APDevTeam/main
DerToaster98 91f3bda
if director range is less than 0, do not try convering
DerToaster98 db16481
implement clamp methods
DerToaster98 8017b91
clamp vectors
DerToaster98 88dd7e2
correct mathhelper
DerToaster98 98523e9
add single method for clamping vectors
DerToaster98 26c222a
fix stackoverflow exception
DerToaster98 f4fa334
use clampVector method
DerToaster98 825f711
do the same for arrow and cannons director
DerToaster98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/net/countercraft/movecraft/combat/utils/MathHelper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| package net.countercraft.movecraft.combat.utils; | ||
|
|
||
| import org.bukkit.Axis; | ||
| import org.bukkit.util.Vector; | ||
|
|
||
| public class MathHelper { | ||
|
|
||
| public static double clamp(double value) { | ||
| // Double.MIN_VALUE represents the lowest POSITIVE double value to match IEEE754 format | ||
| return clamp(-Double.MAX_VALUE, Double.MAX_VALUE, value); | ||
| } | ||
|
|
||
| // Same as with doubles! | ||
| public static float clamp(float value) { | ||
| return clamp(-Float.MAX_VALUE, Float.MAX_VALUE, value); | ||
| } | ||
|
|
||
| public static int clamp(int value) { | ||
| return clamp(Integer.MIN_VALUE, Integer.MAX_VALUE, value); | ||
| } | ||
|
|
||
| public static double clamp(double min, double max, double value) { | ||
| if (value > max) { | ||
| return max; | ||
| } | ||
| if (value < min) { | ||
| return min; | ||
| } | ||
| return value; | ||
| } | ||
|
|
||
| public static int clamp(int min, int max, int value) { | ||
| if (value > max) { | ||
| return max; | ||
| } | ||
| if (value < min) { | ||
| return min; | ||
| } | ||
| return value; | ||
| } | ||
|
|
||
| public static float clamp(float min, float max, float value) { | ||
| if (value > max) { | ||
| return max; | ||
| } | ||
| if (value < min) { | ||
| return min; | ||
| } | ||
| return value; | ||
| } | ||
TylerS1066 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public static void clampVectorModify(final Vector vector) { | ||
| vector.setX(clamp(vector.getX())); | ||
| vector.setY(clamp(vector.getY())); | ||
| vector.setZ(clamp(vector.getZ())); | ||
| } | ||
| public static Vector clampVector(final Vector vector) { | ||
| Vector result = vector.clone(); | ||
| clampVectorModify(result); | ||
| return result; | ||
| } | ||
|
|
||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.