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 cxd) {
        this.material = cxd;
    }
    
    public static BlockMaterialPredicate forMaterial(final Material cxd) {
        return (cxd == Material.AIR) ? BlockMaterialPredicate.AIR : new BlockMaterialPredicate(cxd);
    }
    
    @Override
    public boolean test(@Nullable final BlockState cfj) {
        return cfj != null && cfj.getMaterial() == this.material;
    }
    
    static {
        AIR = new BlockMaterialPredicate(Material.AIR) {
            @Override
            public boolean test(@Nullable final BlockState cfj) {
                return cfj != null && cfj.isAir();
            }
        };
    }
}
