mirror of
https://github.com/CCBlueX/LiquidBounce.git
synced 2025-09-06 09:46:38 +00:00
chore(HUD): default layout (#5758)
- Disables Minimap by default - Always center scoreboard - for small screen compatibility - Functional Text Component (Ping, Position, Nether Position)
This commit is contained in:
@@ -189,11 +189,11 @@
|
||||
},
|
||||
{
|
||||
"name": "Vertical",
|
||||
"value": "Top"
|
||||
"value": "CenterTranslated"
|
||||
},
|
||||
{
|
||||
"name": "VerticalOffset",
|
||||
"value": 550
|
||||
"value": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -294,7 +294,7 @@
|
||||
"value": [
|
||||
{
|
||||
"name": "Enabled",
|
||||
"value": true
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"name": "Alignment",
|
||||
|
@@ -1,9 +1,9 @@
|
||||
<script lang="ts">
|
||||
import { listen } from "../../../integration/ws";
|
||||
import type { ClientPlayerDataEvent } from "../../../integration/events";
|
||||
import type { PlayerData } from "../../../integration/types";
|
||||
import { rgbaToHex } from "../../../integration/util";
|
||||
import { intToRgba } from "../../../integration/util.js";
|
||||
import {listen} from "../../../integration/ws";
|
||||
import type {ClientPlayerDataEvent} from "../../../integration/events";
|
||||
import type {PlayerData} from "../../../integration/types";
|
||||
import {rgbaToHex} from "../../../integration/util";
|
||||
import {intToRgba} from "../../../integration/util.js";
|
||||
|
||||
let playerData: PlayerData | null = null;
|
||||
let processedText: string = '';
|
||||
@@ -25,24 +25,25 @@
|
||||
const keys = p1.split(".");
|
||||
let value: any = playerData;
|
||||
|
||||
// Traverse playerData to get the correct value
|
||||
for (const key of keys) {
|
||||
value = value ? value[key] : null;
|
||||
}
|
||||
|
||||
// Format the value based on type
|
||||
if (value !== null && value !== undefined) {
|
||||
switch (typeof value) {
|
||||
case 'number': // Round numbers to two decimal places
|
||||
case 'number':
|
||||
if (value % 1 === 0) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
return value.toFixed(2);
|
||||
case 'object': // Convert objects to JSON strings
|
||||
case 'object':
|
||||
return JSON.stringify(value);
|
||||
default:
|
||||
return value.toString();
|
||||
}
|
||||
}
|
||||
|
||||
// Return original tag if value is null or undefined
|
||||
return match;
|
||||
});
|
||||
}
|
||||
|
@@ -131,7 +131,6 @@ object LiquidBounce : EventListener {
|
||||
if (isInitialized) {
|
||||
return
|
||||
}
|
||||
isInitialized = true
|
||||
|
||||
// Ensure we are on the render thread
|
||||
RenderSystem.assertOnRenderThread()
|
||||
@@ -154,6 +153,8 @@ object LiquidBounce : EventListener {
|
||||
|
||||
// Load all configurations
|
||||
ConfigSystem.loadAll()
|
||||
|
||||
isInitialized = true
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -29,6 +29,8 @@ import net.ccbluex.liquidbounce.utils.client.interaction
|
||||
import net.ccbluex.liquidbounce.utils.client.mc
|
||||
import net.ccbluex.liquidbounce.utils.client.player
|
||||
import net.ccbluex.liquidbounce.utils.entity.getActualHealth
|
||||
import net.ccbluex.liquidbounce.utils.entity.netherPosition
|
||||
import net.ccbluex.liquidbounce.utils.entity.ping
|
||||
import net.ccbluex.netty.http.model.RequestObject
|
||||
import net.ccbluex.netty.http.util.httpOk
|
||||
import net.minecraft.entity.effect.StatusEffectInstance
|
||||
@@ -41,6 +43,7 @@ import net.minecraft.scoreboard.Team
|
||||
import net.minecraft.scoreboard.number.NumberFormat
|
||||
import net.minecraft.scoreboard.number.StyledNumberFormat
|
||||
import net.minecraft.text.Text
|
||||
import net.minecraft.util.Identifier
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.util.math.Vec3d
|
||||
import net.minecraft.world.GameMode
|
||||
@@ -62,7 +65,9 @@ fun getCrosshairData(requestObject: RequestObject) = httpOk(interopGson.toJsonTr
|
||||
data class PlayerData(
|
||||
val username: String,
|
||||
val uuid: String,
|
||||
val dimension: Identifier,
|
||||
val position: Vec3d,
|
||||
val netherPosition: Vec3d,
|
||||
val blockPosition: BlockPos,
|
||||
val velocity: Vec3d,
|
||||
val selectedSlot: Int,
|
||||
@@ -77,6 +82,7 @@ data class PlayerData(
|
||||
val maxAir: Int,
|
||||
val experienceLevel: Int,
|
||||
val experienceProgress: Float,
|
||||
val ping: Int,
|
||||
val effects: List<StatusEffectInstance>,
|
||||
val mainHandStack: ItemStack,
|
||||
val offHandStack: ItemStack,
|
||||
@@ -89,7 +95,9 @@ data class PlayerData(
|
||||
fun fromPlayer(player: PlayerEntity) = PlayerData(
|
||||
player.nameForScoreboard,
|
||||
player.uuidAsString,
|
||||
player.world.registryKey.value,
|
||||
player.pos,
|
||||
player.netherPosition,
|
||||
player.blockPos,
|
||||
player.velocity,
|
||||
player.inventory.selectedSlot,
|
||||
@@ -104,6 +112,7 @@ data class PlayerData(
|
||||
player.maxAir,
|
||||
player.experienceLevel,
|
||||
player.experienceProgress.fixNaN(),
|
||||
player.ping,
|
||||
player.statusEffects.toList(),
|
||||
player.mainHandStack,
|
||||
if (shouldHideOffhand(player = player) && hideShieldSlot) ItemStack.EMPTY else player.offHandStack,
|
||||
|
@@ -28,15 +28,13 @@ import net.ccbluex.liquidbounce.utils.render.Alignment
|
||||
/**
|
||||
* Represents a HUD component
|
||||
*/
|
||||
abstract class Component(name: String, enabled: Boolean)
|
||||
: ToggleableConfigurable(parent = ComponentOverlay, name = name, enabled = enabled) {
|
||||
abstract class Component(
|
||||
name: String,
|
||||
enabled: Boolean,
|
||||
alignment: Alignment = Alignment.center()
|
||||
) : ToggleableConfigurable(parent = ComponentOverlay, name = name, enabled = enabled) {
|
||||
|
||||
val alignment = tree(Alignment(
|
||||
Alignment.ScreenAxisX.CENTER,
|
||||
0,
|
||||
Alignment.ScreenAxisY.CENTER,
|
||||
0
|
||||
))
|
||||
val alignment = tree(alignment)
|
||||
|
||||
protected fun registerComponentListen(cfg: Configurable = this) {
|
||||
for (v in cfg.inner) {
|
||||
|
@@ -30,10 +30,18 @@ import net.ccbluex.liquidbounce.integration.theme.ThemeManager
|
||||
import net.ccbluex.liquidbounce.integration.theme.component.types.IntegratedComponent
|
||||
import net.ccbluex.liquidbounce.integration.theme.component.types.TextComponent
|
||||
import net.ccbluex.liquidbounce.utils.client.logger
|
||||
import net.ccbluex.liquidbounce.utils.render.Alignment
|
||||
import net.ccbluex.liquidbounce.utils.render.Alignment.ScreenAxisX
|
||||
import net.ccbluex.liquidbounce.utils.render.Alignment.ScreenAxisY
|
||||
|
||||
val components: MutableList<Component> = mutableListOf()
|
||||
val customComponents: MutableList<Component> = mutableListOf(
|
||||
TextComponent("hello! :)", enabled = false)
|
||||
TextComponent(
|
||||
"Ping: {ping}, XYZ {position.x}, {position.y}, {position.z} |" +
|
||||
" Nether XZ: {netherPosition.x}, {netherPosition.z}",
|
||||
enabled = false,
|
||||
alignment = Alignment(ScreenAxisX.LEFT, 4, ScreenAxisY.BOTTOM, 22)
|
||||
)
|
||||
)
|
||||
|
||||
object ComponentOverlay : EventListener {
|
||||
|
@@ -26,12 +26,17 @@ import net.ccbluex.liquidbounce.config.types.NamedChoice
|
||||
import net.ccbluex.liquidbounce.config.types.ToggleableConfigurable
|
||||
import net.ccbluex.liquidbounce.integration.theme.component.Component
|
||||
import net.ccbluex.liquidbounce.render.engine.Color4b
|
||||
import net.ccbluex.liquidbounce.utils.render.Alignment
|
||||
|
||||
/**
|
||||
* A text component
|
||||
*/
|
||||
@Suppress("unused")
|
||||
class TextComponent(text: String, enabled: Boolean = true) : Component("Text", enabled) {
|
||||
class TextComponent(
|
||||
text: String,
|
||||
enabled: Boolean = true,
|
||||
alignment: Alignment = Alignment.center()
|
||||
) : Component("Text", enabled, alignment) {
|
||||
|
||||
private val text by text("Text", text)
|
||||
private val color by color("Color", Color4b.WHITE)
|
||||
|
@@ -61,6 +61,7 @@ import net.minecraft.util.math.*
|
||||
import net.minecraft.util.shape.VoxelShapes
|
||||
import net.minecraft.world.Difficulty
|
||||
import net.minecraft.world.RaycastContext
|
||||
import net.minecraft.world.World
|
||||
import net.minecraft.world.explosion.ExplosionBehavior
|
||||
import net.minecraft.world.explosion.ExplosionImpl
|
||||
import kotlin.math.cos
|
||||
@@ -68,6 +69,12 @@ import kotlin.math.floor
|
||||
import kotlin.math.sin
|
||||
import kotlin.math.sqrt
|
||||
|
||||
val Entity.netherPosition: Vec3d
|
||||
get() = if (world.registryKey == World.NETHER) {
|
||||
Vec3d(x, y, z)
|
||||
} else {
|
||||
Vec3d(x / 8.0, y, z / 8.0)
|
||||
}
|
||||
|
||||
val ClientPlayerEntity.moving
|
||||
get() = input.movementForward != 0.0f || input.movementSideways != 0.0f
|
||||
|
@@ -30,6 +30,10 @@ class Alignment(
|
||||
verticalOffset: Int,
|
||||
) : Configurable("Alignment") {
|
||||
|
||||
companion object {
|
||||
fun center() = Alignment(ScreenAxisX.CENTER, 0, ScreenAxisY.CENTER, 0)
|
||||
}
|
||||
|
||||
val horizontalAlignment by enumChoice("Horizontal", horizontalAlignment)
|
||||
val horizontalOffset by int("HorizontalOffset", horizontalOffset, -1000..1000)
|
||||
val verticalAlignment by enumChoice("Vertical", verticalAlignment)
|
||||
|
Reference in New Issue
Block a user