From e2aa9b79e1717144f33db359a6654efe67497fef Mon Sep 17 00:00:00 2001 From: FullRisk Date: Sun, 12 Jul 2026 20:11:05 +0200 Subject: [PATCH] Hotfix Nr. 2 --- .../java/de/fullrisk/citrusDev/Config.java | 1 + .../fullrisk/citrusDev/UI/Module_Coords.java | 66 ++++++++++++++++++- .../de/fullrisk/citrusDev/UI/MyScreen.java | 15 ++++- .../citrusDev/UIHelper/SettingsControls.java | 35 ++++++++++ .../citrusDev/mixin/PlayerNametagMixin.java | 2 +- .../assets/citrus-dev/font/icon_font.json | 24 +++---- 6 files changed, 125 insertions(+), 18 deletions(-) diff --git a/src/main/java/de/fullrisk/citrusDev/Config.java b/src/main/java/de/fullrisk/citrusDev/Config.java index fe556f6..5d1945a 100644 --- a/src/main/java/de/fullrisk/citrusDev/Config.java +++ b/src/main/java/de/fullrisk/citrusDev/Config.java @@ -27,6 +27,7 @@ public class Config { public int coordsX = 1; public int coordsY = 1; public int coordsP = 4; + public boolean biomeEnabled; public boolean coordsEnabled = true; public boolean fullbrightEnabled = false; diff --git a/src/main/java/de/fullrisk/citrusDev/UI/Module_Coords.java b/src/main/java/de/fullrisk/citrusDev/UI/Module_Coords.java index 135687e..47ccece 100644 --- a/src/main/java/de/fullrisk/citrusDev/UI/Module_Coords.java +++ b/src/main/java/de/fullrisk/citrusDev/UI/Module_Coords.java @@ -8,8 +8,12 @@ import io.wispforest.owo.ui.core.*; import io.wispforest.owo.ui.hud.Hud; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; import net.minecraft.network.chat.Component; import net.minecraft.resources.Identifier; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.biome.Biome; import net.minecraft.world.phys.Vec3; import de.fullrisk.citrusDev.Config; @@ -18,12 +22,20 @@ public class Module_Coords { private static LabelComponent x; private static LabelComponent y; private static LabelComponent z; + private static LabelComponent biome; public static FlowLayout coordinates; private static final Config CONFIG = Config.get(); static boolean toggle = CONFIG.coordsEnabled; + static boolean toggleBiome = CONFIG.biomeEnabled; private static boolean shown = false; + private static boolean biomeShown = false; + + private static final Surface GLASS_PANEL = Surface.blur(5f, 15f) + .and(Surface.flat(0x40FFFFFF)); + + // ---- coords toggle ---- public static boolean isEnabled() { return toggle; @@ -35,8 +47,19 @@ public class Module_Coords { CONFIG.save(); } - private static final Surface GLASS_PANEL = Surface.blur(5f, 15f) - .and(Surface.flat(0x40FFFFFF)); + // ---- biome toggle ---- + + public static boolean isBiomeEnabled() { + return toggleBiome; + } + + public static void setBiomeEnabled(boolean value) { + toggleBiome = value; + CONFIG.biomeEnabled = value; + CONFIG.save(); + } + + // ---- positioning ---- public static void setPosition(int x, int y) { if (coordinates != null) { @@ -59,12 +82,15 @@ public class Module_Coords { return coordinates; } + // ---- HUD registration ---- + public static void register() { Hud.add(Identifier.fromNamespaceAndPath("citrus-dev", "coords_display"), () -> { if (coordinates == null) { x = UIComponents.label(Component.literal("")); y = UIComponents.label(Component.literal("")); z = UIComponents.label(Component.literal("")); + biome = UIComponents.label(Component.literal("")); coordinates = UIContainers.verticalFlow(Sizing.content(), Sizing.content()); coordinates.gap(2); @@ -78,6 +104,8 @@ public class Module_Coords { }); } + // ---- data getters ---- + public static Vec3 getPlayerPosition() { LocalPlayer player = Minecraft.getInstance().player; return player != null ? player.position() : null; @@ -98,6 +126,27 @@ public class Module_Coords { return player != null ? player.getZ() : 0.0; } + public static Holder getBiome() { + LocalPlayer player = Minecraft.getInstance().player; + if (player == null) return null; + + Level level = player.level(); + BlockPos pos = player.blockPosition(); + + return level.getBiome(pos); + } + + public static String getBiomeName() { + Holder biomeHolder = getBiome(); + if (biomeHolder == null) return "Unknown"; + + return biomeHolder.unwrapKey() + .map(key -> key.identifier().getPath()) + .orElse("Unknown"); + } + + // ---- tick ---- + public static void tick() { if (coordinates == null) return; @@ -113,12 +162,25 @@ public class Module_Coords { coordinates.surface(Surface.flat(0)); coordinates.padding(Insets.of(0)); shown = false; + biomeShown = false; } if (!toggle) return; + if (toggleBiome && !biomeShown) { + coordinates.child(biome); + biomeShown = true; + } else if (!toggleBiome && biomeShown) { + coordinates.removeChild(biome); + biomeShown = false; + } + x.text(Component.literal("X: " + String.format("%.1f", Module_Coords.getX()))); y.text(Component.literal("Y: " + String.format("%.1f", Module_Coords.getY()))); z.text(Component.literal("Z: " + String.format("%.1f", Module_Coords.getZ()))); + + if (toggleBiome) { + biome.text(Component.literal("Biome: " + Module_Coords.getBiomeName())); + } } } \ No newline at end of file diff --git a/src/main/java/de/fullrisk/citrusDev/UI/MyScreen.java b/src/main/java/de/fullrisk/citrusDev/UI/MyScreen.java index d8d230a..699a8ce 100644 --- a/src/main/java/de/fullrisk/citrusDev/UI/MyScreen.java +++ b/src/main/java/de/fullrisk/citrusDev/UI/MyScreen.java @@ -16,6 +16,7 @@ import net.minecraft.sounds.SoundEvents; import de.fullrisk.citrusDev.client.PlaytimeTracker; import java.util.List; +import java.util.Set; import java.util.concurrent.Flow; import static de.fullrisk.citrusDev.UI.Module_FPS.fpsContainer; @@ -540,10 +541,18 @@ public class MyScreen extends BaseOwoScreen { int currentIndex = positionIndex(Config.get().fpsX, Config.get().fpsY); - return List.of( - new SettingRow("Position", SettingsControls.makeCyclingButton(GLASS_PANEL, positionStates, currentIndex)) - + FlowLayout biomeCheckbox = SettingsControls.makeCheckbox( + FLAT, + GLASS_PANEL, + Module_Coords.isBiomeEnabled(), + Module_Coords::setBiomeEnabled ); + + return List.of( + new SettingRow("Position", SettingsControls.makeCyclingButton(GLASS_PANEL, positionStates, currentIndex)), + new SettingRow("Show Biome", biomeCheckbox) + ); + } private int positionIndex(int x, int y) { diff --git a/src/main/java/de/fullrisk/citrusDev/UIHelper/SettingsControls.java b/src/main/java/de/fullrisk/citrusDev/UIHelper/SettingsControls.java index 86f286c..fbcdbf3 100644 --- a/src/main/java/de/fullrisk/citrusDev/UIHelper/SettingsControls.java +++ b/src/main/java/de/fullrisk/citrusDev/UIHelper/SettingsControls.java @@ -108,6 +108,41 @@ public class SettingsControls { return makeCyclingButton(baseSurface, states, 0); } + public static FlowLayout makeCheckbox(Surface baseSurface, Surface checkedSurface, boolean initial, java.util.function.Consumer onChange) { + boolean[] checked = { initial }; + + FlowLayout box = UIContainers.verticalFlow(Sizing.fixed(16), Sizing.fixed(16)); + box.verticalAlignment(VerticalAlignment.CENTER); + box.horizontalAlignment(HorizontalAlignment.CENTER); + box.surface(checked[0] ? checkedSurface : baseSurface); + + var check = UIComponents.label(Component.literal(checked[0] ? "✓" : "")) + .color(Color.ofRgb(0xFFFFFF)) + .horizontalTextAlignment(HorizontalAlignment.CENTER) + .verticalTextAlignment(VerticalAlignment.CENTER); + box.child(check); + + box.mouseEnter().subscribe(() -> box.surface( + Surface.blur(5f, 15f).and(Surface.flat(0x70FFFFFF)).and(Surface.outline(0xFFFFFFFF)) + )); + box.mouseLeave().subscribe(() -> box.surface(checked[0] ? checkedSurface : baseSurface)); + + box.mouseDown().subscribe((click, doubled) -> { + Minecraft.getInstance().getSoundManager().play( + SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK.value(), 2.0F, 2) + ); + + checked[0] = !checked[0]; + check.text(Component.literal(checked[0] ? "✓" : "")); + box.surface(checked[0] ? checkedSurface : baseSurface); + onChange.accept(checked[0]); + + return true; + }); + + return box; + } + public static FlowLayout makeSlider(Surface baseSurface, int width, double min, double max, double initial, DoubleFunction labelFormatter, DoubleConsumer onChange) { int labelWidth = 34; diff --git a/src/main/java/de/fullrisk/citrusDev/mixin/PlayerNametagMixin.java b/src/main/java/de/fullrisk/citrusDev/mixin/PlayerNametagMixin.java index af4e725..dccd68a 100644 --- a/src/main/java/de/fullrisk/citrusDev/mixin/PlayerNametagMixin.java +++ b/src/main/java/de/fullrisk/citrusDev/mixin/PlayerNametagMixin.java @@ -31,7 +31,7 @@ public abstract class PlayerNametagMixin { new FontDescription.Resource(Identifier.fromNamespaceAndPath("citrus-dev", "icon_font")) )); - MutableComponent nameWithSpace = Component.literal(" ") + MutableComponent nameWithSpace = Component.literal("") .append(original) .setStyle(Style.EMPTY.withFont(new FontDescription.Resource(Identifier.fromNamespaceAndPath("minecraft", "default")))); diff --git a/src/main/resources/assets/citrus-dev/font/icon_font.json b/src/main/resources/assets/citrus-dev/font/icon_font.json index 2c456d0..ca286bf 100644 --- a/src/main/resources/assets/citrus-dev/font/icon_font.json +++ b/src/main/resources/assets/citrus-dev/font/icon_font.json @@ -3,43 +3,43 @@ { "type": "bitmap", "file": "citrus-dev:ranks/owner.png", - "ascent": 7, - "height": 8, + "ascent": 8, + "height": 10, "chars": ["\uE001"] }, { "type": "bitmap", "file": "citrus-dev:ranks/admin.png", - "ascent": 7, - "height": 8, + "ascent": 8, + "height": 10, "chars": ["\uE002"] }, { "type": "bitmap", "file": "citrus-dev:ranks/vip.png", - "ascent": 7, - "height": 8, + "ascent": 8, + "height": 10, "chars": ["\uE003"] }, { "type": "bitmap", "file": "citrus-dev:ranks/dev.png", - "ascent": 7, - "height": 8, + "ascent": 8, + "height": 10, "chars": ["\uE004"] }, { "type": "bitmap", "file": "citrus-dev:ranks/bughunter.png", - "ascent": 7, - "height": 8, + "ascent": 8, + "height": 10, "chars": ["\uE005"] }, { "type": "bitmap", "file": "citrus-dev:ranks/default.png", - "ascent": 7, - "height": 8, + "ascent": 8, + "height": 10, "chars": ["\uE099"] } ]