Skip to content

Commit 38bac22

Browse files
committed
fix: (betterinventory) add move-while-open and make the slot highlight visible
The module only shipped the clicked-slot highlight, and its Fill mode drew under the item so it was hidden. Add a MoveWhileOpen option that keeps movement keys active while a container screen is open (yielding to the dedicated InvMove module to avoid double-driving keybinds), and draw the highlight at drawSlot RETURN with a translucent Fill so it renders over the item.
1 parent f318bdf commit 38bac22

2 files changed

Lines changed: 47 additions & 2 deletions

File tree

src/main/java/net/ccbluex/liquidbounce/features/module/modules/other/BetterInventory.kt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ import net.ccbluex.liquidbounce.event.UpdateEvent
99
import net.ccbluex.liquidbounce.event.handler
1010
import net.ccbluex.liquidbounce.features.module.Category
1111
import net.ccbluex.liquidbounce.features.module.Module
12+
import net.ccbluex.liquidbounce.features.module.modules.movement.InvMove
1213
import net.ccbluex.liquidbounce.injection.forge.mixins.gui.MixinGuiContainerAccessor
1314
import net.minecraft.client.gui.inventory.GuiContainer
15+
import net.minecraft.client.settings.GameSettings
16+
import net.minecraft.client.settings.KeyBinding
1417
import org.lwjgl.input.Mouse
1518
import java.awt.Color
1619

1720
object BetterInventory : Module("BetterInventory", Category.OTHER, Category.SubCategory.MISCELLANEOUS, gameDetecting = false) {
1821

22+
private val moveWhileOpen by boolean("MoveWhileOpen", true)
23+
.describe("Keep walking, sprinting and jumping while an inventory or chest screen is open.")
24+
1925
val highlightClicked by boolean("HighlightClicked", true)
2026
.describe("Highlight the last slot you clicked.")
2127
val highlightMode by choices("HighlightMode", arrayOf("Border", "Fill"), "Border") { highlightClicked }
@@ -30,15 +36,28 @@ object BetterInventory : Module("BetterInventory", Category.OTHER, Category.SubC
3036

3137
private var leftHeld = false
3238
private var rightHeld = false
39+
private var drivingMovement = false
40+
41+
private val movementBindings = arrayOf(
42+
mc.gameSettings.keyBindForward,
43+
mc.gameSettings.keyBindBack,
44+
mc.gameSettings.keyBindLeft,
45+
mc.gameSettings.keyBindRight,
46+
mc.gameSettings.keyBindJump,
47+
mc.gameSettings.keyBindSprint
48+
)
3349

3450
val onUpdate = handler<UpdateEvent> {
3551
val screen = mc.currentScreen as? GuiContainer ?: run {
3652
clickedSlot = -1
3753
leftHeld = false
3854
rightHeld = false
55+
releaseMovement()
3956
return@handler
4057
}
4158

59+
driveMovement()
60+
4261
val leftDown = Mouse.isButtonDown(0)
4362
val rightDown = Mouse.isButtonDown(1)
4463

@@ -52,4 +71,27 @@ object BetterInventory : Module("BetterInventory", Category.OTHER, Category.SubC
5271
leftHeld = leftDown
5372
rightHeld = rightDown
5473
}
74+
75+
/** Presses the movement bindings while a container is open, yielding to the dedicated InvMove module. */
76+
private fun driveMovement() {
77+
if (!moveWhileOpen || InvMove.handleEvents()) {
78+
releaseMovement()
79+
return
80+
}
81+
drivingMovement = true
82+
for (binding in movementBindings) binding.pressed = isPhysicallyDown(binding)
83+
}
84+
85+
private fun releaseMovement() {
86+
if (!drivingMovement) return
87+
drivingMovement = false
88+
for (binding in movementBindings) binding.pressed = isPhysicallyDown(binding)
89+
}
90+
91+
private fun isPhysicallyDown(binding: KeyBinding): Boolean =
92+
if (binding.keyCode < 0) Mouse.isButtonDown(binding.keyCode + 100) else GameSettings.isKeyDown(binding)
93+
94+
override fun onDisable() {
95+
releaseMovement()
96+
}
5597
}

src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiContainerHighlight.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
@SideOnly(Side.CLIENT)
2323
public abstract class MixinGuiContainerHighlight extends MixinGuiScreen {
2424

25-
@Inject(method = "drawSlot", at = @At("HEAD"))
25+
@Inject(method = "drawSlot", at = @At("RETURN"))
2626
private void drawSlot(Slot slot, CallbackInfo ci) {
2727
final BetterInventory betterInventory = BetterInventory.INSTANCE;
2828

@@ -41,9 +41,12 @@ private void drawSlot(Slot slot, CallbackInfo ci) {
4141
glPushMatrix();
4242
glPushAttrib(GL_ENABLE_BIT);
4343
glDisable(GL_LIGHTING);
44+
glDisable(GL_DEPTH_TEST);
4445

4546
if ("Fill".equals(betterInventory.getHighlightMode())) {
46-
RenderUtils.INSTANCE.drawRect(x, y, x + 16, y + 16, color);
47+
// Render over the drawn item with a translucent tint so the item stays visible.
48+
int fill = (color & 0x00FFFFFF) | 0x66000000;
49+
RenderUtils.INSTANCE.drawRect(x, y, x + 16, y + 16, fill);
4750
} else {
4851
RenderUtils.INSTANCE.drawBorder(x, y, x + 16, y + 16, betterInventory.getBorderWidth(), color);
4952
}

0 commit comments

Comments
 (0)