Skip to content

Commit e68fc13

Browse files
authored
KillAura: Split mob age filter into hostile and passive, ensure it works accurately
1 parent 5d0bdb2 commit e68fc13

File tree

1 file changed

+33
-16
lines changed
  • src/main/java/meteordevelopment/meteorclient/systems/modules/combat

1 file changed

+33
-16
lines changed

src/main/java/meteordevelopment/meteorclient/systems/modules/combat/KillAura.java

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
import net.minecraft.entity.EntityType;
2929
import net.minecraft.entity.LivingEntity;
3030
import net.minecraft.entity.Tameable;
31-
import net.minecraft.entity.mob.EndermanEntity;
32-
import net.minecraft.entity.mob.PiglinEntity;
33-
import net.minecraft.entity.mob.ZombifiedPiglinEntity;
34-
import net.minecraft.entity.passive.AnimalEntity;
31+
import net.minecraft.entity.mob.*;
32+
import net.minecraft.entity.passive.FrogEntity;
33+
import net.minecraft.entity.passive.ParrotEntity;
34+
import net.minecraft.entity.passive.PassiveEntity;
3535
import net.minecraft.entity.passive.WolfEntity;
3636
import net.minecraft.entity.player.PlayerEntity;
3737
import net.minecraft.item.*;
@@ -169,13 +169,20 @@ public class KillAura extends Module {
169169
.build()
170170
);
171171

172-
private final Setting<EntityAge> mobAgeFilter = sgTargeting.add(new EnumSetting.Builder<EntityAge>()
173-
.name("mob-age-filter")
174-
.description("Determines the age of the mobs to target (baby, adult, or both).")
172+
private final Setting<EntityAge> passiveMobAgeFilter = sgTargeting.add(new EnumSetting.Builder<EntityAge>()
173+
.name("passive-mob-age-filter")
174+
.description("Determines the age of passive mobs to target (animals, villagers).")
175175
.defaultValue(EntityAge.Adult)
176176
.build()
177177
);
178178

179+
private final Setting<EntityAge> hostileMobAgeFilter = sgTargeting.add(new EnumSetting.Builder<EntityAge>()
180+
.name("hostile-mob-age-filter")
181+
.description("Determines the age of hostile mobs to target (zombies, piglins, hoglins, zoglins).")
182+
.defaultValue(EntityAge.Both)
183+
.build()
184+
);
185+
179186
private final Setting<Boolean> ignoreNamed = sgTargeting.add(new BoolSetting.Builder()
180187
.name("ignore-named")
181188
.description("Whether or not to attack mobs with a name.")
@@ -408,22 +415,32 @@ private boolean entityCheck(Entity entity) {
408415
}
409416
if (ignorePassive.get()) {
410417
if (entity instanceof EndermanEntity enderman && !enderman.isAngry()) return false;
411-
if (entity instanceof PiglinEntity piglin && !piglin.isAttacking()) return false;
412-
if (entity instanceof ZombifiedPiglinEntity zombifiedPiglin && !zombifiedPiglin.isAttacking()) return false;
413-
if (entity instanceof WolfEntity wolf && !wolf.isAttacking()) return false;
418+
if ((entity instanceof PiglinEntity || entity instanceof ZombifiedPiglinEntity || entity instanceof WolfEntity) && !((MobEntity) entity).isAttacking()) return false;
414419
}
415420
if (entity instanceof PlayerEntity player) {
416421
if (player.isCreative()) return false;
417422
if (!Friends.get().shouldAttack(player)) return false;
418423
if (shieldMode.get() == ShieldMode.Ignore && player.isBlocking()) return false;
419424
if (player instanceof FakePlayerEntity fakePlayer && fakePlayer.noHit) return false;
420425
}
421-
if (entity instanceof AnimalEntity animal) {
422-
return switch (mobAgeFilter.get()) {
423-
case Baby -> animal.isBaby();
424-
case Adult -> !animal.isBaby();
425-
case Both -> true;
426-
};
426+
if (entity instanceof LivingEntity livingEntity) {
427+
// Hostile mobs with baby variants (zombies, piglins, hoglins, zoglins)
428+
if (entity instanceof ZombieEntity || entity instanceof PiglinEntity
429+
|| entity instanceof HoglinEntity || entity instanceof ZoglinEntity) {
430+
return switch (hostileMobAgeFilter.get()) {
431+
case Baby -> livingEntity.isBaby();
432+
case Adult -> !livingEntity.isBaby();
433+
case Both -> true;
434+
};
435+
}
436+
// Passive mobs with baby variants (animals, villagers)
437+
if (entity instanceof PassiveEntity && (!(entity instanceof FrogEntity || entity instanceof ParrotEntity))) {
438+
return switch (passiveMobAgeFilter.get()) {
439+
case Baby -> livingEntity.isBaby();
440+
case Adult -> !livingEntity.isBaby();
441+
case Both -> true;
442+
};
443+
}
427444
}
428445
return true;
429446
}

0 commit comments

Comments
 (0)