Skip to content

Commit

Permalink
Add filter for regular piglins
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Oct 13, 2023
1 parent d1939cf commit d81c6be
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 16 deletions.
6 changes: 4 additions & 2 deletions src/main/java/net/wurstclient/hacks/AimAssistHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ public final class AimAssistHack extends Hack
FilterSleepingSetting.genericCombat(false),
FilterFlyingSetting.genericCombat(0),
FilterHostileSetting.genericCombat(false),
FilterZombiePiglinsSetting
.genericCombat(AttackDetectingEntityFilter.Mode.OFF),
FilterEndermenSetting
.genericCombat(AttackDetectingEntityFilter.Mode.OFF),
FilterPassiveSetting.genericCombat(true),
Expand All @@ -64,6 +62,10 @@ public final class AimAssistHack extends Hack
FilterVillagersSetting.genericCombat(true),
FilterZombieVillagersSetting.genericCombat(true),
FilterGolemsSetting.genericCombat(false),
FilterPiglinsSetting
.genericCombat(AttackDetectingEntityFilter.Mode.OFF),
FilterZombiePiglinsSetting
.genericCombat(AttackDetectingEntityFilter.Mode.OFF),
FilterShulkersSetting.genericCombat(false),
FilterInvisibleSetting.genericCombat(true),
FilterNamedSetting.genericCombat(false),
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/net/wurstclient/hacks/KillauraLegitHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ public final class KillauraLegitHack extends Hack
FilterSleepingSetting.genericCombat(true),
FilterFlyingSetting.genericCombat(0.5),
FilterHostileSetting.genericCombat(false),
FilterZombiePiglinsSetting
.genericCombat(AttackDetectingEntityFilter.Mode.OFF),
FilterEndermenSetting
.genericCombat(AttackDetectingEntityFilter.Mode.OFF),
FilterPassiveSetting.genericCombat(false),
Expand All @@ -90,6 +88,10 @@ public final class KillauraLegitHack extends Hack
FilterVillagersSetting.genericCombat(false),
FilterZombieVillagersSetting.genericCombat(false),
FilterGolemsSetting.genericCombat(false),
FilterPiglinsSetting
.genericCombat(AttackDetectingEntityFilter.Mode.OFF),
FilterZombiePiglinsSetting
.genericCombat(AttackDetectingEntityFilter.Mode.OFF),
FilterShulkersSetting.genericCombat(false),
FilterAllaysSetting.genericCombat(false),
FilterInvisibleSetting.genericCombat(true),
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/net/wurstclient/hacks/ProtectHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ public final class ProtectHack extends Hack
FilterSleepingSetting.genericCombat(false),
FilterFlyingSetting.genericCombat(0),
FilterHostileSetting.genericCombat(false),
FilterZombiePiglinsSetting
.genericCombat(FilterZombiePiglinsSetting.Mode.OFF),
FilterEndermenSetting
.genericCombat(AttackDetectingEntityFilter.Mode.OFF),
FilterPassiveSetting.genericCombat(false),
Expand All @@ -64,6 +62,10 @@ public final class ProtectHack extends Hack
FilterVillagersSetting.genericCombat(false),
FilterZombieVillagersSetting.genericCombat(false),
FilterGolemsSetting.genericCombat(false),
FilterPiglinsSetting
.genericCombat(AttackDetectingEntityFilter.Mode.OFF),
FilterZombiePiglinsSetting
.genericCombat(FilterZombiePiglinsSetting.Mode.OFF),
FilterShulkersSetting.genericCombat(false),
FilterAllaysSetting.genericCombat(false),
FilterInvisibleSetting.genericCombat(false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ public static AnchorAuraFilterList create()
builder.add(new FilterGolemsSetting("Won't target iron golems and snow"
+ " golems when auto-placing anchors." + damageWarning, true));

builder.add(new FilterPiglinsSetting(
"Won't target piglins when auto-placing anchors.",
AttackDetectingEntityFilter.Mode.ON));

builder.add(new FilterZombiePiglinsSetting("Won't target"
+ " zombified piglins when auto-placing anchors." + damageWarning,
AttackDetectingEntityFilter.Mode.ON));

builder.add(new FilterShulkersSetting("Won't target shulkers when"
+ " auto-placing anchors." + damageWarning, true));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ public static CrystalAuraFilterList create()
builder.add(new FilterGolemsSetting("Won't target iron golems and snow"
+ " golems when auto-placing crystals." + damageWarning, true));

builder.add(new FilterPiglinsSetting("Won't target piglins when"
+ " auto-placing crystals." + damageWarning,
AttackDetectingEntityFilter.Mode.ON));

builder.add(new FilterZombiePiglinsSetting("Won't target"
+ " zombified piglins when auto-placing crystals." + damageWarning,
AttackDetectingEntityFilter.Mode.ON));

builder.add(new FilterShulkersSetting("Won't target shulkers when"
+ " auto-placing crystals." + damageWarning, true));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ public static EntityFilterList genericCombat()
FilterSleepingSetting.genericCombat(false),
FilterFlyingSetting.genericCombat(0),
FilterHostileSetting.genericCombat(false),
FilterZombiePiglinsSetting
.genericCombat(AttackDetectingEntityFilter.Mode.OFF),
FilterEndermenSetting
.genericCombat(AttackDetectingEntityFilter.Mode.OFF),
FilterPassiveSetting.genericCombat(false),
Expand All @@ -67,6 +65,10 @@ public static EntityFilterList genericCombat()
FilterVillagersSetting.genericCombat(false),
FilterZombieVillagersSetting.genericCombat(false),
FilterGolemsSetting.genericCombat(false),
FilterPiglinsSetting
.genericCombat(AttackDetectingEntityFilter.Mode.OFF),
FilterZombiePiglinsSetting
.genericCombat(AttackDetectingEntityFilter.Mode.OFF),
FilterShulkersSetting.genericCombat(false),
FilterAllaysSetting.genericCombat(false),
FilterInvisibleSetting.genericCombat(false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ public static FollowFilterList create()
builder.add(new FilterHostileSetting(
"Won't follow hostile mobs like zombies and creepers.", true));

builder.add(FilterZombiePiglinsSetting
.onOffOnly("Won't follow zombified piglins.", true));

builder.add(
FilterEndermenSetting.onOffOnly("Won't follow endermen.", true));

Expand All @@ -64,6 +61,12 @@ public static FollowFilterList create()
builder.add(new FilterGolemsSetting(
"Won't follow iron golems and snow golems.", true));

builder
.add(FilterPiglinsSetting.onOffOnly("Won't follow piglins.", true));

builder.add(FilterZombiePiglinsSetting
.onOffOnly("Won't follow zombified piglins.", true));

builder.add(new FilterShulkersSetting("Won't follow shulkers.", true));

builder.add(new FilterAllaysSetting("Won't follow allays.", true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public static MobEspFilterList create()
{
ArrayList<EntityFilter> builder = new ArrayList<>();
builder.add(FilterHostileSetting.genericVision(false));
builder.add(FilterZombiePiglinsSetting
.genericVision(AttackDetectingEntityFilter.Mode.OFF));
builder.add(FilterEndermenSetting
.genericVision(AttackDetectingEntityFilter.Mode.OFF));
builder.add(FilterPassiveSetting.genericVision(false));
Expand All @@ -33,6 +31,10 @@ public static MobEspFilterList create()
builder.add(FilterVillagersSetting.genericVision(false));
builder.add(FilterZombieVillagersSetting.genericVision(false));
builder.add(FilterGolemsSetting.genericVision(false));
builder.add(FilterPiglinsSetting
.genericVision(AttackDetectingEntityFilter.Mode.OFF));
builder.add(FilterZombiePiglinsSetting
.genericVision(AttackDetectingEntityFilter.Mode.OFF));
builder.add(FilterShulkersSetting.genericVision(false));
builder.add(FilterAllaysSetting.genericVision(false));
builder.add(FilterInvisibleSetting.genericVision(false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ public static RemoteViewFilterList create()
builder.add(new FilterHostileSetting(
"Won't view hostile mobs like zombies and creepers.", true));

builder.add(FilterZombiePiglinsSetting
.onOffOnly("Won't view zombified piglins.", true));

builder
.add(FilterEndermenSetting.onOffOnly("Won't view endermen.", true));

Expand All @@ -64,6 +61,12 @@ public static RemoteViewFilterList create()
builder.add(new FilterGolemsSetting(
"Won't view iron golems and snow golems.", true));

builder
.add(FilterPiglinsSetting.onOffOnly("Won't view piglins.", true));

builder.add(FilterZombiePiglinsSetting
.onOffOnly("Won't view zombified piglins.", true));

builder.add(new FilterShulkersSetting("Won't view shulkers.", true));

builder.add(new FilterAllaysSetting("Won't view allays.", true));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient.settings.filters;

import net.minecraft.entity.Entity;
import net.minecraft.entity.mob.PiglinEntity;

public final class FilterPiglinsSetting extends AttackDetectingEntityFilter
{
private static final String EXCEPTIONS_TEXT =
"\n\nThis filter does not affect piglin brutes.";

private FilterPiglinsSetting(String description, Mode selected,
boolean checked)
{
super("Filter piglins", description + EXCEPTIONS_TEXT, selected,
checked);
}

public FilterPiglinsSetting(String description, Mode selected)
{
this(description, selected, false);
}

@Override
public boolean onTest(Entity e)
{
return !(e instanceof PiglinEntity);
}

@Override
public boolean ifCalmTest(Entity e)
{
return !(e instanceof PiglinEntity pe) || pe.isAttacking();
}

public static FilterPiglinsSetting genericCombat(Mode selected)
{
return new FilterPiglinsSetting("When set to \u00a7lOn\u00a7r,"
+ " piglins won't be attacked at all.\n\n"
+ "When set to \u00a7lIf calm\u00a7r, piglins won't be attacked"
+ " until they attack first. Be warned that this filter cannot"
+ " detect if the piglins are attacking you or someone else.\n\n"
+ "When set to \u00a7lOff\u00a7r, this filter does nothing and"
+ " piglins can be attacked.", selected);
}

public static FilterPiglinsSetting genericVision(Mode selected)
{
return new FilterPiglinsSetting("When set to \u00a7lOn\u00a7r,"
+ " piglins won't be shown at all.\n\n"
+ "When set to \u00a7lIf calm\u00a7r, piglins won't be shown until"
+ " they attack something.\n\n"
+ "When set to \u00a7lOff\u00a7r, this filter does nothing and"
+ " piglins can be shown.", selected);
}

public static FilterPiglinsSetting onOffOnly(String description,
boolean onByDefault)
{
return new FilterPiglinsSetting(description, null, onByDefault);
}
}

0 comments on commit d81c6be

Please sign in to comment.