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

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

public class BlockStateMatchTest extends RuleTest {
    public static final Codec<BlockStateMatchTest> CODEC;
    private final BlockState blockState;
    
    public BlockStateMatchTest(final BlockState cfj) {
        this.blockState = cfj;
    }
    
    @Override
    public boolean test(final BlockState cfj, final Random random) {
        return cfj == this.blockState;
    }
    
    @Override
    protected RuleTestType<?> getType() {
        return RuleTestType.BLOCKSTATE_TEST;
    }
    
    static {
        CODEC = BlockState.CODEC.fieldOf("block_state").xmap((Function)BlockStateMatchTest::new, cul -> cul.blockState).codec();
    }
}
