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

40 lines
1.1 KiB
Java
Raw Normal View History

package de.ellpeck.naturesaura.api.multiblock;
import net.minecraft.block.Block;
2019-10-20 22:30:49 +02:00
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
2020-09-22 03:17:02 +02:00
import net.minecraft.tags.ITag;
import net.minecraft.util.math.BlockPos;
2021-12-04 15:40:09 +01:00
import net.minecraft.level.Level;
public class Matcher {
2019-10-20 22:30:49 +02:00
private final BlockState defaultState;
private final ICheck check;
2019-10-20 22:30:49 +02:00
public Matcher(BlockState defaultState, ICheck check) {
this.defaultState = defaultState;
this.check = check;
}
public static Matcher wildcard() {
return new Matcher(Blocks.AIR.getDefaultState(), null);
}
2020-09-22 03:17:02 +02:00
public static Matcher tag(Block defaultBlock, ITag.INamedTag tag) {
2021-12-04 15:40:09 +01:00
return new Matcher(defaultBlock.getDefaultState(), (level, start, offset, pos, state, c) -> state.getBlock().getTags().contains(tag.getName()));
}
2020-02-07 15:22:30 +01:00
public BlockState getDefaultState() {
return this.defaultState;
}
public ICheck getCheck() {
return this.check;
}
public interface ICheck {
2021-12-04 15:40:09 +01:00
boolean matches(Level level, BlockPos start, BlockPos offset, BlockPos pos, BlockState state, char c);
}
}