added property check to StateMatcher

This commit is contained in:
2016-04-29 20:29:51 +02:00
parent 893e90ab6c
commit 6478f23d18

View File

@@ -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;
}
}