package net.minecraft.world.level.block.state.predicate;

import javax.annotation.Nullable;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.block.state.BlockState;
import java.util.function.Predicate;

public class BlockMaterialPredicate implements Predicate<BlockState> {
    private static final BlockMaterialPredicate AIR;
    private final Material material;
    
    private BlockMaterialPredicate(final Material coo) {
        this.material = coo;
    }
    
    public static BlockMaterialPredicate forMaterial(final Material coo) {
        return (coo == Material.AIR) ? BlockMaterialPredicate.AIR : new BlockMaterialPredicate(coo);
    }
    
    @Override
    public boolean test(@Nullable final BlockState byj) {
        return byj != null && byj.getMaterial() == this.material;
    }
    
    static {
        AIR = new BlockMaterialPredicate(Material.AIR) {
            @Override
            public boolean test(@Nullable final BlockState byj) {
                return byj != null && byj.isAir();
            }
        };
    }
}
