From d81c6be822c8aac5ac03f297c2947a33e53835f5 Mon Sep 17 00:00:00 2001 From: Alexander01998 Date: Fri, 13 Oct 2023 18:48:14 +0200 Subject: [PATCH] Add filter for regular piglins --- .../net/wurstclient/hacks/AimAssistHack.java | 6 +- .../wurstclient/hacks/KillauraLegitHack.java | 6 +- .../net/wurstclient/hacks/ProtectHack.java | 6 +- .../filterlists/AnchorAuraFilterList.java | 8 +++ .../filterlists/CrystalAuraFilterList.java | 8 +++ .../filterlists/EntityFilterList.java | 6 +- .../filterlists/FollowFilterList.java | 9 ++- .../filterlists/MobEspFilterList.java | 6 +- .../filterlists/RemoteViewFilterList.java | 9 ++- .../filters/FilterPiglinsSetting.java | 68 +++++++++++++++++++ 10 files changed, 116 insertions(+), 16 deletions(-) create mode 100644 src/main/java/net/wurstclient/settings/filters/FilterPiglinsSetting.java diff --git a/src/main/java/net/wurstclient/hacks/AimAssistHack.java b/src/main/java/net/wurstclient/hacks/AimAssistHack.java index 99d0ea4dab..96606f45ff 100644 --- a/src/main/java/net/wurstclient/hacks/AimAssistHack.java +++ b/src/main/java/net/wurstclient/hacks/AimAssistHack.java @@ -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), @@ -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), diff --git a/src/main/java/net/wurstclient/hacks/KillauraLegitHack.java b/src/main/java/net/wurstclient/hacks/KillauraLegitHack.java index d86dc74a24..548034c2c9 100644 --- a/src/main/java/net/wurstclient/hacks/KillauraLegitHack.java +++ b/src/main/java/net/wurstclient/hacks/KillauraLegitHack.java @@ -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), @@ -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), diff --git a/src/main/java/net/wurstclient/hacks/ProtectHack.java b/src/main/java/net/wurstclient/hacks/ProtectHack.java index 45e7fe987b..d7d6d5b8f9 100644 --- a/src/main/java/net/wurstclient/hacks/ProtectHack.java +++ b/src/main/java/net/wurstclient/hacks/ProtectHack.java @@ -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), @@ -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), diff --git a/src/main/java/net/wurstclient/settings/filterlists/AnchorAuraFilterList.java b/src/main/java/net/wurstclient/settings/filterlists/AnchorAuraFilterList.java index 9819bb3dd9..41ba3c523b 100644 --- a/src/main/java/net/wurstclient/settings/filterlists/AnchorAuraFilterList.java +++ b/src/main/java/net/wurstclient/settings/filterlists/AnchorAuraFilterList.java @@ -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)); diff --git a/src/main/java/net/wurstclient/settings/filterlists/CrystalAuraFilterList.java b/src/main/java/net/wurstclient/settings/filterlists/CrystalAuraFilterList.java index a16c5fefbf..d239fca0bc 100644 --- a/src/main/java/net/wurstclient/settings/filterlists/CrystalAuraFilterList.java +++ b/src/main/java/net/wurstclient/settings/filterlists/CrystalAuraFilterList.java @@ -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)); diff --git a/src/main/java/net/wurstclient/settings/filterlists/EntityFilterList.java b/src/main/java/net/wurstclient/settings/filterlists/EntityFilterList.java index 6f342a4747..45c5a1a515 100644 --- a/src/main/java/net/wurstclient/settings/filterlists/EntityFilterList.java +++ b/src/main/java/net/wurstclient/settings/filterlists/EntityFilterList.java @@ -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), @@ -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), diff --git a/src/main/java/net/wurstclient/settings/filterlists/FollowFilterList.java b/src/main/java/net/wurstclient/settings/filterlists/FollowFilterList.java index 15f177b5ce..83c9e0a934 100644 --- a/src/main/java/net/wurstclient/settings/filterlists/FollowFilterList.java +++ b/src/main/java/net/wurstclient/settings/filterlists/FollowFilterList.java @@ -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)); @@ -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)); diff --git a/src/main/java/net/wurstclient/settings/filterlists/MobEspFilterList.java b/src/main/java/net/wurstclient/settings/filterlists/MobEspFilterList.java index 4bd1020b25..896c0b064d 100644 --- a/src/main/java/net/wurstclient/settings/filterlists/MobEspFilterList.java +++ b/src/main/java/net/wurstclient/settings/filterlists/MobEspFilterList.java @@ -23,8 +23,6 @@ public static MobEspFilterList create() { ArrayList 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)); @@ -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)); diff --git a/src/main/java/net/wurstclient/settings/filterlists/RemoteViewFilterList.java b/src/main/java/net/wurstclient/settings/filterlists/RemoteViewFilterList.java index 9090b6d96a..c3ca36de9f 100644 --- a/src/main/java/net/wurstclient/settings/filterlists/RemoteViewFilterList.java +++ b/src/main/java/net/wurstclient/settings/filterlists/RemoteViewFilterList.java @@ -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)); @@ -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)); diff --git a/src/main/java/net/wurstclient/settings/filters/FilterPiglinsSetting.java b/src/main/java/net/wurstclient/settings/filters/FilterPiglinsSetting.java new file mode 100644 index 0000000000..005191ff20 --- /dev/null +++ b/src/main/java/net/wurstclient/settings/filters/FilterPiglinsSetting.java @@ -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); + } +}