From 37c5c5c640ba9c66721e824c62e84bf1223c9cd6 Mon Sep 17 00:00:00 2001 From: Wide_Cat Date: Thu, 7 Nov 2024 18:49:24 +0000 Subject: [PATCH] please actually test the code next time :bruh: --- .../meteorclient/mixin/GameRendererMixin.java | 12 ++++++----- .../mixin/baritone/ComeCommandMixin.java | 2 +- .../systems/modules/player/NoMiningTrace.java | 20 +++++++------------ 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/GameRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/GameRendererMixin.java index 878a5722a9..b15a3271d6 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/GameRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/GameRendererMixin.java @@ -6,6 +6,7 @@ package meteordevelopment.meteorclient.mixin; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.injector.ModifyReturnValue; import com.llamalad7.mixinextras.sugar.Local; import com.mojang.blaze3d.systems.RenderSystem; import meteordevelopment.meteorclient.MeteorClient; @@ -32,6 +33,7 @@ import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.util.hit.EntityHitResult; import net.minecraft.util.hit.HitResult; import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Final; @@ -42,7 +44,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(GameRenderer.class) @@ -122,11 +123,12 @@ private void onRenderWorldTail(CallbackInfo info) { MeteorClient.EVENT_BUS.post(RenderAfterWorldEvent.get()); } - @Inject(method = "findCrosshairTarget", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/projectile/ProjectileUtil;raycast(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/util/math/Box;Ljava/util/function/Predicate;D)Lnet/minecraft/util/hit/EntityHitResult;"), cancellable = true) - private void onUpdateTargetedEntity(Entity camera, double blockInteractionRange, double entityInteractionRange, float tickDelta, CallbackInfoReturnable cir, @Local HitResult hitResult) { - if (Modules.get().get(NoMiningTrace.class).canWork() && hitResult.getType() == HitResult.Type.BLOCK) { - cir.setReturnValue(hitResult); + @ModifyReturnValue(method = "findCrosshairTarget", at = @At("RETURN")) + private HitResult onUpdateTargetedEntity(HitResult original, @Local HitResult hitResult) { + if (Modules.get().get(NoMiningTrace.class).canWork(original instanceof EntityHitResult ehr ? ehr.getEntity() : null) && hitResult.getType() == HitResult.Type.BLOCK) { + return hitResult; } + return original; } @Redirect(method = "findCrosshairTarget", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;raycast(DFZ)Lnet/minecraft/util/hit/HitResult;")) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/baritone/ComeCommandMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/baritone/ComeCommandMixin.java index e4e1cca4c3..5ab05b9761 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/baritone/ComeCommandMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/baritone/ComeCommandMixin.java @@ -22,7 +22,7 @@ public abstract class ComeCommandMixin { private void getComeCommandTarget(Args args) { Freecam freecam = Modules.get().get(Freecam.class); if (freecam.isActive()) { - float tickDelta = mc.getRenderTickCounter().getTickDelta(true); // todo unsure if true or false + float tickDelta = mc.getRenderTickCounter().getTickDelta(true); args.set(0, new GoalBlock((int) freecam.getX(tickDelta), (int) freecam.getY(tickDelta), (int) freecam.getZ(tickDelta))); } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/NoMiningTrace.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/NoMiningTrace.java index 110be83ca8..78bc1ac09a 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/NoMiningTrace.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/NoMiningTrace.java @@ -5,28 +5,28 @@ package meteordevelopment.meteorclient.systems.modules.player; -import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.EntityTypeListSetting; import meteordevelopment.meteorclient.settings.Setting; import meteordevelopment.meteorclient.settings.SettingGroup; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; -import meteordevelopment.orbit.EventHandler; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.item.PickaxeItem; import java.util.Set; + public class NoMiningTrace extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final Setting>> entities = sgGeneral.add(new EntityTypeListSetting.Builder() - .name("entities") - .description("Entity blacklist") + .name("blacklisted-entities") + .description("Entities you will interact with as normal.") .defaultValue() .build() ); + private final Setting onlyWhenHoldingPickaxe = sgGeneral.add(new BoolSetting.Builder() .name("only-when-holding-a-pickaxe") .description("Whether or not to work only when holding a pickaxe.") @@ -38,16 +38,10 @@ public NoMiningTrace() { super(Categories.Player, "no-mining-trace", "Allows you to mine blocks through entities."); } - public boolean canWork() { + public boolean canWork(Entity entity) { if (!isActive()) return false; - if (onlyWhenHoldingPickaxe.get()) { - return mc.player.getMainHandStack().getItem() instanceof PickaxeItem || mc.player.getOffHandStack().getItem() instanceof PickaxeItem; - } - - Entity target = mc.targetedEntity; - if (target == null) return false; - if (entities.get().contains(target.getType())) return false; - return true; + return (!onlyWhenHoldingPickaxe.get() || mc.player.getMainHandStack().getItem() instanceof PickaxeItem || mc.player.getOffHandStack().getItem() instanceof PickaxeItem) && + (entity == null || !entities.get().contains(entity.getType())); } }