Hotfix Nr. 2
This commit is contained in:
@@ -27,6 +27,7 @@ public class Config {
|
|||||||
public int coordsX = 1;
|
public int coordsX = 1;
|
||||||
public int coordsY = 1;
|
public int coordsY = 1;
|
||||||
public int coordsP = 4;
|
public int coordsP = 4;
|
||||||
|
public boolean biomeEnabled;
|
||||||
public boolean coordsEnabled = true;
|
public boolean coordsEnabled = true;
|
||||||
|
|
||||||
public boolean fullbrightEnabled = false;
|
public boolean fullbrightEnabled = false;
|
||||||
|
|||||||
@@ -8,8 +8,12 @@ import io.wispforest.owo.ui.core.*;
|
|||||||
import io.wispforest.owo.ui.hud.Hud;
|
import io.wispforest.owo.ui.hud.Hud;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.player.LocalPlayer;
|
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.network.chat.Component;
|
||||||
import net.minecraft.resources.Identifier;
|
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 net.minecraft.world.phys.Vec3;
|
||||||
import de.fullrisk.citrusDev.Config;
|
import de.fullrisk.citrusDev.Config;
|
||||||
|
|
||||||
@@ -18,12 +22,20 @@ public class Module_Coords {
|
|||||||
private static LabelComponent x;
|
private static LabelComponent x;
|
||||||
private static LabelComponent y;
|
private static LabelComponent y;
|
||||||
private static LabelComponent z;
|
private static LabelComponent z;
|
||||||
|
private static LabelComponent biome;
|
||||||
public static FlowLayout coordinates;
|
public static FlowLayout coordinates;
|
||||||
|
|
||||||
private static final Config CONFIG = Config.get();
|
private static final Config CONFIG = Config.get();
|
||||||
|
|
||||||
static boolean toggle = CONFIG.coordsEnabled;
|
static boolean toggle = CONFIG.coordsEnabled;
|
||||||
|
static boolean toggleBiome = CONFIG.biomeEnabled;
|
||||||
private static boolean shown = false;
|
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() {
|
public static boolean isEnabled() {
|
||||||
return toggle;
|
return toggle;
|
||||||
@@ -35,8 +47,19 @@ public class Module_Coords {
|
|||||||
CONFIG.save();
|
CONFIG.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Surface GLASS_PANEL = Surface.blur(5f, 15f)
|
// ---- biome toggle ----
|
||||||
.and(Surface.flat(0x40FFFFFF));
|
|
||||||
|
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) {
|
public static void setPosition(int x, int y) {
|
||||||
if (coordinates != null) {
|
if (coordinates != null) {
|
||||||
@@ -59,12 +82,15 @@ public class Module_Coords {
|
|||||||
return coordinates;
|
return coordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- HUD registration ----
|
||||||
|
|
||||||
public static void register() {
|
public static void register() {
|
||||||
Hud.add(Identifier.fromNamespaceAndPath("citrus-dev", "coords_display"), () -> {
|
Hud.add(Identifier.fromNamespaceAndPath("citrus-dev", "coords_display"), () -> {
|
||||||
if (coordinates == null) {
|
if (coordinates == null) {
|
||||||
x = UIComponents.label(Component.literal(""));
|
x = UIComponents.label(Component.literal(""));
|
||||||
y = UIComponents.label(Component.literal(""));
|
y = UIComponents.label(Component.literal(""));
|
||||||
z = UIComponents.label(Component.literal(""));
|
z = UIComponents.label(Component.literal(""));
|
||||||
|
biome = UIComponents.label(Component.literal(""));
|
||||||
|
|
||||||
coordinates = UIContainers.verticalFlow(Sizing.content(), Sizing.content());
|
coordinates = UIContainers.verticalFlow(Sizing.content(), Sizing.content());
|
||||||
coordinates.gap(2);
|
coordinates.gap(2);
|
||||||
@@ -78,6 +104,8 @@ public class Module_Coords {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- data getters ----
|
||||||
|
|
||||||
public static Vec3 getPlayerPosition() {
|
public static Vec3 getPlayerPosition() {
|
||||||
LocalPlayer player = Minecraft.getInstance().player;
|
LocalPlayer player = Minecraft.getInstance().player;
|
||||||
return player != null ? player.position() : null;
|
return player != null ? player.position() : null;
|
||||||
@@ -98,6 +126,27 @@ public class Module_Coords {
|
|||||||
return player != null ? player.getZ() : 0.0;
|
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() {
|
public static void tick() {
|
||||||
if (coordinates == null) return;
|
if (coordinates == null) return;
|
||||||
|
|
||||||
@@ -113,12 +162,25 @@ public class Module_Coords {
|
|||||||
coordinates.surface(Surface.flat(0));
|
coordinates.surface(Surface.flat(0));
|
||||||
coordinates.padding(Insets.of(0));
|
coordinates.padding(Insets.of(0));
|
||||||
shown = false;
|
shown = false;
|
||||||
|
biomeShown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!toggle) return;
|
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())));
|
x.text(Component.literal("X: " + String.format("%.1f", Module_Coords.getX())));
|
||||||
y.text(Component.literal("Y: " + String.format("%.1f", Module_Coords.getY())));
|
y.text(Component.literal("Y: " + String.format("%.1f", Module_Coords.getY())));
|
||||||
z.text(Component.literal("Z: " + String.format("%.1f", Module_Coords.getZ())));
|
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 de.fullrisk.citrusDev.client.PlaytimeTracker;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.Flow;
|
import java.util.concurrent.Flow;
|
||||||
|
|
||||||
import static de.fullrisk.citrusDev.UI.Module_FPS.fpsContainer;
|
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);
|
int currentIndex = positionIndex(Config.get().fpsX, Config.get().fpsY);
|
||||||
|
|
||||||
return List.of(
|
FlowLayout biomeCheckbox = SettingsControls.makeCheckbox(
|
||||||
new SettingRow("Position", SettingsControls.makeCyclingButton(GLASS_PANEL, positionStates, currentIndex))
|
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) {
|
private int positionIndex(int x, int y) {
|
||||||
|
|||||||
@@ -108,6 +108,41 @@ public class SettingsControls {
|
|||||||
return makeCyclingButton(baseSurface, states, 0);
|
return makeCyclingButton(baseSurface, states, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static FlowLayout makeCheckbox(Surface baseSurface, Surface checkedSurface, boolean initial, java.util.function.Consumer<Boolean> 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,
|
public static FlowLayout makeSlider(Surface baseSurface, int width, double min, double max, double initial,
|
||||||
DoubleFunction<String> labelFormatter, DoubleConsumer onChange) {
|
DoubleFunction<String> labelFormatter, DoubleConsumer onChange) {
|
||||||
int labelWidth = 34;
|
int labelWidth = 34;
|
||||||
|
|||||||
@@ -3,43 +3,43 @@
|
|||||||
{
|
{
|
||||||
"type": "bitmap",
|
"type": "bitmap",
|
||||||
"file": "citrus-dev:ranks/owner.png",
|
"file": "citrus-dev:ranks/owner.png",
|
||||||
"ascent": 7,
|
"ascent": 8,
|
||||||
"height": 8,
|
"height": 10,
|
||||||
"chars": ["\uE001"]
|
"chars": ["\uE001"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "bitmap",
|
"type": "bitmap",
|
||||||
"file": "citrus-dev:ranks/admin.png",
|
"file": "citrus-dev:ranks/admin.png",
|
||||||
"ascent": 7,
|
"ascent": 8,
|
||||||
"height": 8,
|
"height": 10,
|
||||||
"chars": ["\uE002"]
|
"chars": ["\uE002"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "bitmap",
|
"type": "bitmap",
|
||||||
"file": "citrus-dev:ranks/vip.png",
|
"file": "citrus-dev:ranks/vip.png",
|
||||||
"ascent": 7,
|
"ascent": 8,
|
||||||
"height": 8,
|
"height": 10,
|
||||||
"chars": ["\uE003"]
|
"chars": ["\uE003"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "bitmap",
|
"type": "bitmap",
|
||||||
"file": "citrus-dev:ranks/dev.png",
|
"file": "citrus-dev:ranks/dev.png",
|
||||||
"ascent": 7,
|
"ascent": 8,
|
||||||
"height": 8,
|
"height": 10,
|
||||||
"chars": ["\uE004"]
|
"chars": ["\uE004"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "bitmap",
|
"type": "bitmap",
|
||||||
"file": "citrus-dev:ranks/bughunter.png",
|
"file": "citrus-dev:ranks/bughunter.png",
|
||||||
"ascent": 7,
|
"ascent": 8,
|
||||||
"height": 8,
|
"height": 10,
|
||||||
"chars": ["\uE005"]
|
"chars": ["\uE005"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "bitmap",
|
"type": "bitmap",
|
||||||
"file": "citrus-dev:ranks/default.png",
|
"file": "citrus-dev:ranks/default.png",
|
||||||
"ascent": 7,
|
"ascent": 8,
|
||||||
"height": 8,
|
"height": 10,
|
||||||
"chars": ["\uE099"]
|
"chars": ["\uE099"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user