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

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

public class TagMatchTest extends RuleTest {
    public static final Codec<TagMatchTest> CODEC;
    private final Tag<Block> tag;
    
    public TagMatchTest(final Tag<Block> adf) {
        this.tag = adf;
    }
    
    @Override
    public boolean test(final BlockState cfj, final Random random) {
        return cfj.is(this.tag);
    }
    
    @Override
    protected RuleTestType<?> getType() {
        return RuleTestType.TAG_TEST;
    }
    
    static {
        CODEC = Tag.codec(SerializationTags.getInstance()::getBlocks).fieldOf("tag").xmap((Function)TagMatchTest::new, cvf -> cvf.tag).codec();
    }
}
