diff --git a/src-theme/public/metadata.json b/src-theme/public/metadata.json index c92a0e1ec28..a6db49331e2 100644 --- a/src-theme/public/metadata.json +++ b/src-theme/public/metadata.json @@ -264,6 +264,36 @@ } ] }, + { + "name": "BlockCounter", + "value": [ + { + "name": "Enabled", + "value": true + }, + { + "name": "Alignment", + "value": [ + { + "name": "Horizontal", + "value": "Center" + }, + { + "name": "HorizontalOffset", + "value": -20 + }, + { + "name": "Vertical", + "value": "CenterTranslated" + }, + { + "name": "VerticalOffset", + "value": 0 + } + ] + } + ] + }, { "name": "Effects", "value": [ diff --git a/src-theme/src/colors.scss b/src-theme/src/colors.scss index 7b71182f9ae..069d20015a0 100644 --- a/src-theme/src/colors.scss +++ b/src-theme/src/colors.scss @@ -16,6 +16,8 @@ $targethud-base-color: black; $targethud-text-color: white; $targethud-text-dimmed-color: rgba(211, 211, 211, 255); +$blockcounter-base-color: black; + $hotbar-base-color: black; $hotbar-text-color: white; /* TODO: currently unused */ diff --git a/src-theme/src/integration/events.ts b/src-theme/src/integration/events.ts index b0f88c9b90e..8f25eae03fb 100644 --- a/src-theme/src/integration/events.ts +++ b/src-theme/src/integration/events.ts @@ -49,6 +49,10 @@ export interface TargetChangeEvent { target: PlayerData | null; } +export interface BlockCountChangeEvent { + count: number | null; +} + export interface AccountManagerAdditionEvent { username: string | null; error: string | null; diff --git a/src-theme/src/routes/hud/Hud.svelte b/src-theme/src/routes/hud/Hud.svelte index 60f58fd0d67..33d68d0ee07 100644 --- a/src-theme/src/routes/hud/Hud.svelte +++ b/src-theme/src/routes/hud/Hud.svelte @@ -14,6 +14,7 @@ import type {ComponentsUpdateEvent, ScaleFactorChangeEvent} from "../../integration/events"; import Keystrokes from "./elements/keystrokes/Keystrokes.svelte"; import Effects from "./elements/Effects.svelte"; + import BlockCounter from "./elements/BlockCounter.svelte"; let zoom = 100; let components: Component[] = []; @@ -48,6 +49,8 @@ {:else if c.name === "TargetHud"} + {:else if c.name === "BlockCounter"} + {:else if c.name === "Hotbar"} {:else if c.name === "Scoreboard"} diff --git a/src-theme/src/routes/hud/elements/BlockCounter.svelte b/src-theme/src/routes/hud/elements/BlockCounter.svelte new file mode 100644 index 00000000000..60c76f81d48 --- /dev/null +++ b/src-theme/src/routes/hud/elements/BlockCounter.svelte @@ -0,0 +1,43 @@ + + +{#if count !== null} +
+ {count} +
+{/if} + + diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/event/EventManager.kt b/src/main/kotlin/net/ccbluex/liquidbounce/event/EventManager.kt index 942d0cbb3b1..86197ffa4ac 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/event/EventManager.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/event/EventManager.kt @@ -107,6 +107,7 @@ val ALL_EVENT_CLASSES: Array> = arrayOf( ServerConnectEvent::class, ServerPingedEvent::class, TargetChangeEvent::class, + BlockCountChangeEvent::class, GameModeChangeEvent::class, ComponentsUpdate::class, ResourceReloadEvent::class, diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/event/events/ClientEvents.kt b/src/main/kotlin/net/ccbluex/liquidbounce/event/events/ClientEvents.kt index 612208ffc30..fbda5652789 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/event/events/ClientEvents.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/event/events/ClientEvents.kt @@ -78,6 +78,10 @@ class GameModeChangeEvent(val gameMode: GameMode) : Event() @WebSocketEvent class TargetChangeEvent(val target: PlayerData?) : Event() +@Nameable("blockCountChange") +@WebSocketEvent +class BlockCountChangeEvent(val count: Int?): Event() + @Nameable("clientChatStateChange") @WebSocketEvent class ClientChatStateChange(val state: State) : Event() { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleBedPlates.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleBedPlates.kt index 14e7facbc0e..452c0fe6842 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleBedPlates.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleBedPlates.kt @@ -72,8 +72,6 @@ object ModuleBedPlates : Module("BedPlates", Category.RENDER) { distSq } - val env = this - trackedBlockMap.forEachIndexed { idx, (_, trackState) -> val bedPlates = trackState.bedPlates with(matrixStack) { @@ -81,7 +79,7 @@ object ModuleBedPlates : Module("BedPlates", Category.RENDER) { try { val z = idx.toFloat() / trackedBlockMap.size.toFloat() - renderBedPlates(env, trackState, fontBuffers, bedPlates, z * 1000.0F) + renderBedPlates(trackState, fontBuffers, bedPlates, z * 1000.0F) } finally { pop() } @@ -94,8 +92,7 @@ object ModuleBedPlates : Module("BedPlates", Category.RENDER) { } } - private fun renderBedPlates( - env: GUIRenderEnvironment, + private fun GUIRenderEnvironment.renderBedPlates( trackState: TrackedState, fontBuffers: FontRendererBuffers, bedPlates: Set, @@ -141,15 +138,15 @@ object ModuleBedPlates : Module("BedPlates", Category.RENDER) { 0.0f ) - env.matrixStack.push() + matrixStack.push() - env.matrixStack.translate(screenPos.x, screenPos.y, z) - env.matrixStack.translate(0.0f, -height + fontRenderer.height * scale - 6.0F, 0.0f) - env.matrixStack.scale(scale, scale, 1.0F) + matrixStack.translate(screenPos.x, screenPos.y, z) + matrixStack.translate(0.0f, -height + fontRenderer.height * scale - 6.0F, 0.0f) + matrixStack.scale(scale, scale, 1.0F) - fontRenderer.commit(env, fontBuffers) + fontRenderer.commit(fontBuffers) - env.matrixStack.pop() + matrixStack.pop() // draw items val itemStartX = width / 2 - (bedPlates.size + 1) * ITEM_SIZE / 2 diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleItemTags.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleItemTags.kt index 4d76d2ea834..6c181bf35c9 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleItemTags.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleItemTags.kt @@ -155,7 +155,7 @@ object ModuleItemTags : Module("ItemTags", Category.RENDER) { } } - fontRenderer.commit(this, fontBuffers) + fontRenderer.commit(fontBuffers) matrixStack.pop() } diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/nametags/NametagRenderer.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/nametags/NametagRenderer.kt index 4dc169adfb2..e2e93173231 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/nametags/NametagRenderer.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/nametags/NametagRenderer.kt @@ -53,14 +53,14 @@ class NametagRenderer { env: RenderEnvironment, info: NametagInfo, pos: Vec3, - ) { + ) = with(env) { val c = Fonts.DEFAULT_FONT_SIZE.toFloat() val scale = 1.0F / (c * 0.15F) * ModuleNametags.scale - env.matrixStack.push() - env.matrixStack.translate(pos.x, pos.y, pos.z) - env.matrixStack.scale(scale, scale, 1.0F) + matrixStack.push() + matrixStack.translate(pos.x, pos.y, pos.z) + matrixStack.scale(scale, scale, 1.0F) val x = ModuleNametags.fontRenderer.draw( @@ -72,7 +72,7 @@ class NametagRenderer { ) // Make the model view matrix center the text when rendering - env.matrixStack.translate(-x * 0.5F, -ModuleNametags.fontRenderer.height * 0.5F, 0.00F) + matrixStack.translate(-x * 0.5F, -ModuleNametags.fontRenderer.height * 0.5F, 0.00F) ModuleNametags.fontRenderer.commit(env, fontBuffers) @@ -89,7 +89,7 @@ class NametagRenderer { drawItemList(pos, info.items) } - env.matrixStack.pop() + matrixStack.pop() } private fun drawItemList( diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/ModuleScaffold.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/ModuleScaffold.kt index 48827480515..fa0604d3956 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/ModuleScaffold.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/scaffold/ModuleScaffold.kt @@ -22,7 +22,8 @@ import net.ccbluex.liquidbounce.config.Choice import net.ccbluex.liquidbounce.config.NamedChoice import net.ccbluex.liquidbounce.config.NoneChoice import net.ccbluex.liquidbounce.config.ToggleableConfigurable -import net.ccbluex.liquidbounce.event.events.GameTickEvent +import net.ccbluex.liquidbounce.event.EventManager +import net.ccbluex.liquidbounce.event.events.BlockCountChangeEvent import net.ccbluex.liquidbounce.event.events.MovementInputEvent import net.ccbluex.liquidbounce.event.events.SimulatedTickEvent import net.ccbluex.liquidbounce.event.handler @@ -233,7 +234,8 @@ object ModuleScaffold : Module("Scaffold", Category.WORLD) { // In this case we expand the bounding box by 0.5 in all directions and check if there is a collision // This might cause for "Spider-like" behavior, but it's the most reliable way to check // and usually the scaffold should start placing blocks - return world.getBlockCollisions(player, + return world.getBlockCollisions( + player, player.boundingBox.expand(0.5, 0.0, 0.5).offset(0.0, -1.05, 0.0) ).any { shape -> shape != VoxelShapes.empty() } } @@ -279,8 +281,11 @@ object ModuleScaffold : Module("Scaffold", Category.WORLD) { NoFallBlink.waitUntilGround = false ScaffoldMovementPlanner.reset() SilentHotbar.resetSlot(this) + updateRenderCount() } + private fun updateRenderCount(count: Int? = null) = EventManager.callEvent(BlockCountChangeEvent(count)) + @Suppress("unused") val rotationUpdateHandler = handler { NoFallBlink.waitUntilGround = true @@ -402,13 +407,15 @@ object ModuleScaffold : Module("Scaffold", Category.WORLD) { @Suppress("unused") val tickHandler = repeatable { + updateRenderCount(blockCount) + if (player.isOnGround) { // Placement Y is the Y coordinate of the block below the player placementY = player.blockPos.y - 1 jumps++ } - if(mc.options.jumpKey.isPressed) { + if (mc.options.jumpKey.isPressed) { startY = player.blockPos.y jumps = 2 } @@ -449,7 +456,8 @@ object ModuleScaffold : Module("Scaffold", Category.WORLD) { // Does the crosshair target meet the requirements? if (!target.doesCrosshairTargetFullFillRequirements(currentCrosshairTarget) || - !isValidCrosshairTarget(currentCrosshairTarget)) { + !isValidCrosshairTarget(currentCrosshairTarget) + ) { return@repeatable } @@ -559,7 +567,8 @@ object ModuleScaffold : Module("Scaffold", Category.WORLD) { if (!isTowering) { sameYMode.getTargetedBlockPos(blockPos)?.let { return it } } else if (towerMode.activeChoice == ScaffoldTowerMotion && - ScaffoldTowerMotion.placeOffOnNoInput && !player.moving) { + ScaffoldTowerMotion.placeOffOnNoInput && !player.moving + ) { // Find the block closest to the player val blocks = arrayOf( blockPos.add(0, 0, 1), @@ -632,8 +641,10 @@ object ModuleScaffold : Module("Scaffold", Category.WORLD) { val bestMainHandSlot = findBestValidHotbarSlotForTarget() if (bestMainHandSlot != null) { - SilentHotbar.selectSlotSilently(this, bestMainHandSlot, - ScaffoldAutoBlockFeature.slotResetDelay) + SilentHotbar.selectSlotSilently( + this, bestMainHandSlot, + ScaffoldAutoBlockFeature.slotResetDelay + ) return true } else { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/render/RenderShortcuts.kt b/src/main/kotlin/net/ccbluex/liquidbounce/render/RenderShortcuts.kt index e70b68e264a..bf92ca20aee 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/render/RenderShortcuts.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/render/RenderShortcuts.kt @@ -24,6 +24,8 @@ import com.mojang.blaze3d.platform.GlStateManager import com.mojang.blaze3d.systems.RenderSystem import net.ccbluex.liquidbounce.render.engine.Color4b import net.ccbluex.liquidbounce.render.engine.Vec3 +import net.ccbluex.liquidbounce.render.engine.font.FontRenderer +import net.ccbluex.liquidbounce.render.engine.font.FontRendererBuffers import net.ccbluex.liquidbounce.utils.client.mc import net.minecraft.client.gl.ShaderProgram import net.minecraft.client.render.* @@ -58,6 +60,8 @@ class GUIRenderEnvironment(matrixStack: MatrixStack) : RenderEnvironment(matrixS override fun relativeToCamera(pos: Vec3d): Vec3d { return pos } + + fun FontRenderer.commit(buffer: FontRendererBuffers) = commit(this@GUIRenderEnvironment, buffer) } class WorldRenderEnvironment(matrixStack: MatrixStack, val camera: Camera) : RenderEnvironment(matrixStack) { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/web/socket/ClientSocket.kt b/src/main/kotlin/net/ccbluex/liquidbounce/web/socket/ClientSocket.kt index fd2318db2c4..a2e481596e4 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/web/socket/ClientSocket.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/web/socket/ClientSocket.kt @@ -63,6 +63,7 @@ object ClientSocket { "serverConnect", "serverPinged", "targetChange", + "blockCountChange", "gameModeChange", "componentsUpdate", "proxyAdditionResult", diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/web/theme/component/ComponentOverlay.kt b/src/main/kotlin/net/ccbluex/liquidbounce/web/theme/component/ComponentOverlay.kt index 5b567db0641..13673641890 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/web/theme/component/ComponentOverlay.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/web/theme/component/ComponentOverlay.kt @@ -31,8 +31,8 @@ import net.ccbluex.liquidbounce.web.theme.ThemeManager import net.ccbluex.liquidbounce.web.theme.component.types.IntegratedComponent import net.ccbluex.liquidbounce.web.theme.component.types.TextComponent -var components: MutableList = mutableListOf() -var customComponents: MutableList = mutableListOf( +val components: MutableList = mutableListOf() +val customComponents: MutableList = mutableListOf( TextComponent("hello! :)", enabled = false) ) diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/web/theme/component/ComponentType.kt b/src/main/kotlin/net/ccbluex/liquidbounce/web/theme/component/ComponentType.kt index 4d2c992859f..9a9c6b4e915 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/web/theme/component/ComponentType.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/web/theme/component/ComponentType.kt @@ -50,6 +50,7 @@ enum class ComponentType( )), MINIMAP("Minimap", createComponent = { MinimapComponent }), TARGET_HUD("TargetHud"), + BLOCK_COUNTER("BlockCounter"), KEYSTROKES("Keystrokes"), TACO("Taco");