package net.minecraft.world.level.levelgen.structure.templatesystem;

import java.util.function.Function;
import net.minecraft.core.Registry;
import java.util.Random;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Block;
import com.mojang.serialization.Codec;

public class BlockMatchTest extends RuleTest {
    public static final Codec<BlockMatchTest> CODEC;
    private final Block block;
    
    public BlockMatchTest(final Block bvr) {
        this.block = bvr;
    }
    
    @Override
    public boolean test(final BlockState cfj, final Random random) {
        return cfj.is(this.block);
    }
    
    @Override
    protected RuleTestType<?> getType() {
        return RuleTestType.BLOCK_TEST;
    }
    
    static {
        CODEC = Registry.BLOCK.fieldOf("block").xmap((Function)BlockMatchTest::new, cuj -> cuj.block).codec();
    }
}
