create MatchPattern

This commit is contained in:
dfsek 2021-07-27 19:50:26 -07:00
parent fb3f90a9cd
commit 649273db01

View File

@ -0,0 +1,26 @@
package com.dfsek.terra.addons.feature.locator.patterns.match;
import com.dfsek.terra.addons.feature.locator.patterns.Pattern;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.util.Range;
import com.dfsek.terra.api.world.Column;
import java.util.function.Predicate;
public class MatchPattern implements Pattern {
private final Range range;
private final Predicate<BlockState> matches;
protected MatchPattern(Range range, Predicate<BlockState> matches) {
this.range = range;
this.matches = matches;
}
@Override
public boolean matches(int y, Column column) {
for(int i : range) {
if(!matches.test(column.getBlock(i))) return false;
}
return true;
}
}