Fixed //replace and masks with states.

Dieser Commit ist enthalten in:
Matthew Miller 2018-07-21 20:35:23 +10:00
Ursprung 663dd1f4d8
Commit 2239d14a01
3 geänderte Dateien mit 29 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -95,7 +95,13 @@ public class BlockMask extends AbstractExtentMask {
@Override
public boolean test(Vector vector) {
BlockStateHolder block = getExtent().getBlock(vector);
return blocks.contains(block) || blocks.contains(block);
for (BlockStateHolder testBlock : blocks) {
if (testBlock.equalsFuzzy(block)) {
return true;
}
}
return false;
}
@Nullable

Datei anzeigen

@ -53,4 +53,17 @@ public abstract class AbstractProperty<T> implements Property<T> {
checkState(this.name == null, "name already set");
this.name = name;
}
@Override
public int hashCode() {
return name.hashCode();
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Property)) {
return false;
}
return getName().equals(((Property) obj).getName());
}
}

Datei anzeigen

@ -31,9 +31,12 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
/**
@ -167,7 +170,7 @@ public class BlockState implements BlockStateHolder<BlockState> {
return false;
}
List<Property> differingProperties = new ArrayList<>();
Set<Property> differingProperties = new HashSet<>();
for (Object state : o.getStates().keySet()) {
if (getState((Property) state) == null) {
differingProperties.add((Property) state);
@ -179,8 +182,11 @@ public class BlockState implements BlockStateHolder<BlockState> {
}
}
for (Property property : differingProperties) {
if (!getState(property).equals(o.getState(property))) {
for (Property property : getStates().keySet()) {
if (differingProperties.contains(property)) {
continue;
}
if (!Objects.equals(getState(property), o.getState(property))) {
return false;
}
}