Skip to content

Commit

Permalink
Added if entity is friend sword won't be pulled
Browse files Browse the repository at this point in the history
  • Loading branch information
TejasLamba2006 committed Oct 25, 2023
1 parent beb4935 commit 5245b4d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/main/java/net/wurstclient/hacks/AutoSwordHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/
package net.wurstclient.hacks;

import java.util.stream.Stream;

import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
Expand All @@ -24,6 +26,7 @@
import net.wurstclient.settings.SliderSetting;
import net.wurstclient.settings.SliderSetting.ValueDisplay;
import net.wurstclient.util.ItemUtils;
import net.wurstclient.util.EntityUtils;

@SearchTags({"auto sword"})
public final class AutoSwordHack extends Hack implements UpdateListener
Expand Down Expand Up @@ -75,7 +78,10 @@ public void onUpdate()
&& MC.crosshairTarget.getType() == HitResult.Type.ENTITY)
{
Entity entity = ((EntityHitResult)MC.crosshairTarget).getEntity();

//check if entity is correct
if(!isCorrectEntity(entity))
return;

if(entity instanceof LivingEntity
&& ((LivingEntity)entity).getHealth() > 0)
setSlot();
Expand Down Expand Up @@ -191,4 +197,12 @@ public String toString()
return name;
}
}
private boolean isCorrectEntity(Entity entity)
{
Stream<Entity> stream = Stream.of(entity);
stream = stream.filter(EntityUtils.IS_ATTACKABLE);

return stream.findFirst().isPresent();
}
}

0 comments on commit 5245b4d

Please sign in to comment.