Skip to content

Commit

Permalink
Merge branch 'master' into korean_Description
Browse files Browse the repository at this point in the history
  • Loading branch information
JAXPLE authored Nov 4, 2023
2 parents dd0906e + d2f50ac commit c4e62cd
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/wurstclient/hacks/RemoteViewHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void onEnable()
}

// save old data
wasInvisible = entity.isInvisibleTo(MC.player);
wasInvisible = entity.isInvisible();

// enable NoClip
MC.player.noClip = true;
Expand Down
14 changes: 5 additions & 9 deletions src/main/java/net/wurstclient/hacks/TriggerBotHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -110,14 +108,12 @@ public void onUpdate()

private boolean isCorrectEntity(Entity entity)
{
Stream<Entity> 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);
}
}
8 changes: 7 additions & 1 deletion src/main/java/net/wurstclient/hacks/TrueSightHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,5 +21,10 @@ public TrueSightHack()
setCategory(Category.RENDER);
}

// See LivingEntityRendererMixin
public boolean shouldBeVisible(Entity entity)
{
return isEnabled();
}

// See EntityMixin.onIsInvisibleTo()
}
21 changes: 6 additions & 15 deletions src/main/java/net/wurstclient/hacks/treebot/TreeBotUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,24 @@
*/
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;

public enum TreeBotUtils
{
;

private static final List<Block> 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<Block> 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);
}
}
21 changes: 21 additions & 0 deletions src/main/java/net/wurstclient/mixin/EntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Boolean> 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);
}
}
16 changes: 0 additions & 16 deletions src/main/java/net/wurstclient/mixin/LivingEntityRendererMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ public final <T extends Entity> Stream<T> applyTo(Stream<T> 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),
Expand Down

0 comments on commit c4e62cd

Please sign in to comment.