diff options
Diffstat (limited to 'src/main/java/me')
-rw-r--r-- | src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java index be5cc58d..08a902ab 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/title/TitleContainerConfigScreen.java @@ -6,6 +6,7 @@ import me.xmrvizzy.skyblocker.utils.RenderUtils; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.util.math.Vector2f; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.Pair; @@ -20,8 +21,8 @@ public class TitleContainerConfigScreen extends Screen { private final Title example1 = new Title(Text.literal("Test1").formatted(Formatting.RED)); private final Title example2 = new Title(Text.literal("Test23").formatted(Formatting.AQUA)); private final Title example3 = new Title(Text.literal("Testing1234").formatted(Formatting.DARK_GREEN)); - private int hudX = SkyblockerConfig.get().general.titleContainer.x; - private int hudY = SkyblockerConfig.get().general.titleContainer.y; + private float hudX = SkyblockerConfig.get().general.titleContainer.x; + private float hudY = SkyblockerConfig.get().general.titleContainer.y; protected TitleContainerConfigScreen(Text title) { super(title); @@ -31,7 +32,7 @@ public class TitleContainerConfigScreen extends Screen { public void render(DrawContext context, int mouseX, int mouseY, float delta) { super.render(context, mouseX, mouseY, delta); renderBackground(context); - TitleContainer.render(context, Set.of(example1, example2, example3), hudX, hudY, delta); + TitleContainer.render(context, Set.of(example1, example2, example3), (int) hudX, (int) hudY, delta); SkyblockerConfig.Direction direction = SkyblockerConfig.get().general.titleContainer.direction; SkyblockerConfig.Alignment alignment = SkyblockerConfig.get().general.titleContainer.alignment; context.drawCenteredTextWithShadow(textRenderer, "Press Q/E to change Alignment: " + alignment, width / 2, textRenderer.fontHeight * 2, Color.WHITE.getRGB()); @@ -39,11 +40,11 @@ public class TitleContainerConfigScreen extends Screen { context.drawCenteredTextWithShadow(textRenderer, "Press +/- to change Scale", width / 2, textRenderer.fontHeight * 4 + 10, Color.WHITE.getRGB()); context.drawCenteredTextWithShadow(textRenderer, "Right Click To Reset Position", width / 2, textRenderer.fontHeight * 5 + 15, Color.GRAY.getRGB()); - Pair<Vector2i, Vector2i> boundingBox = getSelectionBoundingBox(); - int x1 = boundingBox.getLeft().x; - int y1 = boundingBox.getLeft().y; - int x2 = boundingBox.getRight().x; - int y2 = boundingBox.getRight().y; + Pair<Vector2f, Vector2f> boundingBox = getSelectionBoundingBox(); + int x1 = (int) boundingBox.getLeft().getX(); + int y1 = (int) boundingBox.getLeft().getY(); + int x2 = (int) boundingBox.getRight().getX(); + int y2 = (int) boundingBox.getRight().getY(); context.drawHorizontalLine(x1, x2, y1, Color.RED.getRGB()); context.drawHorizontalLine(x1, x2, y2, Color.RED.getRGB()); @@ -51,14 +52,14 @@ public class TitleContainerConfigScreen extends Screen { context.drawVerticalLine(x2, y1, y2, Color.RED.getRGB()); } - public Pair<Vector2i, Vector2i> getSelectionBoundingBox() { + public Pair<Vector2f, Vector2f> getSelectionBoundingBox() { SkyblockerConfig.Alignment alignment = SkyblockerConfig.get().general.titleContainer.alignment; - int midWidth = getSelectionWidth() / 2; - int x1 = 0; - int x2 = 0; - int y1 = hudY; - int y2 = hudY + getSelectionHeight(); + float midWidth = getSelectionWidth() / 2F; + float x1 = 0; + float x2 = 0; + float y1 = hudY; + float y2 = hudY + getSelectionHeight(); switch (alignment) { case RIGHT -> { x1 = hudX - midWidth * 2; @@ -73,18 +74,18 @@ public class TitleContainerConfigScreen extends Screen { x2 = hudX + midWidth * 2; } } - return new Pair<>(new Vector2i(x1, y1), new Vector2i(x2, y2)); + return new Pair<>(new Vector2f(x1, y1), new Vector2f(x2, y2)); } - public int getSelectionHeight() { - int scale = (int) (3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F)); + public float getSelectionHeight() { + float scale = (3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F)); return SkyblockerConfig.get().general.titleContainer.direction == SkyblockerConfig.Direction.HORIZONTAL ? - textRenderer.fontHeight * scale : - (textRenderer.fontHeight + 10) * 3 * scale; + (textRenderer.fontHeight * scale) : + (textRenderer.fontHeight + 10F) * 3F * scale; } - public int getSelectionWidth() { - int scale = (int) (3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F)); + public float getSelectionWidth() { + float scale = (3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F)); return SkyblockerConfig.get().general.titleContainer.direction == SkyblockerConfig.Direction.HORIZONTAL ? (textRenderer.getWidth("Test1") + 10 + textRenderer.getWidth("Test23") + 10 + textRenderer.getWidth("Testing1234")) * scale : textRenderer.getWidth("Testing1234") * scale; @@ -92,23 +93,23 @@ public class TitleContainerConfigScreen extends Screen { @Override public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { - int midWidth = getSelectionWidth() / 2; - int midHeight = getSelectionHeight() / 2; + float midWidth = getSelectionWidth() / 2; + float midHeight = getSelectionHeight() / 2; var alignment = SkyblockerConfig.get().general.titleContainer.alignment; - Pair<Vector2i, Vector2i> boundingBox = getSelectionBoundingBox(); - int x1 = boundingBox.getLeft().x; - int y1 = boundingBox.getLeft().y; - int x2 = boundingBox.getRight().x; - int y2 = boundingBox.getRight().y; + Pair<Vector2f, Vector2f> boundingBox = getSelectionBoundingBox(); + float x1 = boundingBox.getLeft().getX(); + float y1 = boundingBox.getLeft().getY(); + float x2 = boundingBox.getRight().getX(); + float y2 = boundingBox.getRight().getY(); - if (RenderUtils.pointExistsInArea((int) mouseX, (int) mouseY, x1, y1, x2, y2) && button == 0) { + if (RenderUtils.pointExistsInArea((int) mouseX, (int) mouseY, (int) x1, (int) y1, (int) x2, (int) y2) && button == 0) { hudX = switch (alignment) { case LEFT ->(int) mouseX - midWidth; case MIDDLE -> (int) mouseX; case RIGHT -> (int) mouseX + midWidth; }; - hudY = (int) mouseY - (midHeight); + hudY = (int) (mouseY - midHeight); } return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY); } @@ -158,8 +159,8 @@ public class TitleContainerConfigScreen extends Screen { @Override public void close() { - SkyblockerConfig.get().general.titleContainer.x = hudX; - SkyblockerConfig.get().general.titleContainer.y = hudY; + SkyblockerConfig.get().general.titleContainer.x = (int) hudX; + SkyblockerConfig.get().general.titleContainer.y = (int) hudY; AutoConfig.getConfigHolder(SkyblockerConfig.class).save(); super.close(); } |