2018-11-23 19:21:52 +01:00
|
|
|
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;
|
2018-11-23 19:21:52 +01:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2020-04-29 16:38:50 +02:00
|
|
|
import net.minecraft.world.World;
|
2018-11-23 19:21:52 +01:00
|
|
|
|
|
|
|
public class Matcher {
|
|
|
|
|
2019-10-20 22:30:49 +02:00
|
|
|
private final BlockState defaultState;
|
2018-11-23 19:21:52 +01:00
|
|
|
private final ICheck check;
|
|
|
|
|
2019-10-20 22:30:49 +02:00
|
|
|
public Matcher(BlockState defaultState, ICheck check) {
|
2018-11-23 19:21:52 +01:00
|
|
|
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) {
|
|
|
|
return new Matcher(defaultBlock.getDefaultState(), (world, start, offset, pos, state, c) -> state.getBlock().getTags().contains(tag.getName()));
|
2018-11-23 19:21:52 +01:00
|
|
|
}
|
|
|
|
|
2020-02-07 15:22:30 +01:00
|
|
|
public BlockState getDefaultState() {
|
|
|
|
return this.defaultState;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ICheck getCheck() {
|
|
|
|
return this.check;
|
|
|
|
}
|
|
|
|
|
2018-11-23 19:21:52 +01:00
|
|
|
public interface ICheck {
|
2020-04-29 16:38:50 +02:00
|
|
|
boolean matches(World world, BlockPos start, BlockPos offset, BlockPos pos, BlockState state, char c);
|
2018-11-23 19:21:52 +01:00
|
|
|
}
|
|
|
|
}
|