Hotfix Nr. 2
This commit is contained in:
@@ -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<Biome> 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<Biome> 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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<FlowLayout> {
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user