Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: MultiActions #3984

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
*/
package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.ccbluex.liquidbounce.LiquidBounce;
import net.ccbluex.liquidbounce.event.EventManager;
import net.ccbluex.liquidbounce.event.events.*;
import net.ccbluex.liquidbounce.features.misc.HideAppearance;
import net.ccbluex.liquidbounce.features.module.modules.combat.killaura.ModuleKillAura;
import net.ccbluex.liquidbounce.features.module.modules.combat.killaura.features.AutoBlock;
import net.ccbluex.liquidbounce.features.module.modules.exploit.ModuleMultiActions;
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleXRay;
import net.ccbluex.liquidbounce.render.engine.RenderingFlags;
import net.ccbluex.liquidbounce.utils.combat.CombatManager;
Expand All @@ -34,6 +36,7 @@
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerInteractionManager;
import net.minecraft.client.network.ServerInfo;
import net.minecraft.client.option.GameOptions;
import net.minecraft.client.option.KeyBinding;
Expand Down Expand Up @@ -70,6 +73,9 @@ public abstract class MixinMinecraftClient {
private IntegratedServer server;
@Shadow
private int itemUseCooldown;
@Shadow
@Nullable
public ClientPlayerInteractionManager interactionManager;

@Inject(method = "isAmbientOcclusionEnabled()Z", at = @At("HEAD"), cancellable = true)
private static void injectXRayFullBright(CallbackInfoReturnable<Boolean> callback) {
Expand Down Expand Up @@ -214,15 +220,6 @@ private void hookHandleInputEvent(CallbackInfo callbackInfo) {
EventManager.INSTANCE.callEvent(new InputHandleEvent());
}

/**
* Hook KillAura enforced blocking state
*/
@Redirect(method = "handleInputEvents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;isPressed()Z", ordinal = 2))
private boolean hookEnforcedBlockingState(KeyBinding instance) {
return (ModuleKillAura.INSTANCE.getEnabled() && AutoBlock.INSTANCE.getEnabled()
&& AutoBlock.INSTANCE.getBlockingStateEnforced()) || instance.isPressed();
}

/**
* Hook item use cooldown
*/
Expand Down Expand Up @@ -274,4 +271,33 @@ private void hookFpsChange(CallbackInfo ci) {
private void onFinishedLoading(CallbackInfo ci) {
EventManager.INSTANCE.callEvent(new ResourceReloadEvent());
}

@ModifyExpressionValue(method = "handleBlockBreaking", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isUsingItem()Z"))
private boolean injectMultiActionsBreakingWhileUsing(boolean original) {
return original && !(ModuleMultiActions.INSTANCE.handleEvents() && ModuleMultiActions.INSTANCE.getBreakingWhileUsing());
}

@ModifyExpressionValue(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;isBreakingBlock()Z"))
private boolean injectMultiActionsPlacingWhileBreaking(boolean original) {
return original && !(ModuleMultiActions.INSTANCE.handleEvents() && ModuleMultiActions.INSTANCE.getPlacingWhileBreaking());
}

@ModifyExpressionValue(method = "handleInputEvents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isUsingItem()Z", ordinal = 0))
private boolean injectMultiActionsAttackingWhileUsingAndEnforcedBlockingState(boolean isUsingItem) {
if (isUsingItem) {
if (!this.options.useKey.isPressed() && !(ModuleKillAura.INSTANCE.getEnabled()
&& AutoBlock.INSTANCE.getEnabled() && AutoBlock.INSTANCE.getBlockingStateEnforced())) {
this.interactionManager.stopUsingItem(this.player);
}

if (!ModuleMultiActions.INSTANCE.handleEvents() || !ModuleMultiActions.INSTANCE.getAttackingWhileUsing()) {
this.options.attackKey.timesPressed = 0;
}

this.options.pickItemKey.timesPressed = 0;
this.options.useKey.timesPressed = 0;
}

return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ object ModuleManager : Listenable, Iterable<Module> by modules {
ModuleGhostHand,
ModuleKick,
ModuleMoreCarry,
ModuleMultiActions,
ModuleNameCollector,
ModuleNoPitchLimit,
ModulePingSpoof,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import net.ccbluex.liquidbounce.features.module.modules.combat.killaura.features
import net.ccbluex.liquidbounce.features.module.modules.combat.killaura.features.NotifyWhenFail.failedHits
import net.ccbluex.liquidbounce.features.module.modules.combat.killaura.features.NotifyWhenFail.hasFailedHit
import net.ccbluex.liquidbounce.features.module.modules.combat.killaura.features.NotifyWhenFail.renderFailedHits
import net.ccbluex.liquidbounce.features.module.modules.exploit.ModuleMultiActions
import net.ccbluex.liquidbounce.features.module.modules.misc.debugrecorder.modes.GenericDebugRecorder
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleDebug
import net.ccbluex.liquidbounce.render.engine.Color4b
Expand Down Expand Up @@ -110,7 +111,6 @@ object ModuleKillAura : Module("KillAura", Category.COMBAT) {
private val criticalsMode by enumChoice("Criticals", CriticalsMode.SMART)
private val keepSprint by boolean("KeepSprint", true)
private val attackShielding by boolean("AttackShielding", false)
private val whileUsingItem by boolean("WhileUsingItem", true)
private val requiresClick by boolean("RequiresClick", false)
internal val ignoreOpenInventory by boolean("IgnoreOpenInventory", true)
internal val simulateInventoryClosing by boolean("SimulateInventoryClosing", true)
Expand Down Expand Up @@ -485,7 +485,8 @@ object ModuleKillAura : Module("KillAura", Category.COMBAT) {
waitTicks(AutoBlock.tickOff)
}
}
} else if (player.isUsingItem && !whileUsingItem) {
} else if (player.isUsingItem &&
!(ModuleMultiActions.handleEvents() && ModuleMultiActions.attackingWhileUsing)) {
return // return if it's not allowed to attack while the player is using another item that's not a shield
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
*
* Copyright (c) 2015 - 2024 CCBlueX
*
* LiquidBounce is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LiquidBounce is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
*/
package net.ccbluex.liquidbounce.features.module.modules.exploit

import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.Module

object ModuleMultiActions : Module("MultiActions", Category.EXPLOIT, aliases = arrayOf("MultiTask")) {
val placingWhileBreaking by boolean("PlacingWhileBreaking", true)
val attackingWhileUsing by boolean("AttackingWhileUsing", true)
val breakingWhileUsing by boolean("BreakingWhileUsing", true)
}
1 change: 1 addition & 0 deletions src/main/resources/assets/liquidbounce/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -583,5 +583,6 @@
"liquidbounce.module.autoShop.messages.reloadSuccess": "Reloaded successfully",
"liquidbounce.module.autoShop.messages.loadError": "Cannot load the config",
"liquidbounce.module.liquidPlace.description": "Allows you to place blocks on liquids.",
"liquidbounce.module.multiActions.description": "Allows you to do multiple things at the same time.",
"liquidbounce.module.bedDefender.description": "Automatically places blocks to defend your bed in BedWars."
}
Loading