diff options
author | Walker Selby <git@walkerselby.com> | 2023-12-11 14:35:49 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-11 23:35:49 +0100 |
commit | c85c55e4c15715e7a4667cbacbdc5c953fdb3d7f (patch) | |
tree | 44a13bb011647020fb0ff51a3b8ea6f73324abfa /src/main/java/at | |
parent | 46411b35835df6a1f5a594c869940ba2fe1d8d28 (diff) | |
download | skyhanni-c85c55e4c15715e7a4667cbacbdc5c953fdb3d7f.tar.gz skyhanni-c85c55e4c15715e7a4667cbacbdc5c953fdb3d7f.tar.bz2 skyhanni-c85c55e4c15715e7a4667cbacbdc5c953fdb3d7f.zip |
Internal Change: Cleanup Position (#670)
Remove Duplicate Code #670
Diffstat (limited to 'src/main/java/at')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java b/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java index d8b2a7a99..670ea573c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java +++ b/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java @@ -115,27 +115,23 @@ public class Position { public int getAbsX0(int objWidth) { int width = new ScaledResolution(Minecraft.getMinecraft()).getScaledWidth(); - int ret = x; - if (x < 0) { - ret = width + x - objWidth; - } - - if (ret < 0) ret = 0; - if (ret > width - objWidth) ret = width - objWidth; - - return ret; + return calcAbs0(x, width, objWidth); } public int getAbsY0(int objHeight) { int height = new ScaledResolution(Minecraft.getMinecraft()).getScaledHeight(); - int ret = y; - if (y < 0) { - ret = height + y - objHeight; + return calcAbs0(y, height, objHeight); + } + + private int calcAbs0(int axis, int length, int objLength) { + int ret = axis; + if (axis < 0) { + ret = length + axis - objLength; } if (ret < 0) ret = 0; - if (ret > height - objHeight) ret = height - objHeight; + if (ret > length - objLength) ret = length - objLength; return ret; } |