forked from TAIGA/TAIGA
added property check to StateMatcher
This commit is contained in:
@@ -1,21 +1,26 @@
|
||||
package main.util;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
|
||||
public class StateMatcher implements Predicate<IBlockState> {
|
||||
private final IBlockState state;
|
||||
private final IProperty property;
|
||||
private final Comparable value;
|
||||
|
||||
private StateMatcher(IBlockState state) {
|
||||
private StateMatcher(IBlockState state, IProperty property, Comparable value) {
|
||||
this.state = state;
|
||||
this.property = property;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static StateMatcher forState(IBlockState state) {
|
||||
return new StateMatcher(state);
|
||||
public static StateMatcher forState(IBlockState state, IProperty property, Comparable value) {
|
||||
return new StateMatcher(state, property, value);
|
||||
}
|
||||
|
||||
public boolean apply(IBlockState state) {
|
||||
return state != null && state.getBlock() == this.state.getBlock() && state.getMaterial() == this.state.getMaterial();
|
||||
return state != null && state.getBlock() == this.state.getBlock() && state.getValue(property) == value;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user