| 1 | package thunder.hack.injection;
|
| 2 |
|
| 3 | import com.mojang.authlib.GameProfile;
|
| 4 | import net.minecraft.client.multiplayer.ClientLevel;
|
| 5 | import net.minecraft.client.player.AbstractClientPlayer;
|
| 6 | import net.minecraft.client.player.LocalPlayer;
|
| 7 | import net.minecraft.network.protocol.game.ServerboundPlayerCommandPacket;
|
| 8 | import net.minecraft.world.entity.MoverType;
|
| 9 | import net.minecraft.world.phys.Vec3;
|
| 10 | import org.spongepowered.asm.mixin.Mixin;
|
| 11 | import org.spongepowered.asm.mixin.Shadow;
|
| 12 | import org.spongepowered.asm.mixin.Unique;
|
| 13 | import org.spongepowered.asm.mixin.injection.At;
|
| 14 | import org.spongepowered.asm.mixin.injection.Inject;
|
| 15 | import org.spongepowered.asm.mixin.injection.Redirect;
|
| 16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
| 17 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
| 18 | import thunder.hack.ThunderHack;
|
| 19 | import thunder.hack.core.Core;
|
| 20 | import thunder.hack.core.manager.client.ModuleManager;
|
| 21 | import thunder.hack.events.impl.*;
|
| 22 | import thunder.hack.features.modules.Module;
|
| 23 |
|
| 24 | import static thunder.hack.features.modules.Module.fullNullCheck;
|
| 25 | import static thunder.hack.features.modules.Module.mc;
|
| 26 |
|
| 27 | @Mixin(value = LocalPlayer.class, priority = 800)
|
| 28 | public abstract class MixinClientPlayerEntity extends AbstractClientPlayer {
|
| 29 | @Unique
|
| 30 | boolean pre_sprint_state = false;
|
| 31 | @Unique
|
| 32 | private boolean updateLock = false;
|
| 33 | @Unique
|
| 34 | private Runnable postAction;
|
| 35 |
|
| 36 | @Shadow
|
| 37 | public abstract float getViewXRot(float tickDelta);
|
| 38 | @Shadow
|
| 39 | protected abstract void sendPosition();
|
| 40 |
|
| 41 | public MixinClientPlayerEntity(ClientLevel world, GameProfile profile) {
|
| 42 | super(world, profile);
|
| 43 | }
|
| 44 |
|
| 45 | @Inject(method = "tick", at = @At("HEAD"))
|
| 46 | public void tickHook(CallbackInfo info) {
|
| 47 | if(Module.fullNullCheck()) return;
|
| 48 | ThunderHack.EVENT_BUS.post(new PlayerUpdateEvent());
|
| 49 | }
|
| 50 |
|
| 51 | @Redirect(method = "aiStep", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;isUsingItem()Z"), require = 0)
|
| 52 | private boolean tickMovementHook(LocalPlayer player) {
|
| 53 | if (ModuleManager.noSlow.isEnabled() && ModuleManager.noSlow.canNoSlow())
|
| 54 | return false;
|
| 55 | return player.isUsingItem();
|
| 56 | }
|
| 57 |
|
| 58 | @Inject(method = "isMovingSlowly", at = @At("HEAD"), cancellable = true)
|
| 59 | public void shouldSlowDownHook(CallbackInfoReturnable<Boolean> cir) {
|
| 60 | if(ModuleManager.noSlow.isEnabled()) {
|
| 61 | if (isVisuallyCrawling()) {
|
| 62 | if (ModuleManager.noSlow.crawl.getValue())
|
| 63 | cir.setReturnValue(false);
|
| 64 | } else {
|
| 65 | if (ModuleManager.noSlow.sneak.getValue())
|
| 66 | cir.setReturnValue(false);
|
| 67 | }
|
| 68 | }
|
| 69 | }
|
| 70 |
|
| 71 | @Inject(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/AbstractClientPlayer;move(Lnet/minecraft/world/entity/MoverType;Lnet/minecraft/world/phys/Vec3;)V"), cancellable = true)
|
| 72 | public void onMoveHook(MoverType movementType, Vec3 movement, CallbackInfo ci) {
|
| 73 | if(Module.fullNullCheck()) return;
|
| 74 | EventMove event = new EventMove(movement.x, movement.y, movement.z);
|
| 75 | ThunderHack.EVENT_BUS.post(event);
|
| 76 | if (event.isCancelled()) {
|
| 77 | super.move(movementType, new Vec3(event.getX(), event.getY(), event.getZ()));
|
| 78 | ci.cancel();
|
| 79 | }
|
| 80 | }
|
| 81 |
|
| 82 | @Inject(method = "sendPosition", at = @At("HEAD"), cancellable = true)
|
| 83 | private void sendMovementPacketsHook(CallbackInfo info) {
|
| 84 | if (fullNullCheck()) return;
|
| 85 | EventSync event = new EventSync(getYRot(), getXRot());
|
| 86 | ThunderHack.EVENT_BUS.post(event);
|
| 87 | postAction = event.getPostAction();
|
| 88 | EventSprint e = new EventSprint(isSprinting());
|
| 89 | ThunderHack.EVENT_BUS.post(e);
|
| 90 | ThunderHack.EVENT_BUS.post(new EventAfterRotate());
|
| 91 | if (e.getSprintState() != mc.player.wasSprinting) {
|
| 92 | if (e.getSprintState())
|
| 93 | mc.player.connection.send(new ServerboundPlayerCommandPacket(this, ServerboundPlayerCommandPacket.Action.START_SPRINTING));
|
| 94 | else
|
| 95 | mc.player.connection.send(new ServerboundPlayerCommandPacket(this, ServerboundPlayerCommandPacket.Action.STOP_SPRINTING));
|
| 96 |
|
| 97 | mc.player.wasSprinting = e.getSprintState();
|
| 98 | }
|
| 99 | pre_sprint_state = mc.player.wasSprinting;
|
| 100 | Core.lockSprint = true;
|
| 101 |
|
| 102 | if (event.isCancelled()) info.cancel();
|
| 103 | }
|
| 104 |
|
| 105 | @Inject(method = "sendPosition", at = @At("RETURN"), cancellable = true)
|
| 106 | private void sendMovementPacketsPostHook(CallbackInfo info) {
|
| 107 | if (fullNullCheck()) return;
|
| 108 | mc.player.wasSprinting = pre_sprint_state;
|
| 109 | Core.lockSprint = false;
|
| 110 | EventPostSync event = new EventPostSync();
|
| 111 | ThunderHack.EVENT_BUS.post(event);
|
| 112 | if(postAction != null) {
|
| 113 | postAction.run();
|
| 114 | postAction = null;
|
| 115 | }
|
| 116 | if (event.isCancelled())
|
| 117 | info.cancel();
|
| 118 | }
|
| 119 |
|
| 120 | @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;sendPosition()V", ordinal = 0, shift = At.Shift.AFTER), cancellable = true)
|
| 121 | private void PostUpdateHook(CallbackInfo info) {
|
| 122 | if(Module.fullNullCheck()) return;
|
| 123 | if (updateLock) {
|
| 124 | return;
|
| 125 | }
|
| 126 | PostPlayerUpdateEvent playerUpdateEvent = new PostPlayerUpdateEvent();
|
| 127 | ThunderHack.EVENT_BUS.post(playerUpdateEvent);
|
| 128 | if (playerUpdateEvent.isCancelled()) {
|
| 129 | info.cancel();
|
| 130 | if (playerUpdateEvent.getIterations() > 0) {
|
| 131 | for (int i = 0; i < playerUpdateEvent.getIterations(); i++) {
|
| 132 | updateLock = true;
|
| 133 | tick();
|
| 134 | updateLock = false;
|
| 135 | sendPosition();
|
| 136 | }
|
| 137 | }
|
| 138 | }
|
| 139 | }
|
| 140 |
|
| 141 | @Inject(method = "moveTowardsClosestSpace", at = @At("HEAD"), cancellable = true)
|
| 142 | private void onPushOutOfBlocksHook(double x, double d, CallbackInfo info) {
|
| 143 | if (ModuleManager.noPush.isEnabled() && ModuleManager.noPush.blocks.getValue()) {
|
| 144 | info.cancel();
|
| 145 | }
|
| 146 | }
|
| 147 |
|
| 148 | @Inject(method = "handlePortalTransitionEffect", at = @At("HEAD"), cancellable = true)
|
| 149 | private void updateNauseaHook(CallbackInfo ci) {
|
| 150 | if(ModuleManager.portalInventory.isEnabled())
|
| 151 | ci.cancel();
|
| 152 | }
|
| 153 | }
|
| 154 |
|