| 1 | /*
|
| 2 | * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
|
| 3 | * Copyright (c) Meteor Development.
|
| 4 | */
|
| 5 |
|
| 6 | package meteordevelopment.meteorclient.mixin;
|
| 7 |
|
| 8 | import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
| 9 | import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
| 10 | import meteordevelopment.meteorclient.MeteorClient;
|
| 11 | import meteordevelopment.meteorclient.events.entity.EntityMoveEvent;
|
| 12 | import meteordevelopment.meteorclient.events.entity.player.JumpVelocityMultiplierEvent;
|
| 13 | import meteordevelopment.meteorclient.events.entity.player.PlayerMoveEvent;
|
| 14 | import meteordevelopment.meteorclient.mixininterface.ICamera;
|
| 15 | import meteordevelopment.meteorclient.systems.modules.Modules;
|
| 16 | import meteordevelopment.meteorclient.systems.modules.combat.Hitboxes;
|
| 17 | import meteordevelopment.meteorclient.systems.modules.movement.*;
|
| 18 | import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.ElytraFly;
|
| 19 | import meteordevelopment.meteorclient.systems.modules.render.ESP;
|
| 20 | import meteordevelopment.meteorclient.systems.modules.render.FreeLook;
|
| 21 | import meteordevelopment.meteorclient.systems.modules.render.Freecam;
|
| 22 | import meteordevelopment.meteorclient.systems.modules.render.NoRender;
|
| 23 | import meteordevelopment.meteorclient.systems.modules.world.HighwayBuilder;
|
| 24 | import meteordevelopment.meteorclient.utils.Utils;
|
| 25 | import meteordevelopment.meteorclient.utils.entity.fakeplayer.FakePlayerEntity;
|
| 26 | import net.minecraft.client.Camera;
|
| 27 | import net.minecraft.world.entity.Entity;
|
| 28 | import net.minecraft.world.entity.MoverType;
|
| 29 | import net.minecraft.world.entity.Pose;
|
| 30 | import net.minecraft.world.entity.player.Player;
|
| 31 | import net.minecraft.world.level.block.Block;
|
| 32 | import net.minecraft.world.level.block.Blocks;
|
| 33 | import net.minecraft.world.phys.Vec3;
|
| 34 | import org.spongepowered.asm.mixin.Mixin;
|
| 35 | import org.spongepowered.asm.mixin.injection.At;
|
| 36 | import org.spongepowered.asm.mixin.injection.Inject;
|
| 37 | import org.spongepowered.asm.mixin.injection.ModifyArgs;
|
| 38 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
| 39 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
| 40 | import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
|
| 41 |
|
| 42 | import static meteordevelopment.meteorclient.MeteorClient.mc;
|
| 43 |
|
| 44 | @Mixin(Entity.class)
|
| 45 | public abstract class EntityMixin {
|
| 46 | @Inject(method = {"isInWater", "isInLava"}, at = @At("HEAD"), cancellable = true)
|
| 47 | private void onIsInFluid(CallbackInfoReturnable<Boolean> cir) {
|
| 48 | if ((Object) this != mc.player) return;
|
| 49 |
|
| 50 | Flight flight = Modules.get().get(Flight.class);
|
| 51 | NoSlow noSlow = Modules.get().get(NoSlow.class);
|
| 52 | if (flight.isActive() || noSlow.fluidDrag()) cir.setReturnValue(false);
|
| 53 | }
|
| 54 |
|
| 55 | @Inject(method = {"onAboveBubbleColumn", "onInsideBubbleColumn"}, at = @At("HEAD"))
|
| 56 | private void onBubbleColumn(CallbackInfo ci) {
|
| 57 | if ((Object) this != mc.player) return;
|
| 58 |
|
| 59 | Jesus jesus = Modules.get().get(Jesus.class);
|
| 60 | if (jesus.isActive()) {
|
| 61 | jesus.isInBubbleColumn = true;
|
| 62 | }
|
| 63 | }
|
| 64 |
|
| 65 | @ModifyExpressionValue(method = "updateSwimming", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;isUnderWater()Z"))
|
| 66 | private boolean isSubmergedInWater(boolean submerged) {
|
| 67 | if ((Object) this != mc.player) return submerged;
|
| 68 |
|
| 69 | if (Modules.get().get(NoSlow.class).fluidDrag()) return false;
|
| 70 | if (Modules.get().get(Flight.class).isActive()) return false;
|
| 71 | return submerged;
|
| 72 | }
|
| 73 |
|
| 74 | @ModifyArgs(method = "push(Lnet/minecraft/world/entity/Entity;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;push(DDD)V"))
|
| 75 | private void onPushAwayFrom(Args args, Entity entity) {
|
| 76 | Velocity velocity = Modules.get().get(Velocity.class);
|
| 77 |
|
| 78 | // Velocity
|
| 79 | if ((Object) this == mc.player && velocity.isActive() && velocity.entityPush.get()) {
|
| 80 | double multiplier = velocity.entityPushAmount.get();
|
| 81 | args.set(0, (double) args.get(0) * multiplier);
|
| 82 | args.set(2, (double) args.get(2) * multiplier);
|
| 83 | }
|
| 84 | // FakePlayerEntity
|
| 85 | else if (entity instanceof FakePlayerEntity player && player.doNotPush) {
|
| 86 | args.set(0, 0.0);
|
| 87 | args.set(2, 0.0);
|
| 88 | }
|
| 89 | }
|
| 90 |
|
| 91 | @ModifyReturnValue(method = "getBlockJumpFactor", at = @At("RETURN"))
|
| 92 | private float onGetBlockJumpFactor(float original) {
|
| 93 | if ((Object) this == mc.player) {
|
| 94 | JumpVelocityMultiplierEvent event = MeteorClient.EVENT_BUS.post(JumpVelocityMultiplierEvent.get());
|
| 95 | return (original * event.multiplier);
|
| 96 | }
|
| 97 |
|
| 98 | return original;
|
| 99 | }
|
| 100 |
|
| 101 | @Inject(method = "move", at = @At("HEAD"))
|
| 102 | private void onMove(MoverType moverType, Vec3 delta, CallbackInfo ci) {
|
| 103 | if ((Object) this == mc.player) {
|
| 104 | MeteorClient.EVENT_BUS.post(PlayerMoveEvent.get(moverType, delta));
|
| 105 | } else {
|
| 106 | MeteorClient.EVENT_BUS.post(EntityMoveEvent.get((Entity) (Object) this, delta));
|
| 107 | }
|
| 108 | }
|
| 109 |
|
| 110 | @ModifyExpressionValue(method = "getBlockSpeedFactor", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getBlock()Lnet/minecraft/world/level/block/Block;"))
|
| 111 | private Block modifyBlockSpeedFactor(Block original) {
|
| 112 | if ((Object) this != mc.player) return original;
|
| 113 |
|
| 114 | if (original == Blocks.SOUL_SAND && Modules.get().get(NoSlow.class).soulSand()) return Blocks.STONE;
|
| 115 | if (original == Blocks.HONEY_BLOCK && Modules.get().get(NoSlow.class).honeyBlock()) return Blocks.STONE;
|
| 116 | return original;
|
| 117 | }
|
| 118 |
|
| 119 | @ModifyReturnValue(method = "isInvisibleTo", at = @At("RETURN"))
|
| 120 | private boolean isInvisibleToCanceller(boolean original) {
|
| 121 | if (!Utils.canUpdate()) return original;
|
| 122 | ESP esp = Modules.get().get(ESP.class);
|
| 123 | if (Modules.get().get(NoRender.class).noInvisibility() || esp.isActive() && !esp.shouldSkip((Entity) (Object) this))
|
| 124 | return false;
|
| 125 | return original;
|
| 126 | }
|
| 127 |
|
| 128 | @Inject(method = "isCurrentlyGlowing", at = @At("HEAD"), cancellable = true)
|
| 129 | private void isCurrentlyGlowing(CallbackInfoReturnable<Boolean> cir) {
|
| 130 | if (Modules.get().get(NoRender.class).noGlowing()) cir.setReturnValue(false);
|
| 131 | }
|
| 132 |
|
| 133 | @Inject(method = "getPickRadius", at = @At("HEAD"), cancellable = true)
|
| 134 | private void onGetPickRadius(CallbackInfoReturnable<Float> cir) {
|
| 135 | double v = Modules.get().get(Hitboxes.class).getEntityValue((Entity) (Object) this);
|
| 136 | if (v != 0) cir.setReturnValue((float) v);
|
| 137 | }
|
| 138 |
|
| 139 | @Inject(method = "isInvisibleTo", at = @At("HEAD"), cancellable = true)
|
| 140 | private void onIsInvisibleTo(Player player, CallbackInfoReturnable<Boolean> cir) {
|
| 141 | if (player == null) cir.setReturnValue(false);
|
| 142 | }
|
| 143 |
|
| 144 | @Inject(method = "getPose", at = @At("HEAD"), cancellable = true)
|
| 145 | private void getPoseHook(CallbackInfoReturnable<Pose> cir) {
|
| 146 | if ((Object) this != mc.player) return;
|
| 147 |
|
| 148 | if (Modules.get().get(ElytraFly.class).canPacketEfly()) {
|
| 149 | cir.setReturnValue(Pose.FALL_FLYING);
|
| 150 | }
|
| 151 | }
|
| 152 |
|
| 153 | @ModifyReturnValue(method = "getPose", at = @At("RETURN"))
|
| 154 | private Pose modifyGetPose(Pose original) {
|
| 155 | if ((Object) this != mc.player) return original;
|
| 156 |
|
| 157 | if (original == Pose.CROUCHING && !mc.player.isShiftKeyDown() && ((PlayerAccessor) mc.player).meteor$canChangeIntoPose(Pose.STANDING))
|
| 158 | return Pose.STANDING;
|
| 159 | return original;
|
| 160 | }
|
| 161 |
|
| 162 | @ModifyReturnValue(method = "isSuppressingBounce", at = @At("RETURN"))
|
| 163 | private boolean cancelBounce(boolean original) {
|
| 164 | return Modules.get().get(NoFall.class).cancelBounce() || original;
|
| 165 | }
|
| 166 |
|
| 167 | @Inject(method = "turn", at = @At("HEAD"), cancellable = true)
|
| 168 | private void updateTurn(double xo, double yo, CallbackInfo ci) {
|
| 169 | if ((Object) this != mc.player) return;
|
| 170 |
|
| 171 | Freecam freecam = Modules.get().get(Freecam.class);
|
| 172 | FreeLook freeLook = Modules.get().get(FreeLook.class);
|
| 173 |
|
| 174 | if (freecam.isActive()) {
|
| 175 | freecam.changeLookDirection(xo * 0.15, yo * 0.15);
|
| 176 | ci.cancel();
|
| 177 | } else if (Modules.get().isActive(HighwayBuilder.class)) {
|
| 178 | Camera camera = mc.gameRenderer.mainCamera();
|
| 179 | ((ICamera) camera).meteor$setRot(camera.yRot() + xo * 0.15, camera.xRot() + yo * 0.15);
|
| 180 | ci.cancel();
|
| 181 | } else if (freeLook.cameraMode()) {
|
| 182 | freeLook.cameraYaw += (float) (xo / freeLook.sensitivity.get().floatValue());
|
| 183 | freeLook.cameraPitch += (float) (yo / freeLook.sensitivity.get().floatValue());
|
| 184 |
|
| 185 | if (Math.abs(freeLook.cameraPitch) > 90.0F)
|
| 186 | freeLook.cameraPitch = freeLook.cameraPitch > 0.0F ? 90.0F : -90.0F;
|
| 187 | ci.cancel();
|
| 188 | }
|
| 189 | }
|
| 190 | }
|
| 191 |
|