| 1 | /*
|
| 2 | * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
|
| 3 | *
|
| 4 | * Copyright (c) 2015 - 2026 CCBlueX
|
| 5 | *
|
| 6 | * LiquidBounce is free software: you can redistribute it and/or modify
|
| 7 | * it under the terms of the GNU General Public License as published by
|
| 8 | * the Free Software Foundation, either version 3 of the License, or
|
| 9 | * (at your option) any later version.
|
| 10 | *
|
| 11 | * LiquidBounce is distributed in the hope that it will be useful,
|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 | * GNU General Public License for more details.
|
| 15 | *
|
| 16 | * You should have received a copy of the GNU General Public License
|
| 17 | * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
|
| 18 | */
|
| 19 | package net.ccbluex.liquidbounce.injection.mixins.minecraft.client;
|
| 20 |
|
| 21 | import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
| 22 | import com.llamalad7.mixinextras.injector.ModifyReceiver;
|
| 23 | import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
|
| 24 | import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
| 25 | import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
| 26 | import com.llamalad7.mixinextras.sugar.Local;
|
| 27 | import com.mojang.blaze3d.platform.Window;
|
| 28 | import net.ccbluex.liquidbounce.LiquidBounce;
|
| 29 | import net.ccbluex.liquidbounce.event.CoroutineTicker;
|
| 30 | import net.ccbluex.liquidbounce.event.EventManager;
|
| 31 | import net.ccbluex.liquidbounce.event.TickLoopTaskExecutor;
|
| 32 | import net.ccbluex.liquidbounce.event.events.*;
|
| 33 | import net.ccbluex.liquidbounce.features.misc.SelfDestruct;
|
| 34 | import net.ccbluex.liquidbounce.features.module.modules.combat.ModuleAutoClicker;
|
| 35 | import net.ccbluex.liquidbounce.features.module.modules.combat.ModuleNoMissCooldown;
|
| 36 | import net.ccbluex.liquidbounce.features.module.modules.combat.killaura.features.KillAuraAutoBlock;
|
| 37 | import net.ccbluex.liquidbounce.features.module.modules.exploit.ModuleMultiActions;
|
| 38 | import net.ccbluex.liquidbounce.features.module.modules.misc.ModuleMiddleClickAction;
|
| 39 | import net.ccbluex.liquidbounce.features.module.modules.player.ModuleAutoBreak;
|
| 40 | import net.ccbluex.liquidbounce.features.module.modules.player.ModuleNoBlockInteract;
|
| 41 | import net.ccbluex.liquidbounce.features.module.modules.player.ModuleReach;
|
| 42 | import net.ccbluex.liquidbounce.features.module.modules.render.ModuleFreeCam;
|
| 43 | import net.ccbluex.liquidbounce.injection.mixins.minecraft.entity.MixinEntityAccessor;
|
| 44 | import net.ccbluex.liquidbounce.integration.backend.BrowserBackendManager;
|
| 45 | import net.ccbluex.liquidbounce.integration.backend.browser.GlobalBrowserSettings;
|
| 46 | import net.ccbluex.liquidbounce.integration.screen.ScreenManager;
|
| 47 | import net.ccbluex.liquidbounce.render.ClientTesselator;
|
| 48 | import net.ccbluex.liquidbounce.render.buffers.StaticGpuBufferPool;
|
| 49 | import net.ccbluex.liquidbounce.render.mesh.MeshDraw;
|
| 50 | import net.ccbluex.liquidbounce.render.utils.RenderingDebug;
|
| 51 | import net.ccbluex.liquidbounce.utils.client.vfp.VfpCompatibility;
|
| 52 | import net.ccbluex.liquidbounce.utils.combat.CombatManager;
|
| 53 | import net.minecraft.SharedConstants;
|
| 54 | import net.minecraft.client.Minecraft;
|
| 55 | import net.minecraft.client.Options;
|
| 56 | import net.minecraft.client.User;
|
| 57 | import net.minecraft.client.gui.Gui;
|
| 58 | import net.minecraft.client.multiplayer.ClientLevel;
|
| 59 | import net.minecraft.client.multiplayer.ClientPacketListener;
|
| 60 | import net.minecraft.client.multiplayer.MultiPlayerGameMode;
|
| 61 | import net.minecraft.client.multiplayer.ServerData;
|
| 62 | import net.minecraft.client.player.LocalPlayer;
|
| 63 | import net.minecraft.client.resources.language.I18n;
|
| 64 | import net.minecraft.client.server.IntegratedServer;
|
| 65 | import net.minecraft.util.profiling.ProfilerFiller;
|
| 66 | import net.minecraft.world.entity.Entity;
|
| 67 | import net.minecraft.world.entity.LivingEntity;
|
| 68 | import net.minecraft.world.item.component.AttackRange;
|
| 69 | import net.minecraft.world.phys.AABB;
|
| 70 | import net.minecraft.world.phys.BlockHitResult;
|
| 71 | import net.minecraft.world.phys.HitResult;
|
| 72 | import net.minecraft.world.phys.Vec3;
|
| 73 | import org.jspecify.annotations.Nullable;
|
| 74 | import org.objectweb.asm.Opcodes;
|
| 75 | import org.spongepowered.asm.mixin.Final;
|
| 76 | import org.spongepowered.asm.mixin.Mixin;
|
| 77 | import org.spongepowered.asm.mixin.Shadow;
|
| 78 | import org.spongepowered.asm.mixin.injection.At;
|
| 79 | import org.spongepowered.asm.mixin.injection.Inject;
|
| 80 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
| 81 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
| 82 | import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
| 83 |
|
| 84 | import static net.ccbluex.liquidbounce.utils.client.ProtocolUtilKt.getUsesViaFabricPlus;
|
| 85 |
|
| 86 | @Mixin(Minecraft.class)
|
| 87 | public abstract class MixinMinecraft {
|
| 88 |
|
| 89 | @Shadow
|
| 90 | @Nullable
|
| 91 | public LocalPlayer player;
|
| 92 | @Shadow
|
| 93 | @Nullable
|
| 94 | public HitResult hitResult;
|
| 95 | @Shadow
|
| 96 | @Final
|
| 97 | public Options options;
|
| 98 | @Shadow
|
| 99 | @Nullable
|
| 100 | private IntegratedServer singleplayerServer;
|
| 101 | @Shadow
|
| 102 | private int rightClickDelay;
|
| 103 | @Shadow
|
| 104 | @Nullable
|
| 105 | public MultiPlayerGameMode gameMode;
|
| 106 |
|
| 107 | @Shadow
|
| 108 | @Nullable
|
| 109 | public abstract ClientPacketListener getConnection();
|
| 110 |
|
| 111 | @Shadow
|
| 112 | public abstract @Nullable ServerData getCurrentServer();
|
| 113 |
|
| 114 | @Shadow
|
| 115 | public abstract Window getWindow();
|
| 116 |
|
| 117 | @Shadow
|
| 118 | public abstract int getFps();
|
| 119 |
|
| 120 | @Shadow
|
| 121 | public abstract User getUser();
|
| 122 |
|
| 123 | @Shadow
|
| 124 | protected abstract void continueAttack(boolean breaking);
|
| 125 |
|
| 126 | @Shadow
|
| 127 | @Nullable
|
| 128 | public ClientLevel level;
|
| 129 |
|
| 130 | @Shadow
|
| 131 | @Final
|
| 132 | public Gui gui;
|
| 133 |
|
| 134 | /**
|
| 135 | * Entry point
|
| 136 | */
|
| 137 | @Inject(method = "<init>(Lnet/minecraft/client/main/GameConfig;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;resizeGui()V"))
|
| 138 | private void startClient(CallbackInfo callback) {
|
| 139 | EventManager.INSTANCE.callEvent(ClientStartEvent.INSTANCE);
|
| 140 | }
|
| 141 |
|
| 142 | /**
|
| 143 | * Exit point
|
| 144 | */
|
| 145 | @Inject(method = "close", at = @At("HEAD"))
|
| 146 | private void stopClient(CallbackInfo callback) {
|
| 147 | MeshDraw.DefaultUploader.close();
|
| 148 | EventManager.INSTANCE.callEvent(ClientShutdownEvent.INSTANCE);
|
| 149 | }
|
| 150 |
|
| 151 | @Inject(method = "<init>(Lnet/minecraft/client/main/GameConfig;)V", at = @At(value = "FIELD",
|
| 152 | target = "Lnet/minecraft/client/Minecraft;profileKeyPairManager:Lnet/minecraft/client/multiplayer/ProfileKeyPairManager;",
|
| 153 | ordinal = 0, shift = At.Shift.AFTER, opcode = Opcodes.PUTFIELD))
|
| 154 | private void onSessionInit(CallbackInfo callback) {
|
| 155 | EventManager.INSTANCE.callEvent(new SessionEvent(getUser()));
|
| 156 | }
|
| 157 |
|
| 158 | /**
|
| 159 | * Modify window title to our client title.
|
| 160 | * Example: LiquidBounce v1.0.0 | 1.16.3
|
| 161 | *
|
| 162 | * @param callback our window title
|
| 163 | * <p>
|
| 164 | * todo: modify constant Minecraft instead
|
| 165 | */
|
| 166 | @Inject(method = "createTitle", at = @At(
|
| 167 | value = "INVOKE",
|
| 168 | target = "Ljava/lang/StringBuilder;append(Ljava/lang/String;)Ljava/lang/StringBuilder;",
|
| 169 | ordinal = 1),
|
| 170 | cancellable = true)
|
| 171 | private void getClientTitle(CallbackInfoReturnable<String> callback) {
|
| 172 | if (SelfDestruct.INSTANCE.isDestructed()) {
|
| 173 | return;
|
| 174 | }
|
| 175 |
|
| 176 | LiquidBounce.INSTANCE.getLogger().debug("Modifying window title");
|
| 177 |
|
| 178 | StringBuilder titleBuilder = new StringBuilder(LiquidBounce.CLIENT_NAME);
|
| 179 | titleBuilder.append(" v");
|
| 180 | titleBuilder.append(LiquidBounce.INSTANCE.getClientVersion());
|
| 181 | titleBuilder.append(" ");
|
| 182 |
|
| 183 | if (LiquidBounce.IN_DEVELOPMENT) {
|
| 184 | titleBuilder.append("(dev) ");
|
| 185 | }
|
| 186 |
|
| 187 | titleBuilder.append(LiquidBounce.INSTANCE.getClientCommit());
|
| 188 |
|
| 189 | titleBuilder.append(" | ");
|
| 190 |
|
| 191 | // ViaFabricPlus compatibility
|
| 192 | if (getUsesViaFabricPlus()) {
|
| 193 | var protocolVersion = VfpCompatibility.INSTANCE.unsafeGetProtocolVersion();
|
| 194 |
|
| 195 | if (protocolVersion != null) {
|
| 196 | titleBuilder.append(protocolVersion.name());
|
| 197 | } else {
|
| 198 | titleBuilder.append(SharedConstants.getCurrentVersion().name());
|
| 199 | }
|
| 200 | } else {
|
| 201 | titleBuilder.append(SharedConstants.getCurrentVersion().name());
|
| 202 | }
|
| 203 |
|
| 204 | // For debugging purposes, will be removed until we have a stable release
|
| 205 | var backend = BrowserBackendManager.INSTANCE.getBackend();
|
| 206 | if (backend != null && backend.isInitialized() && backend.getAccelerationFlags().isSupported()) {
|
| 207 | var accelerated = GlobalBrowserSettings.INSTANCE.getAccelerated();
|
| 208 |
|
| 209 | if (accelerated != null && accelerated.get()) {
|
| 210 | titleBuilder.append(" | Accelerated Paint is ON");
|
| 211 | // Hotkey only works when not in-game
|
| 212 | if (this.level == null && this.player == null) {
|
| 213 | titleBuilder.append(" [Hotkey: F12]");
|
| 214 | }
|
| 215 | }
|
| 216 | }
|
| 217 |
|
| 218 | ClientPacketListener clientPlayNetworkHandler = this.getConnection();
|
| 219 | if (clientPlayNetworkHandler != null && clientPlayNetworkHandler.getConnection().isConnected()) {
|
| 220 | titleBuilder.append(" - ");
|
| 221 | ServerData serverInfo = this.getCurrentServer();
|
| 222 | if (this.singleplayerServer != null && !this.singleplayerServer.isPublished()) {
|
| 223 | titleBuilder.append(I18n.get("title.singleplayer"));
|
| 224 | } else if (serverInfo != null && serverInfo.isRealm()) {
|
| 225 | titleBuilder.append(I18n.get("title.multiplayer.realms"));
|
| 226 | } else if (this.singleplayerServer == null && (serverInfo == null || !serverInfo.isLan())) {
|
| 227 | titleBuilder.append(I18n.get("title.multiplayer.other"));
|
| 228 | } else {
|
| 229 | titleBuilder.append(I18n.get("title.multiplayer.lan"));
|
| 230 | }
|
| 231 | }
|
| 232 |
|
| 233 | callback.setReturnValue(titleBuilder.toString());
|
| 234 | }
|
| 235 |
|
| 236 | /**
|
| 237 | * Hook game tick event at HEAD
|
| 238 | */
|
| 239 | @Inject(method = "tick", at = @At("HEAD"))
|
| 240 | private void hookTickEvent(CallbackInfo callbackInfo) {
|
| 241 | CoroutineTicker.INSTANCE.beginMinecraftTick();
|
| 242 | TickLoopTaskExecutor.INSTANCE.onTickLoopStart();
|
| 243 | CoroutineTicker.INSTANCE.tick();
|
| 244 | EventManager.INSTANCE.callEvent(GameTickEvent.INSTANCE);
|
| 245 | }
|
| 246 |
|
| 247 | @Inject(method = "tick", at = @At(
|
| 248 | value = "INVOKE",
|
| 249 | target = "Lnet/minecraft/client/multiplayer/ClientPacketListener;send(Lnet/minecraft/network/protocol/Packet;)V",
|
| 250 | shift = At.Shift.AFTER
|
| 251 | ))
|
| 252 | private void hookTickLoopCompletedAfterTickEndPacket(CallbackInfo callbackInfo) {
|
| 253 | TickLoopTaskExecutor.INSTANCE.onTickLoopCompleted();
|
| 254 | }
|
| 255 |
|
| 256 | @Inject(method = "tick", at = @At("RETURN"))
|
| 257 | private void fallbackCompleteTickLoop(CallbackInfo callbackInfo) {
|
| 258 | if (TickLoopTaskExecutor.INSTANCE.isInTickLoop()) {
|
| 259 | TickLoopTaskExecutor.INSTANCE.onTickLoopCompleted();
|
| 260 | }
|
| 261 |
|
| 262 | CoroutineTicker.INSTANCE.endMinecraftTick();
|
| 263 | }
|
| 264 |
|
| 265 | /**
|
| 266 | * Hook game render task queue event
|
| 267 | */
|
| 268 | @Inject(method = "runTick", at = @At("HEAD"))
|
| 269 | private void hookRenderTaskQueue(CallbackInfo callbackInfo) {
|
| 270 | EventManager.INSTANCE.callEvent(GameRenderTaskQueueEvent.INSTANCE);
|
| 271 | }
|
| 272 |
|
| 273 | @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;runAllTasks()V", shift = At.Shift.BEFORE))
|
| 274 | private void hookPacketProcess(CallbackInfo callbackInfo) {
|
| 275 | EventManager.INSTANCE.callEvent(TickPacketProcessEvent.INSTANCE);
|
| 276 | }
|
| 277 |
|
| 278 | /**
|
| 279 | * Hook input handling
|
| 280 | */
|
| 281 | @Inject(method = "handleKeybinds", at = @At("RETURN"))
|
| 282 | private void hookHandleInputEvent(CallbackInfo callbackInfo) {
|
| 283 | EventManager.INSTANCE.callEvent(InputHandleEvent.INSTANCE);
|
| 284 | }
|
| 285 |
|
| 286 | /**
|
| 287 | * Hook item use cooldown
|
| 288 | */
|
| 289 | @Inject(method = "startUseItem", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;rightClickDelay:I", shift = At.Shift.AFTER, opcode = Opcodes.PUTFIELD))
|
| 290 | private void hookItemUseCooldown(CallbackInfo callbackInfo) {
|
| 291 | UseCooldownEvent useCooldownEvent = new UseCooldownEvent(rightClickDelay);
|
| 292 | EventManager.INSTANCE.callEvent(useCooldownEvent);
|
| 293 | rightClickDelay = useCooldownEvent.getCooldown();
|
| 294 | }
|
| 295 |
|
| 296 | @Inject(method = "pickBlockOrEntity", at = @At("HEAD"), cancellable = true)
|
| 297 | private void hookItemPick(CallbackInfo ci) {
|
| 298 | if (ModuleMiddleClickAction.Pearl.INSTANCE.cancelPick()) {
|
| 299 | ci.cancel();
|
| 300 | }
|
| 301 | }
|
| 302 |
|
| 303 | @ModifyExpressionValue(method = "startAttack",
|
| 304 | at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;missTime:I", ordinal = 0, opcode = Opcodes.GETFIELD))
|
| 305 | private int injectNoMissCooldown(int original) {
|
| 306 | if (ModuleNoMissCooldown.INSTANCE.getRunning() && ModuleNoMissCooldown.INSTANCE.getRemoveAttackCooldown()) {
|
| 307 | return 0;
|
| 308 | }
|
| 309 |
|
| 310 | if (ModuleAutoClicker.AttackButton.INSTANCE.getRunning()) {
|
| 311 | var clickAmount = ModuleAutoClicker.AttackButton.INSTANCE.getClicker().getClickAmount();
|
| 312 | if (clickAmount != null && clickAmount > 0) {
|
| 313 | return 0;
|
| 314 | }
|
| 315 | }
|
| 316 |
|
| 317 | return original;
|
| 318 | }
|
| 319 |
|
| 320 | @ModifyReceiver(
|
| 321 | method = "startAttack",
|
| 322 | at = @At(
|
| 323 | value = "INVOKE",
|
| 324 | target = "Lnet/minecraft/world/item/component/AttackRange;isInRange(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/phys/Vec3;)Z"
|
| 325 | )
|
| 326 | )
|
| 327 | private AttackRange injectReachAttackRange(AttackRange instance, LivingEntity entity, Vec3 pos) {
|
| 328 | if (ModuleReach.INSTANCE.getRunning()) {
|
| 329 | return ModuleReach.INSTANCE.getEntity().adjustAttackRange(instance);
|
| 330 | }
|
| 331 |
|
| 332 | return instance;
|
| 333 | }
|
| 334 |
|
| 335 | @WrapWithCondition(method = "startAttack", at = @At(value = "FIELD",
|
| 336 | target = "Lnet/minecraft/client/Minecraft;missTime:I", ordinal = 1, opcode = Opcodes.PUTFIELD))
|
| 337 | private boolean disableAttackCooldown(Minecraft instance, int value) {
|
| 338 | return !(ModuleNoMissCooldown.INSTANCE.getRunning() && ModuleNoMissCooldown.INSTANCE.getRemoveAttackCooldown());
|
| 339 | }
|
| 340 |
|
| 341 | @Inject(method = "startAttack", at = @At("HEAD"), cancellable = true)
|
| 342 | private void injectCombatPause(CallbackInfoReturnable<Boolean> cir) {
|
| 343 | if (player == null || hitResult == null || hitResult.getType() == HitResult.Type.MISS) {
|
| 344 | if (ModuleNoMissCooldown.INSTANCE.getRunning() && ModuleNoMissCooldown.INSTANCE.getCancelAttackOnMiss()) {
|
| 345 | // Prevent swinging
|
| 346 | cir.setReturnValue(true);
|
| 347 | }
|
| 348 | return;
|
| 349 | }
|
| 350 |
|
| 351 | if (CombatManager.INSTANCE.getShouldPauseCombat()) {
|
| 352 | cir.setReturnValue(false);
|
| 353 | }
|
| 354 | }
|
| 355 |
|
| 356 | @Inject(method = "updateLevelInEngines(Lnet/minecraft/client/multiplayer/ClientLevel;Z)V", at = @At("HEAD"))
|
| 357 | private void hookWorldChangeEvent(ClientLevel world, boolean bl, CallbackInfo ci) {
|
| 358 | EventManager.INSTANCE.callEvent(new WorldChangeEvent(world));
|
| 359 | }
|
| 360 |
|
| 361 | @Inject(method = "renderFrame", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;fps:I",
|
| 362 | ordinal = 0, shift = At.Shift.AFTER, opcode = Opcodes.PUTSTATIC))
|
| 363 | private void hookFpsChange(CallbackInfo ci) {
|
| 364 | EventManager.INSTANCE.callEvent(new FpsChangeEvent(this.getFps()));
|
| 365 | }
|
| 366 |
|
| 367 | @Inject(method = "onResourceLoadFinished", at = @At("HEAD"))
|
| 368 | private void onFinishedLoading(CallbackInfo ci) {
|
| 369 | EventManager.INSTANCE.callEvent(ResourceReloadEvent.INSTANCE);
|
| 370 | }
|
| 371 |
|
| 372 | @ModifyExpressionValue(method = "continueAttack", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;isUsingItem()Z"))
|
| 373 | private boolean injectMultiActionsBreakingWhileUsing(boolean original) {
|
| 374 | return original && !ModuleMultiActions.mayBreakWhileUsing();
|
| 375 | }
|
| 376 |
|
| 377 | @ModifyExpressionValue(method = "startUseItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;isDestroying()Z"))
|
| 378 | private boolean injectMultiActionsPlacingWhileBreaking(boolean original) {
|
| 379 | return original && !ModuleMultiActions.mayPlaceWhileBreaking();
|
| 380 | }
|
| 381 |
|
| 382 | /**
|
| 383 | * Alternative input handler of [handleInputEvents] while being inside a client-side screen.
|
| 384 | */
|
| 385 | @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;screen()Lnet/minecraft/client/gui/screens/Screen;", ordinal = 1, shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILSOFT)
|
| 386 | private void passthroughInputHandler(CallbackInfo ci, @Local(name = "profiler") ProfilerFiller profiler) {
|
| 387 | if (this.gui.overlay() == null && this.player != null && this.level
|
| 388 | != null && ScreenManager.isClientScreen(this.gui.screen())) {
|
| 389 | profiler.popPush("Keybindings");
|
| 390 |
|
| 391 | if (ModuleAutoBreak.INSTANCE.getEnabled()) {
|
| 392 | this.continueAttack(this.options.keyAttack.isDown());
|
| 393 | }
|
| 394 | }
|
| 395 | }
|
| 396 |
|
| 397 | @ModifyExpressionValue(method = "handleKeybinds", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;isUsingItem()Z", ordinal = 0))
|
| 398 | private boolean injectMultiActionsAttackingWhileUsingAndEnforcedBlockingState(boolean isUsingItem) {
|
| 399 | if (isUsingItem) {
|
| 400 | if (!this.options.keyUse.isDown() && !(KillAuraAutoBlock.INSTANCE.getRunning() && KillAuraAutoBlock.INSTANCE.getEnforcedBlockingHand() != null)) {
|
| 401 | this.gameMode.releaseUsingItem(this.player);
|
| 402 | }
|
| 403 |
|
| 404 | if (!ModuleMultiActions.mayAttackWhileUsing()) {
|
| 405 | this.options.keyAttack.clickCount = 0;
|
| 406 | }
|
| 407 |
|
| 408 | this.options.keyPickItem.clickCount = 0;
|
| 409 | this.options.keyUse.clickCount = 0;
|
| 410 | }
|
| 411 |
|
| 412 | return false;
|
| 413 | }
|
| 414 |
|
| 415 | @WrapWithCondition(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;missTime:I", ordinal = 0, opcode = Opcodes.PUTFIELD))
|
| 416 | private boolean injectFixAttackCooldownOnVirtualBrowserScreen(Minecraft instance, int value) {
|
| 417 | // Do not reset attack cooldown when we are in the vr/browser screen, as this poses an
|
| 418 | // unintended modification to the attack cooldown, which is not intended.
|
| 419 | return !ScreenManager.isClientScreen(this.gui.screen());
|
| 420 | }
|
| 421 |
|
| 422 | @Inject(method = "clearDownloadedResourcePacks", at = @At("HEAD"))
|
| 423 | private void handleDisconnection(CallbackInfo ci) {
|
| 424 | EventManager.INSTANCE.callEvent(DisconnectEvent.INSTANCE);
|
| 425 | }
|
| 426 |
|
| 427 | @Inject(method = "startUseItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;useItemOn(Lnet/minecraft/client/player/LocalPlayer;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/phys/BlockHitResult;)Lnet/minecraft/world/InteractionResult;"), cancellable = true)
|
| 428 | private void hookBlockInteract(CallbackInfo ci) {
|
| 429 | final BlockHitResult blockHitResult = (BlockHitResult) this.hitResult;
|
| 430 | if (blockHitResult == null) return; // it should never be null
|
| 431 |
|
| 432 | if (ModuleNoBlockInteract.INSTANCE.getRunning() &&
|
| 433 | ModuleNoBlockInteract.INSTANCE.shouldSneak(blockHitResult)) {
|
| 434 |
|
| 435 | ModuleNoBlockInteract.INSTANCE.startSneaking();
|
| 436 | ci.cancel();
|
| 437 | }
|
| 438 | }
|
| 439 |
|
| 440 | @Inject(method = "renderFrame", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/CommandEncoder;submit()V", shift = At.Shift.BEFORE))
|
| 441 | private void endDynamicGpuBufferFrame(boolean advanceGameTime, CallbackInfo ci) {
|
| 442 | MeshDraw.DefaultUploader.endFrame();
|
| 443 | }
|
| 444 |
|
| 445 | @Inject(method = "renderFrame", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;endFrame()V", shift = At.Shift.AFTER))
|
| 446 | private void onFlipFrame(boolean advanceGameTime, CallbackInfo ci) {
|
| 447 | RenderingDebug.flipFrame();
|
| 448 | ClientTesselator.Shared.clear();
|
| 449 | StaticGpuBufferPool.cleanup();
|
| 450 | }
|
| 451 |
|
| 452 | @WrapOperation(method = "pick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;raycastHitResult(FLnet/minecraft/world/entity/Entity;)Lnet/minecraft/world/phys/HitResult;"))
|
| 453 | private HitResult updateTargetedEntityInvoke(LocalPlayer instance, float a, Entity cameraEntity, Operation<HitResult> original) {
|
| 454 | HitResult result;
|
| 455 | if (cameraEntity == instance && ModuleFreeCam.shouldCameraInteractActive()) {
|
| 456 | final Vec3 position = cameraEntity.position();
|
| 457 | final AABB boundingBox = cameraEntity.getBoundingBox();
|
| 458 | final Vec3 lastPosition = new Vec3(cameraEntity.xo, cameraEntity.yo, cameraEntity.zo);
|
| 459 | final float yRot = cameraEntity.getYRot();
|
| 460 | final float xRot = cameraEntity.getXRot();
|
| 461 | final float yRot0 = cameraEntity.yRotO;
|
| 462 | final float xRot0 = cameraEntity.xRotO;
|
| 463 |
|
| 464 | final Vec3 cameraPosition = ModuleFreeCam.PositionState.pos.subtract(0.0, cameraEntity.getEyeHeight(), 0.0);
|
| 465 | ((MixinEntityAccessor) cameraEntity).position(cameraPosition);
|
| 466 | cameraEntity.setBoundingBox(boundingBox.move(cameraPosition.subtract(position)));
|
| 467 | cameraEntity.xo = ModuleFreeCam.PositionState.lastPos.x;
|
| 468 | cameraEntity.yo = ModuleFreeCam.PositionState.lastPos.y - cameraEntity.getEyeHeight();
|
| 469 | cameraEntity.zo = ModuleFreeCam.PositionState.lastPos.z;
|
| 470 | ((MixinEntityAccessor) cameraEntity).yRot(ModuleFreeCam.PositionState.rot.yRot());
|
| 471 | ((MixinEntityAccessor) cameraEntity).xRot(ModuleFreeCam.PositionState.rot.xRot());
|
| 472 | cameraEntity.yRotO = ModuleFreeCam.PositionState.lastRot.yRot();
|
| 473 | cameraEntity.xRotO = ModuleFreeCam.PositionState.lastRot.xRot();
|
| 474 |
|
| 475 | try {
|
| 476 | result = original.call(instance, a, cameraEntity);
|
| 477 | } finally {
|
| 478 | ((MixinEntityAccessor) cameraEntity).position(position);
|
| 479 | cameraEntity.setBoundingBox(boundingBox);
|
| 480 | cameraEntity.xo = lastPosition.x;
|
| 481 | cameraEntity.yo = lastPosition.y;
|
| 482 | cameraEntity.zo = lastPosition.z;
|
| 483 | ((MixinEntityAccessor) cameraEntity).yRot(yRot);
|
| 484 | ((MixinEntityAccessor) cameraEntity).xRot(xRot);
|
| 485 | cameraEntity.yRotO = yRot0;
|
| 486 | cameraEntity.xRotO = xRot0;
|
| 487 | }
|
| 488 | } else {
|
| 489 | result = original.call(instance, a, cameraEntity);
|
| 490 | }
|
| 491 |
|
| 492 | return result;
|
| 493 | }
|
| 494 | }
|
| 495 |
|