diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/render/HUD.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/render/HUD.kt index 051ee9e9b20..5a27a339e73 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/render/HUD.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/render/HUD.kt @@ -8,8 +8,8 @@ package net.ccbluex.liquidbounce.features.module.modules.render import net.ccbluex.liquidbounce.LiquidBounce.CLIENT_NAME import net.ccbluex.liquidbounce.LiquidBounce.hud import net.ccbluex.liquidbounce.event.* -import net.ccbluex.liquidbounce.features.module.Module import net.ccbluex.liquidbounce.features.module.Category +import net.ccbluex.liquidbounce.features.module.Module import net.ccbluex.liquidbounce.ui.client.hud.designer.GuiHudDesigner import net.ccbluex.liquidbounce.ui.client.hud.element.Element.Companion.MAX_GRADIENT_COLORS import net.ccbluex.liquidbounce.utils.render.ColorSettingsFloat @@ -24,23 +24,21 @@ import net.minecraft.util.ResourceLocation object HUD : Module("HUD", Category.RENDER, defaultInArray = false, gameDetecting = false, hideModule = true) { val customHotbar by BoolValue("CustomHotbar", true) + val smoothHotbarSlot by BoolValue("SmoothHotbarSlot", true) { customHotbar } + val roundedHotbarRadius by FloatValue("RoundedHotbar-Radius", 0F, 0F..5F) { customHotbar } val hotbarMode by ListValue("Hotbar-Color", arrayOf("Custom", "Rainbow", "Gradient"), "Custom") { customHotbar } - val hbHighlightColors = ColorSettingsInteger(this, "Hotbar-Highlight-Colors", applyMax = true) { customHotbar }.with(a = 100) val hbBackgroundColors = ColorSettingsInteger(this, "Hotbar-Background-Colors") { customHotbar && hotbarMode == "Custom" }.with(a = 100) - val gradientHotbarSpeed by FloatValue("Hotbar-Gradient-Speed", 1f, 0.5f..10f) { customHotbar && hotbarMode == "Gradient" } - val maxHotbarGradientColors by IntegerValue("Max-Hotbar-Gradient-Colors", 4, 1..MAX_GRADIENT_COLORS) { customHotbar && hotbarMode == "Gradient" } val bgGradColors = ColorSettingsFloat.create(this, "Hotbar-Gradient") { customHotbar && hotbarMode == "Gradient" && it <= maxHotbarGradientColors } - val hotbarBorder by FloatValue("HotbarBorder-Width", 0.5F, 0.5F..5F) { customHotbar } val hbBorderColors = ColorSettingsInteger(this, "HotbarBorder", zeroAlphaCheck = true) { customHotbar }.with(a = 0) diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiInGame.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiInGame.java index b3e947d16fc..c1a3a162874 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiInGame.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiInGame.java @@ -12,6 +12,7 @@ import net.ccbluex.liquidbounce.features.module.modules.render.NoScoreboard; import net.ccbluex.liquidbounce.ui.font.AWTFontRenderer; import net.ccbluex.liquidbounce.utils.ClassUtils; +import net.ccbluex.liquidbounce.utils.inventory.InventoryUtils; import net.ccbluex.liquidbounce.utils.render.ColorSettingsKt; import net.ccbluex.liquidbounce.utils.render.FakeItemRender; import net.ccbluex.liquidbounce.utils.render.RenderUtils; @@ -134,13 +135,17 @@ protected void renderTooltip(ScaledResolution sr, float partialTicks) { if (mc.getRenderViewEntity() instanceof EntityPlayer) { EntityPlayer entityPlayer = (EntityPlayer) mc.getRenderViewEntity(); - int slot = entityPlayer.inventory.currentItem; + float slot = entityPlayer.inventory.currentItem; if (FakeItemRender.INSTANCE.getFakeItem() != -1) { slot = FakeItemRender.INSTANCE.getFakeItem(); } if (hud.handleEvents() && hud.getCustomHotbar()) { + if (hud.getSmoothHotbarSlot()) { + slot = InventoryUtils.INSTANCE.getLerpedSlot(); + } + int middleScreen = sr.getScaledWidth() / 2; int height = sr.getScaledHeight() - 1; @@ -191,7 +196,7 @@ protected void renderTooltip(ScaledResolution sr, float partialTicks) { } // Inner - Highlight - render.drawRoundedRectInt( + render.drawRoundedRect( middleScreen - 91 - 1 + slot * 20 + 1, height - 22, middleScreen - 91 - 1 + slot * 20 + 23, height - 23 - 1 + 24, hud.getHbHighlightColors().color().getRGB(), @@ -208,7 +213,7 @@ protected void renderTooltip(ScaledResolution sr, float partialTicks) { ); // Border - Highlight - render.drawRoundedBorderInt( + render.drawRoundedBorder( middleScreen - 91 - 1 + slot * 20 + 1, height - 22, middleScreen - 91 - 1 + slot * 20 + 23, height - 23 - 1 + 24, hud.getHotbarBorder(), diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/inventory/InventoryUtils.kt b/src/main/java/net/ccbluex/liquidbounce/utils/inventory/InventoryUtils.kt index 2717284e020..cb6d50688ad 100644 --- a/src/main/java/net/ccbluex/liquidbounce/utils/inventory/InventoryUtils.kt +++ b/src/main/java/net/ccbluex/liquidbounce/utils/inventory/InventoryUtils.kt @@ -10,6 +10,7 @@ import net.ccbluex.liquidbounce.features.module.modules.misc.NoSlotSet import net.ccbluex.liquidbounce.features.module.modules.world.ChestAura import net.ccbluex.liquidbounce.utils.MinecraftInstance import net.ccbluex.liquidbounce.utils.PacketUtils.sendPacket +import net.ccbluex.liquidbounce.utils.render.FakeItemRender import net.ccbluex.liquidbounce.utils.timing.MSTimer import net.ccbluex.liquidbounce.utils.timing.TickedActions import net.minecraft.block.BlockBush @@ -57,6 +58,8 @@ object InventoryUtils : MinecraftInstance(), Listenable { private var _serverSlot = 0 private var _serverOpenInventory = false + var lerpedSlot = 0f + var isFirstInventoryClick = true var timeSinceClosedInventory = 0L @@ -177,7 +180,6 @@ object InventoryUtils : MinecraftInstance(), Listenable { @EventTarget fun onPacket(event: PacketEvent) { - if (event.isCancelled) return when (val packet = event.packet) { @@ -239,6 +241,19 @@ object InventoryUtils : MinecraftInstance(), Listenable { } } + @EventTarget + fun onRender3D(event: Render3DEvent) { + val slotToUse = if (FakeItemRender.fakeItem != -1) { + FakeItemRender.fakeItem + } else mc.thePlayer?.inventory?.currentItem ?: 0 + + // Could just use serverSlot, but that would also mean getting slots from modules like Scaffold + // Where AutoBlock Spoof mode could be enabled and the user would maybe not like to see that + // (SilentHotbar module needed for this one) + + lerpedSlot += (slotToUse - lerpedSlot) * 0.1f + } + @EventTarget fun onWorld(event: WorldEvent) { // Reset flags to prevent de-sync