| 1 | package thunder.hack.injection;
|
| 2 |
|
| 3 | import org.spongepowered.asm.mixin.Mixin;
|
| 4 | import org.spongepowered.asm.mixin.Shadow;
|
| 5 | import org.spongepowered.asm.mixin.Unique;
|
| 6 | import org.spongepowered.asm.mixin.injection.At;
|
| 7 | import org.spongepowered.asm.mixin.injection.Inject;
|
| 8 | import org.spongepowered.asm.mixin.injection.ModifyArgs;
|
| 9 | import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
| 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
| 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
| 12 | import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
|
| 13 | import thunder.hack.ThunderHack;
|
| 14 | import thunder.hack.core.manager.client.ModuleManager;
|
| 15 | import thunder.hack.events.impl.EventFixVelocity;
|
| 16 | import thunder.hack.features.modules.Module;
|
| 17 | import thunder.hack.features.modules.combat.Aura;
|
| 18 | import thunder.hack.features.modules.combat.HitBox;
|
| 19 | import thunder.hack.features.modules.render.Shaders;
|
| 20 | import thunder.hack.features.modules.render.Trails;
|
| 21 | import thunder.hack.utility.interfaces.IEntity;
|
| 22 | import thunder.hack.utility.interfaces.IEntityLiving;
|
| 23 |
|
| 24 | import java.util.ArrayList;
|
| 25 | import java.util.List;
|
| 26 | import net.minecraft.core.BlockPos;
|
| 27 | import net.minecraft.util.Mth;
|
| 28 | import net.minecraft.world.entity.Entity;
|
| 29 | import net.minecraft.world.entity.player.Player;
|
| 30 | import net.minecraft.world.phys.AABB;
|
| 31 | import net.minecraft.world.phys.Vec3;
|
| 32 |
|
| 33 | import static thunder.hack.features.modules.Module.mc;
|
| 34 |
|
| 35 | @Mixin(Entity.class)
|
| 36 | public abstract class MixinEntity implements IEntity, IEntityLiving {
|
| 37 |
|
| 38 | @Shadow
|
| 39 | protected abstract BlockPos getBlockPosBelowThatAffectsMyMovement();
|
| 40 |
|
| 41 | @Shadow
|
| 42 | public abstract Vec3 trackingPosition();
|
| 43 |
|
| 44 | @Shadow
|
| 45 | private AABB bb;
|
| 46 |
|
| 47 | @Override
|
| 48 | public List<Trails.Trail> getTrails() {
|
| 49 | return trails;
|
| 50 | }
|
| 51 |
|
| 52 | @Override
|
| 53 | public BlockPos thunderHack_Recode$getVelocityBP() {
|
| 54 | return getBlockPosBelowThatAffectsMyMovement();
|
| 55 | }
|
| 56 |
|
| 57 | @Unique
|
| 58 | public List<Trails.Trail> trails = new ArrayList<>();
|
| 59 |
|
| 60 | @Unique
|
| 61 | double prevServerX, prevServerY, prevServerZ;
|
| 62 |
|
| 63 | @Unique
|
| 64 | public List<Aura.Position> positonHistory = new ArrayList<>();
|
| 65 |
|
| 66 | @Override
|
| 67 | public List<Aura.Position> getPositionHistory() {
|
| 68 | return positonHistory;
|
| 69 | }
|
| 70 |
|
| 71 | @Inject(method = {"moveOrInterpolateTo"}, at = {@At("HEAD")})
|
| 72 | private void updateTrackedPositionAndAnglesHook(Vec3 pos, float yaw, float pitch, CallbackInfo ci) {
|
| 73 | if (Module.fullNullCheck()) return;
|
| 74 | Vec3 syncedPos = trackingPosition();
|
| 75 | prevServerX = syncedPos.x;
|
| 76 | prevServerY = syncedPos.y;
|
| 77 | prevServerZ = syncedPos.z;
|
| 78 | positonHistory.add(new Aura.Position(syncedPos.x, syncedPos.y, syncedPos.z));
|
| 79 | positonHistory.removeIf(Aura.Position::shouldRemove);
|
| 80 | }
|
| 81 |
|
| 82 | @Override
|
| 83 | public double getPrevServerX() {
|
| 84 | return prevServerX;
|
| 85 | }
|
| 86 |
|
| 87 | @Override
|
| 88 | public double getPrevServerY() {
|
| 89 | return prevServerY;
|
| 90 | }
|
| 91 |
|
| 92 | @Override
|
| 93 | public double getPrevServerZ() {
|
| 94 | return prevServerZ;
|
| 95 | }
|
| 96 |
|
| 97 | @ModifyArgs(method = "push(Lnet/minecraft/world/entity/Entity;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;push(DDD)V"))
|
| 98 | public void pushAwayFromHook(Args args) {
|
| 99 |
|
| 100 | //Condition '...' is always 'false' is a lie!!! do not delete
|
| 101 | if ((Object) this == mc.player && ModuleManager.noPush.isEnabled() && ModuleManager.noPush.players.getValue()) {
|
| 102 | args.set(0, 0.);
|
| 103 | args.set(1, 0.);
|
| 104 | args.set(2, 0.);
|
| 105 | }
|
| 106 | }
|
| 107 |
|
| 108 | @Inject(method = "moveRelative", at = {@At("HEAD")}, cancellable = true)
|
| 109 | public void updateVelocityHook(float speed, Vec3 movementInput, CallbackInfo ci) {
|
| 110 | if(Module.fullNullCheck()) return;
|
| 111 | if ((Object) this == mc.player) {
|
| 112 | Vec3 vanillaVelocity = movementInputToVelocityC(movementInput, speed, mc.player.getYRot());
|
| 113 | EventFixVelocity event = new EventFixVelocity(movementInput, speed, mc.player.getYRot(), vanillaVelocity);
|
| 114 | ThunderHack.EVENT_BUS.post(event);
|
| 115 |
|
| 116 | // Keep Minecraft's own movement path unless a module actually changed the
|
| 117 | // velocity. Reimplementing moveRelative globally makes vanilla movement
|
| 118 | // sensitive to mapping and behavior changes between game versions.
|
| 119 | if (!event.getVelocity().equals(vanillaVelocity)) {
|
| 120 | ci.cancel();
|
| 121 | mc.player.setDeltaMovement(mc.player.getDeltaMovement().add(event.getVelocity()));
|
| 122 | }
|
| 123 | }
|
| 124 | }
|
| 125 |
|
| 126 | @Unique
|
| 127 | private static Vec3 movementInputToVelocityC(Vec3 movementInput, float speed, float yaw) {
|
| 128 | double d = movementInput.lengthSqr();
|
| 129 | if (d < 1.0E-7) {
|
| 130 | return Vec3.ZERO;
|
| 131 | }
|
| 132 | Vec3 vec3d = (d > 1.0 ? movementInput.normalize() : movementInput).scale(speed);
|
| 133 | float f = Mth.sin(yaw * ((float) Math.PI / 180));
|
| 134 | float g = Mth.cos(yaw * ((float) Math.PI / 180));
|
| 135 | return new Vec3(vec3d.x * (double) g - vec3d.z * (double) f, vec3d.y, vec3d.z * (double) g + vec3d.x * (double) f);
|
| 136 | }
|
| 137 |
|
| 138 | @Inject(method = "getBoundingBox", at = {@At("HEAD")}, cancellable = true)
|
| 139 | public final void getBoundingBox(CallbackInfoReturnable<AABB> cir) {
|
| 140 | if (ModuleManager.hitBox.isEnabled() && mc != null && mc.player != null && ((Entity) (Object) this).getId() != mc.player.getId() && (ModuleManager.aura.isDisabled() || HitBox.affectToAura.getValue())) {
|
| 141 | cir.setReturnValue(new AABB(this.bb.minX - HitBox.XZExpand.getValue() / 2f, this.bb.minY - HitBox.YExpand.getValue() / 2f, this.bb.minZ - HitBox.XZExpand.getValue() / 2f, this.bb.maxX + HitBox.XZExpand.getValue() / 2f, this.bb.maxY + HitBox.YExpand.getValue() / 2f, this.bb.maxZ + HitBox.XZExpand.getValue() / 2f));
|
| 142 | }
|
| 143 | }
|
| 144 |
|
| 145 | @Inject(method = "isCurrentlyGlowing", at = @At("HEAD"), cancellable = true)
|
| 146 | public void isGlowingHook(CallbackInfoReturnable<Boolean> cir) {
|
| 147 | Shaders shaders = ModuleManager.shaders;
|
| 148 | if (shaders.isEnabled()) {
|
| 149 | cir.setReturnValue(shaders.shouldRender((Entity) (Object) this));
|
| 150 | }
|
| 151 | }
|
| 152 |
|
| 153 | @Inject(method = "isOnFire", at = @At("HEAD"), cancellable = true)
|
| 154 | public void isOnFireHook(CallbackInfoReturnable<Boolean> cir) {
|
| 155 | if (ModuleManager.noRender.isEnabled() && ModuleManager.noRender.fireEntity.getValue()) {
|
| 156 | cir.setReturnValue(false);
|
| 157 | }
|
| 158 | }
|
| 159 |
|
| 160 | @Inject(method = "isInvisibleTo", at = @At("HEAD"), cancellable = true)
|
| 161 | public void isInvisibleToHook(Player player, CallbackInfoReturnable<Boolean> cir) {
|
| 162 | if (ModuleManager.serverHelper.isEnabled() && ModuleManager.serverHelper.trueSight.getValue()) {
|
| 163 | cir.setReturnValue(false);
|
| 164 | }
|
| 165 | }
|
| 166 |
|
| 167 | @Inject(method = "isInLava", at = @At("HEAD"), cancellable = true)
|
| 168 | public void isInLavaHook(CallbackInfoReturnable<Boolean> cir) {
|
| 169 | if((ModuleManager.jesus.isEnabled() || ModuleManager.noWaterCollision.isEnabled()) && mc.player != null && ((Entity) (Object) this).getId() == mc.player.getId())
|
| 170 | cir.setReturnValue(false);
|
| 171 | }
|
| 172 |
|
| 173 | @Inject(method = "isInWater", at = @At("HEAD"), cancellable = true)
|
| 174 | public void isTouchingWaterHook(CallbackInfoReturnable<Boolean> cir) {
|
| 175 | if((ModuleManager.jesus.isEnabled() || ModuleManager.noWaterCollision.isEnabled()) && mc.player != null && ((Entity) (Object) this).getId() == mc.player.getId())
|
| 176 | cir.setReturnValue(false);
|
| 177 | }
|
| 178 |
|
| 179 | @Inject(method = "setSwimming", at = @At("HEAD"), cancellable = true)
|
| 180 | public void setSwimmingHook(boolean swimming, CallbackInfo ci) {
|
| 181 | if((ModuleManager.jesus.isEnabled() || ModuleManager.noWaterCollision.isEnabled()) && swimming && mc.player != null && ((Entity) (Object) this).getId() == mc.player.getId())
|
| 182 | ci.cancel();
|
| 183 | }
|
| 184 |
|
| 185 | @ModifyVariable(method = "turn", at = @At("HEAD"), ordinal = 0, argsOnly = true)
|
| 186 | private double changeLookDirectionHook0(double value) {
|
| 187 | if(ModuleManager.viewLock.isEnabled() && ModuleManager.viewLock.yaw.getValue())
|
| 188 | return 0d;
|
| 189 | return value;
|
| 190 | }
|
| 191 |
|
| 192 | @ModifyVariable(method = "turn", at = @At("HEAD"), ordinal = 1, argsOnly = true)
|
| 193 | private double changeLookDirectionHook1(double value) {
|
| 194 | if(ModuleManager.viewLock.isEnabled() && ModuleManager.viewLock.pitch.getValue())
|
| 195 | return 0d;
|
| 196 | return value;
|
| 197 | }
|
| 198 | }
|