Skip to content

Commit

Permalink
Add EntityFilterList.testOne() method
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Nov 3, 2023
1 parent 9544d20 commit f4b321e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
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);
}
}
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 f4b321e

Please sign in to comment.