Skip to content

Commit 08ad2cf

Browse files
committed
fix middle click cancel not working
1 parent 93a9a87 commit 08ad2cf

File tree

9 files changed

+16
-47
lines changed

9 files changed

+16
-47
lines changed

src/main/java/com/lambda/mixin/MinecraftClientMixin.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,30 +175,25 @@ boolean redirectMultiActon(boolean original) {
175175
@Inject(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isRiding()Z"))
176176
void injectFastPlace(CallbackInfo ci) {
177177
if (!Interact.INSTANCE.isEnabled()) return;
178-
179178
itemUseCooldown = Interact.getPlaceDelay();
180179
}
181180

182181
@WrapMethod(method = "doItemUse")
183182
void injectItemUse(Operation<Void> original) {
184-
if (BetterFirework.INSTANCE.isDisabled() || !BetterFirework.onInteract())
185-
original.call();
183+
if (BetterFirework.INSTANCE.isDisabled() || !BetterFirework.onInteract()) original.call();
186184
}
187185

188186
@WrapMethod(method = "doItemPick")
189187
void injectItemPick(Operation<Void> original) {
190-
if (BetterFirework.INSTANCE.isDisabled() || !BetterFirework.onPick())
191-
original.call();
188+
if (BetterFirework.INSTANCE.isDisabled() || !BetterFirework.onPick()) original.call();
192189
}
193190

194191
@WrapMethod(method = "getTargetMillisPerTick")
195192
float getTargetMillisPerTick(float millis, Operation<Float> original) {
196193
var length = TimerManager.INSTANCE.getLength();
197194

198-
if (length == TimerManager.DEFAULT_LENGTH)
199-
return original.call(millis);
200-
else
201-
return (float) TimerManager.INSTANCE.getLength();
195+
if (length == TimerManager.DEFAULT_LENGTH) return original.call(millis);
196+
else return (float) TimerManager.INSTANCE.getLength();
202197
}
203198

204199
@Inject(method = "updateWindowTitle", at = @At("HEAD"), cancellable = true)

src/main/kotlin/com/lambda/config/groups/BuildSettings.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class BuildSettings(
4848
override var entityReach by c.setting("Attack Reach", 3.0, 1.0..7.0, 0.01, "Maximum entity interaction distance").group(baseGroup, Group.Reach).index()
4949
override val scanReach: Double get() = max(entityReach, blockReach)
5050

51-
override val checkSideVisibility by c.setting("Visibility Check", true, "Whether to check if an AABB side is visible").group(baseGroup, Group.Scan).index()
51+
override val checkSideVisibility by c.setting("Visibility Check", false, "Whether to check if an AABB side is visible").group(baseGroup, Group.Scan).index()
5252
override val strictRayCast by c.setting("Strict Raycast", false, "Whether to include the environment to the ray cast context").group(baseGroup, Group.Scan).index()
5353
override val resolution by c.setting("Resolution", 5, 1..20, 1, "The amount of grid divisions per surface of the hit box", "") { strictRayCast }.group(baseGroup, Group.Scan).index()
5454
override val pointSelection by c.setting("Point Selection", PointSelection.Optimum, "The strategy to select the best hit point").group(baseGroup, Group.Scan).index()

src/main/kotlin/com/lambda/config/groups/InteractSettings.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class InteractSettings(
3131
baseGroup: NamedEnum
3232
) : SettingGroup(c), InteractConfig {
3333
override val rotate by c.setting("Rotate For Interact", true, "Rotate towards block while placing").group(baseGroup).index()
34-
override val airPlace by c.setting("Air Place", AirPlaceMode.None, "Allows for placing blocks without adjacent faces").group(baseGroup).index()
34+
override val airPlace by c.setting("Air Place", AirPlaceMode.Grim, "Allows for placing blocks without adjacent faces").group(baseGroup).index()
3535
override val axisRotateSetting by c.setting("Axis Rotate", true, "Overrides the Rotate For Place setting and rotates the player on each axis to air place rotational blocks") { airPlace.isEnabled }.group(baseGroup).index()
3636
override val sorter by c.setting("Interaction Sorter", ActionConfig.SortMode.Tool, "The order in which placements are performed").group(baseGroup).index()
3737
override val tickStageMask by c.setting("Interaction Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), "The sub-tick timing at which place actions are performed", displayClassName = true).group(baseGroup).index()

src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ object PlayerTrap : Module(
6363
::spleefEntities,
6464
::collectDrops
6565
) { defaultValue(false); hide() }
66-
::checkSideVisibility.edit { defaultValue(false) }
67-
}
68-
interactConfig.apply {
69-
::airPlace.edit { defaultValue(InteractConfig.AirPlaceMode.Grim) }
7066
}
7167
hideGroup(eatConfig)
7268
}

src/main/kotlin/com/lambda/module/modules/combat/Surround.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ object Surround : Module(
5252
::spleefEntities,
5353
::collectDrops
5454
) { defaultValue(false); hide() }
55-
::checkSideVisibility.edit { defaultValue(false) }
56-
}
57-
interactConfig.apply {
58-
::airPlace.edit { defaultValue(InteractConfig.AirPlaceMode.Grim) }
5955
}
6056
hideGroup(eatConfig)
6157
}

src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.lambda.module.modules.movement
1919

20+
import com.lambda.Lambda.mc
2021
import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig
2122
import com.lambda.config.applyEdits
2223
import com.lambda.config.settings.complex.Bind
@@ -28,6 +29,7 @@ import com.lambda.interaction.managers.hotbar.HotbarRequest
2829
import com.lambda.interaction.managers.inventory.InventoryRequest.Companion.inventoryRequest
2930
import com.lambda.interaction.material.StackSelection.Companion.selectStack
3031
import com.lambda.module.Module
32+
import com.lambda.module.modules.movement.BetterFirework.sendSwing
3133
import com.lambda.module.tag.ModuleTag
3234
import com.lambda.threading.runSafe
3335
import com.lambda.util.Communication.warn
@@ -130,7 +132,7 @@ object BetterFirework : Module(
130132
!fireworkInteract ||
131133
player.inventory.selectedStack?.item != Items.FIREWORK_ROCKET ||
132134
player.isGliding || // No need to do special magic if we are already holding fireworks and flying
133-
(mc.crosshairTarget != null && mc.crosshairTarget!!.type != HitResult.Type.MISS && !fireworkInteractCancel) -> false
135+
(mc.crosshairTarget != null && mc.crosshairTarget?.type != HitResult.Type.MISS && !fireworkInteractCancel) -> false
134136
else -> {
135137
mc.itemUseCooldown += 4
136138
val cancelInteract = player.canTakeoff || fireworkInteractCancel
@@ -145,25 +147,14 @@ object BetterFirework : Module(
145147
} ?: false
146148

147149
/**
148-
* Returns true when the pick interaction should be canceled.
150+
* Returns true if the pick interaction should be canceled.
149151
*/
150152
@JvmStatic
151-
fun onPick() =
152-
runSafe {
153-
when {
154-
(mc.crosshairTarget?.type == HitResult.Type.BLOCK && !middleClickCancel) ||
155-
activateButton.mouse != mc.options.pickItemKey.boundKey.code ||
156-
takeoffState != TakeoffState.None -> false // Prevent using multiple times
157-
else -> middleClickCancel
158-
}
159-
} ?: false
153+
fun onPick() = if (activateButton.mouse == mc.options.pickItemKey.boundKey.code) middleClickCancel else false
160154

161155
fun SafeContext.sendSwing() {
162-
if (clientSwing) {
163-
player.swingHand(Hand.MAIN_HAND)
164-
} else {
165-
connection.sendPacket(HandSwingC2SPacket(Hand.MAIN_HAND))
166-
}
156+
if (clientSwing) player.swingHand(Hand.MAIN_HAND)
157+
else connection.sendPacket(HandSwingC2SPacket(Hand.MAIN_HAND))
167158
}
168159

169160
/**

src/main/kotlin/com/lambda/module/modules/player/AirPlace.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ object AirPlace : Module(
7171
init {
7272
setDefaultAutomationConfig {
7373
applyEdits {
74-
interactConfig.apply {
75-
::airPlace.edit { defaultValue(InteractConfig.AirPlaceMode.Grim) }
76-
}
7774
hideAllGroupsExcept(interactConfig)
7875
}
7976
}

src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ object FastBreak : Module(
5454
)
5555
::maxBuildDependencies.edit { defaultValue(0) }
5656
editTyped(
57-
::checkSideVisibility,
5857
::strictRayCast
59-
) { defaultValue(false); hide() }
58+
) { defaultValue(false); }
59+
hide(::strictRayCast, ::checkSideVisibility)
6060
::blockReach.edit { defaultValue(Double.MAX_VALUE) }
6161
}
6262
breakConfig.apply {

src/main/kotlin/com/lambda/module/modules/player/Printer.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,7 @@ object Printer : Module(
4444
private var buildTask: Task<*>? = null
4545

4646
init {
47-
setDefaultAutomationConfig {
48-
applyEdits {
49-
editTyped(buildConfig::pathing, buildConfig::stayInRange) { defaultValue(false) }
50-
editTyped(breakConfig::efficientOnly, breakConfig::suitableToolsOnly) { defaultValue(false) }
51-
interactConfig::airPlace.edit { defaultValue(InteractConfig.AirPlaceMode.Grim) }
52-
}
53-
}
47+
setDefaultAutomationConfig()
5448

5549
onEnable {
5650
if (!litematicaAvailable()) {

0 commit comments

Comments
 (0)