NaturesAura/src/main/java/de/ellpeck/naturesaura/api/multiblock/Matcher.java

25 lines
826 B
Java
Raw Normal View History

package de.ellpeck.naturesaura.api.multiblock;
2021-12-04 19:17:21 +01:00
import net.minecraft.core.BlockPos;
2022-03-04 15:59:04 +01:00
import net.minecraft.tags.TagKey;
2021-12-04 19:17:21 +01:00
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
2021-12-08 00:31:29 +01:00
public record Matcher(BlockState defaultState, ICheck check) {
public static Matcher any() {
2021-12-04 19:17:21 +01:00
return new Matcher(Blocks.AIR.defaultBlockState(), null);
}
2022-03-04 15:59:04 +01:00
public static Matcher tag(Block defaultBlock, TagKey<Block> tag) {
return new Matcher(defaultBlock.defaultBlockState(), (level, start, offset, pos, state, c) -> state.is(tag));
}
public interface ICheck {
2021-12-04 19:17:21 +01:00
2021-12-04 15:40:09 +01:00
boolean matches(Level level, BlockPos start, BlockPos offset, BlockPos pos, BlockState state, char c);
}
}