Skip to content

Commit

Permalink
Add equals / isSame for IBlockData and fix BlockStateEditor parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauriichan committed Aug 17, 2021
1 parent da3a999 commit f9f411c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private BlockStateEditor(@NonNull String blockdata) {
return;
}
if (parts[1].contains("?")) {
parts = parts[1].split("?", 2);
parts = parts[1].split("\\?", 2);
id = parts[0];
properties = '?' + parts[1];
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public interface IBlockData {

@NonNull
BlockStateEditor asEditor();

default boolean isMinecraft() {
return getNamespace().equalsIgnoreCase("minecraft");
}

default IBlockData setConversionPossible(boolean state) {
getProperties().set(IProperty.of("data_conversion", state));
return this;
Expand All @@ -47,4 +47,12 @@ default boolean isConversionPossible() {
return property.isPresent() ? property.getValue() : false;
}

default boolean isSame(Object obj) {
return (obj instanceof IBlockData) ? isSame((IBlockData) obj) : false;
}

default boolean isSame(IBlockData data) {
return data != null ? data.asString().equals(asString()) : false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@ public abstract class BaseBlockData implements IBlockData {
public final IProperties getProperties() {
return properties;
}

@Override
public final boolean equals(Object obj) {
return isSame(obj);
}

}

0 comments on commit f9f411c

Please sign in to comment.