diff --git a/src/main/java/net/wurstclient/hacks/RemoteViewHack.java b/src/main/java/net/wurstclient/hacks/RemoteViewHack.java index f47320c48d..820638faeb 100644 --- a/src/main/java/net/wurstclient/hacks/RemoteViewHack.java +++ b/src/main/java/net/wurstclient/hacks/RemoteViewHack.java @@ -77,7 +77,7 @@ public void onEnable() } // save old data - wasInvisible = entity.isInvisibleTo(MC.player); + wasInvisible = entity.isInvisible(); // enable NoClip MC.player.noClip = true; diff --git a/src/main/java/net/wurstclient/hacks/TriggerBotHack.java b/src/main/java/net/wurstclient/hacks/TriggerBotHack.java index 593bf149c7..c41ad527cd 100644 --- a/src/main/java/net/wurstclient/hacks/TriggerBotHack.java +++ b/src/main/java/net/wurstclient/hacks/TriggerBotHack.java @@ -7,8 +7,6 @@ */ package net.wurstclient.hacks; -import java.util.stream.Stream; - import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.entity.Entity; @@ -110,14 +108,12 @@ public void onUpdate() private boolean isCorrectEntity(Entity entity) { - Stream stream = Stream.of(entity); - stream = stream.filter(EntityUtils.IS_ATTACKABLE); - - double rangeSq = Math.pow(range.getValue(), 2); - stream = stream.filter(e -> MC.player.squaredDistanceTo(e) <= rangeSq); + if(!EntityUtils.IS_ATTACKABLE.test(entity)) + return false; - stream = entityFilters.applyTo(stream); + if(MC.player.squaredDistanceTo(entity) > range.getValueSq()) + return false; - return stream.findFirst().isPresent(); + return entityFilters.testOne(entity); } } diff --git a/src/main/java/net/wurstclient/hacks/TrueSightHack.java b/src/main/java/net/wurstclient/hacks/TrueSightHack.java index e0cb640782..485e117387 100644 --- a/src/main/java/net/wurstclient/hacks/TrueSightHack.java +++ b/src/main/java/net/wurstclient/hacks/TrueSightHack.java @@ -7,6 +7,7 @@ */ package net.wurstclient.hacks; +import net.minecraft.entity.Entity; import net.wurstclient.Category; import net.wurstclient.SearchTags; import net.wurstclient.hack.Hack; @@ -20,5 +21,10 @@ public TrueSightHack() setCategory(Category.RENDER); } - // See LivingEntityRendererMixin + public boolean shouldBeVisible(Entity entity) + { + return isEnabled(); + } + + // See EntityMixin.onIsInvisibleTo() } diff --git a/src/main/java/net/wurstclient/hacks/treebot/TreeBotUtils.java b/src/main/java/net/wurstclient/hacks/treebot/TreeBotUtils.java index 688559ca9e..fa1cf19f82 100644 --- a/src/main/java/net/wurstclient/hacks/treebot/TreeBotUtils.java +++ b/src/main/java/net/wurstclient/hacks/treebot/TreeBotUtils.java @@ -7,11 +7,8 @@ */ package net.wurstclient.hacks.treebot; -import java.util.Arrays; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; +import net.minecraft.block.BlockState; +import net.minecraft.registry.tag.BlockTags; import net.minecraft.util.math.BlockPos; import net.wurstclient.util.BlockUtils; @@ -19,21 +16,15 @@ public enum TreeBotUtils { ; - private static final List LOG_BLOCKS = - Arrays.asList(Blocks.OAK_LOG, Blocks.SPRUCE_LOG, Blocks.BIRCH_LOG, - Blocks.JUNGLE_LOG, Blocks.ACACIA_LOG, Blocks.DARK_OAK_LOG); - - private static final List LEAVES_BLOCKS = Arrays.asList( - Blocks.OAK_LEAVES, Blocks.SPRUCE_LEAVES, Blocks.BIRCH_LEAVES, - Blocks.JUNGLE_LEAVES, Blocks.ACACIA_LEAVES, Blocks.DARK_OAK_LEAVES); - public static boolean isLog(BlockPos pos) { - return LOG_BLOCKS.contains(BlockUtils.getBlock(pos)); + return BlockUtils.getState(pos).isIn(BlockTags.LOGS); } public static boolean isLeaves(BlockPos pos) { - return LEAVES_BLOCKS.contains(BlockUtils.getBlock(pos)); + BlockState state = BlockUtils.getState(pos); + return state.isIn(BlockTags.LEAVES) + || state.isIn(BlockTags.WART_BLOCKS); } } diff --git a/src/main/java/net/wurstclient/mixin/EntityMixin.java b/src/main/java/net/wurstclient/mixin/EntityMixin.java index 1640bac450..ef0d9d9cd4 100644 --- a/src/main/java/net/wurstclient/mixin/EntityMixin.java +++ b/src/main/java/net/wurstclient/mixin/EntityMixin.java @@ -13,12 +13,15 @@ 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 net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.command.CommandOutput; import net.minecraft.util.Nameable; import net.minecraft.util.math.Vec3d; import net.minecraft.world.entity.EntityLike; +import net.wurstclient.WurstClient; import net.wurstclient.event.EventManager; import net.wurstclient.events.VelocityFromEntityCollisionListener.VelocityFromEntityCollisionEvent; import net.wurstclient.events.VelocityFromFluidListener.VelocityFromFluidEvent; @@ -53,4 +56,22 @@ private void onPushAwayFrom(Entity entity, CallbackInfo ci) if(event.isCancelled()) ci.cancel(); } + + /** + * Makes invisible entities render as ghosts if TrueSight is enabled. + */ + @Inject(at = @At("RETURN"), + method = "Lnet/minecraft/entity/Entity;isInvisibleTo(Lnet/minecraft/entity/player/PlayerEntity;)Z", + cancellable = true) + private void onIsInvisibleTo(PlayerEntity player, + CallbackInfoReturnable cir) + { + // Return early if the entity is not invisible + if(!cir.getReturnValueZ()) + return; + + if(WurstClient.INSTANCE.getHax().trueSightHack + .shouldBeVisible((Entity)(Object)this)) + cir.setReturnValue(false); + } } diff --git a/src/main/java/net/wurstclient/mixin/LivingEntityRendererMixin.java b/src/main/java/net/wurstclient/mixin/LivingEntityRendererMixin.java index 2b9decf22c..86e5b45e04 100644 --- a/src/main/java/net/wurstclient/mixin/LivingEntityRendererMixin.java +++ b/src/main/java/net/wurstclient/mixin/LivingEntityRendererMixin.java @@ -17,27 +17,11 @@ import net.minecraft.client.render.entity.LivingEntityRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; import net.wurstclient.WurstClient; @Mixin(LivingEntityRenderer.class) public abstract class LivingEntityRendererMixin { - /** - * Makes invisible entities render as ghosts if TrueSight is enabled. - */ - @Redirect(at = @At(value = "INVOKE", - target = "Lnet/minecraft/entity/LivingEntity;isInvisibleTo(Lnet/minecraft/entity/player/PlayerEntity;)Z", - ordinal = 0), - method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V") - private boolean isInvisibleToWurst(LivingEntity e, PlayerEntity player) - { - if(WurstClient.INSTANCE.getHax().trueSightHack.isEnabled()) - return false; - - return e.isInvisibleTo(player); - } - /** * Disables the distance limit in hasLabel() if configured in NameTags. */ diff --git a/src/main/java/net/wurstclient/settings/filterlists/EntityFilterList.java b/src/main/java/net/wurstclient/settings/filterlists/EntityFilterList.java index 3491fe30cc..e3c3d0ab11 100644 --- a/src/main/java/net/wurstclient/settings/filterlists/EntityFilterList.java +++ b/src/main/java/net/wurstclient/settings/filterlists/EntityFilterList.java @@ -50,6 +50,15 @@ public final Stream applyTo(Stream stream) return stream; } + public final boolean testOne(Entity entity) + { + for(EntityFilter filter : entityFilters) + if(filter.isFilterEnabled() && !filter.test(entity)) + return false; + + return true; + } + public static EntityFilterList genericCombat() { return new EntityFilterList(FilterPlayersSetting.genericCombat(false),