From d04444c9ef9cb49b561eebf948be692049dd475a Mon Sep 17 00:00:00 2001 From: GeorgeRNG Date: Thu, 2 Nov 2023 14:00:05 +0000 Subject: [PATCH] customizable popup position --- .../dfonline/codeclient/config/Config.java | 24 +++++++++++++++++++ .../mixin/render/hud/MInGameHud.java | 5 ++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/dfonline/codeclient/config/Config.java b/src/main/java/dev/dfonline/codeclient/config/Config.java index 1e7d6758..081940a6 100644 --- a/src/main/java/dev/dfonline/codeclient/config/Config.java +++ b/src/main/java/dev/dfonline/codeclient/config/Config.java @@ -43,6 +43,8 @@ public class Config { public boolean UseIForLineScope = false; public boolean CustomBlockBreaking = false; public boolean ChestPeeker = true; + public int ChestPeekerX = 0; + public int ChestPeekerY = -4; private void save() { try { @@ -73,6 +75,8 @@ private void save() { object.addProperty("UseIForLineScope",UseIForLineScope); object.addProperty("CustomBlockBreaking",CustomBlockBreaking); object.addProperty("ChestPeeker",ChestPeeker); + object.addProperty("ChestPeekerX",ChestPeekerX); + object.addProperty("ChestPeekerY",ChestPeekerY); FileManager.writeConfig(object.toString()); } catch (Exception e) { CodeClient.LOGGER.info("Couldn't save config: " + e); @@ -389,6 +393,26 @@ public YetAnotherConfigLib getLibConfig() { ) .controller(TickBoxControllerBuilder::create) .build()) + .option(Option.createBuilder(int.class) + .name(Text.literal("Preview X Offset")) + .description(OptionDescription.of(Text.literal("How far horizontally the preview popup is"))) + .binding( + 0, + () -> ChestPeekerX, + opt -> ChestPeekerX = opt + ) + .controller(integerOption -> IntegerFieldControllerBuilder.create(integerOption).range(-500,500)) + .build()) + .option(Option.createBuilder(int.class) + .name(Text.literal("Preview Y Offset")) + .description(OptionDescription.of(Text.literal("How far vertically the preview popup is"))) + .binding( + -4, + () -> ChestPeekerY, + opt -> ChestPeekerY = opt + ) + .controller(integerOption -> IntegerFieldControllerBuilder.create(integerOption).range(-500,500)) + .build()) .build()) .category(ConfigCategory.createBuilder() .name(Text.literal("AutoJoin")) diff --git a/src/main/java/dev/dfonline/codeclient/mixin/render/hud/MInGameHud.java b/src/main/java/dev/dfonline/codeclient/mixin/render/hud/MInGameHud.java index 128879cc..74e11e1d 100644 --- a/src/main/java/dev/dfonline/codeclient/mixin/render/hud/MInGameHud.java +++ b/src/main/java/dev/dfonline/codeclient/mixin/render/hud/MInGameHud.java @@ -1,6 +1,7 @@ package dev.dfonline.codeclient.mixin.render.hud; import dev.dfonline.codeclient.OverlayManager; +import dev.dfonline.codeclient.config.Config; import dev.dfonline.codeclient.dev.ChestPeeker; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; @@ -36,8 +37,8 @@ private void onRender(DrawContext context, float tickDelta, CallbackInfo ci) { } List peeker = ChestPeeker.getOverlayText(); if(peeker != null && !peeker.isEmpty()) { - int x = (scaledWidth / 2); - int yOrig = (scaledHeight / 2) - 4; + int x = (scaledWidth / 2) + Config.getConfig().ChestPeekerX; + int yOrig = (scaledHeight / 2) + Config.getConfig().ChestPeekerY; context.drawTooltip(textRenderer,peeker,x,yOrig); }