diff --git a/build.gradle.kts b/build.gradle.kts index 0946d02..ca9a740 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,7 +12,7 @@ plugins { } group = "dev.isxander" -version = "1.2.0" +version = "1.2.1" repositories { mavenCentral() diff --git a/changelogs/1.2.1.md b/changelogs/1.2.1.md new file mode 100644 index 0000000..fd53791 --- /dev/null +++ b/changelogs/1.2.1.md @@ -0,0 +1,2 @@ +- Fix some rendering crashes +- Prioritize YACL tooltip positioning above rather than below diff --git a/src/main/java/dev/isxander/adaptivetooltips/helpers/YACLTooltipPositioner.java b/src/main/java/dev/isxander/adaptivetooltips/helpers/YACLTooltipPositioner.java index 231f660..1e2af28 100644 --- a/src/main/java/dev/isxander/adaptivetooltips/helpers/YACLTooltipPositioner.java +++ b/src/main/java/dev/isxander/adaptivetooltips/helpers/YACLTooltipPositioner.java @@ -23,8 +23,8 @@ public Vector2ic getPosition(Screen screen, int x, int y, int width, int height) int maxBelow = screen.height - (belowY + height); int minAbove = aboveY - height; - int yResult = belowY; - if (maxBelow < -8) + int yResult = aboveY; + if (minAbove < 8) yResult = maxBelow > minAbove ? belowY : aboveY; int xResult = MathHelper.clamp(centerX - width / 2, -4, screen.width - width - 4); diff --git a/src/main/java/dev/isxander/adaptivetooltips/mixins/ScreenMixin.java b/src/main/java/dev/isxander/adaptivetooltips/mixins/ScreenMixin.java index 0fbfcb2..a99f5bf 100644 --- a/src/main/java/dev/isxander/adaptivetooltips/mixins/ScreenMixin.java +++ b/src/main/java/dev/isxander/adaptivetooltips/mixins/ScreenMixin.java @@ -86,6 +86,9 @@ private Stream wrapPositionedOrderedText(List operation, MatrixStack matrices, List components, int mouseX, int mouseY) { Vector2ic currentPosition = operation.call(clientTooltipPositioner, screen, x, y, width, height); + // push before returning so we don't need to repeat the check on pop + matrices.push(); // injection is before matrices.push() + if (!(clientTooltipPositioner instanceof HoveredTooltipPositioner) && AdaptiveTooltipConfig.INSTANCE.getConfig().onlyRepositionHoverTooltips) return currentPosition; @@ -99,7 +102,6 @@ private Vector2ic moveTooltip(TooltipPositioner clientTooltipPositioner, Screen currentPosition = position.get(); } - matrices.push(); // injection is before matrices.push() ScrollTracker.scroll(matrices, components, currentPosition.x(), currentPosition.y(), width, height, this.width, this.height); return currentPosition;