Skip to content

Commit

Permalink
Improve baby filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Oct 11, 2023
1 parent 59aea94 commit e638068
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,30 @@

import net.minecraft.entity.Entity;
import net.minecraft.entity.passive.PassiveEntity;
import net.minecraft.entity.passive.TadpoleEntity;

public final class FilterBabiesSetting extends EntityFilterCheckbox
{
private static final String EXCEPTIONS_TEXT = "\n\nThis filter does not"
+ " affect baby zombies and other hostile baby mobs.";

public FilterBabiesSetting(String description, boolean checked)
{
super("Filter babies", description, checked);
super("Filter babies", description + EXCEPTIONS_TEXT, checked);
}

@Override
public boolean test(Entity e)
{
return !(e instanceof PassiveEntity && ((PassiveEntity)e).isBaby());
// filter out passive entity babies
if(e instanceof PassiveEntity pe && pe.isBaby())
return false;

// filter out tadpoles
if(e instanceof TadpoleEntity)
return false;

return true;
}

public static FilterBabiesSetting genericCombat(boolean checked)
Expand Down

0 comments on commit e638068

Please sign in to comment.