|
28 | 28 | import net.minecraft.entity.EntityType; |
29 | 29 | import net.minecraft.entity.LivingEntity; |
30 | 30 | 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; |
35 | 35 | import net.minecraft.entity.passive.WolfEntity; |
36 | 36 | import net.minecraft.entity.player.PlayerEntity; |
37 | 37 | import net.minecraft.item.*; |
@@ -169,13 +169,20 @@ public class KillAura extends Module { |
169 | 169 | .build() |
170 | 170 | ); |
171 | 171 |
|
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).") |
175 | 175 | .defaultValue(EntityAge.Adult) |
176 | 176 | .build() |
177 | 177 | ); |
178 | 178 |
|
| 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 | + |
179 | 186 | private final Setting<Boolean> ignoreNamed = sgTargeting.add(new BoolSetting.Builder() |
180 | 187 | .name("ignore-named") |
181 | 188 | .description("Whether or not to attack mobs with a name.") |
@@ -408,22 +415,32 @@ private boolean entityCheck(Entity entity) { |
408 | 415 | } |
409 | 416 | if (ignorePassive.get()) { |
410 | 417 | 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; |
414 | 419 | } |
415 | 420 | if (entity instanceof PlayerEntity player) { |
416 | 421 | if (player.isCreative()) return false; |
417 | 422 | if (!Friends.get().shouldAttack(player)) return false; |
418 | 423 | if (shieldMode.get() == ShieldMode.Ignore && player.isBlocking()) return false; |
419 | 424 | if (player instanceof FakePlayerEntity fakePlayer && fakePlayer.noHit) return false; |
420 | 425 | } |
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 | + } |
427 | 444 | } |
428 | 445 | return true; |
429 | 446 | } |
|
0 commit comments