mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-23 16:41:35 +01:00
Added Block#compare
This commit is contained in:
parent
02702bf842
commit
f30e580aad
@ -38,6 +38,14 @@ public interface Block extends Keyed, TagReadable, BlockConstants {
|
||||
|
||||
@NotNull BlockData getData();
|
||||
|
||||
default boolean compare(@NotNull Block block, @NotNull Comparator comparator) {
|
||||
return comparator.equals(this, block);
|
||||
}
|
||||
|
||||
default boolean compare(@NotNull Block block) {
|
||||
return compare(block, Comparator.ID);
|
||||
}
|
||||
|
||||
static @Nullable Block fromNamespaceId(@NotNull NamespaceID namespaceID) {
|
||||
return BlockRegistry.fromNamespaceId(namespaceID);
|
||||
}
|
||||
@ -64,6 +72,17 @@ public interface Block extends Keyed, TagReadable, BlockConstants {
|
||||
return getData().isAir();
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
interface Comparator {
|
||||
Comparator IDENTITY = (b1, b2) -> b1 == b2;
|
||||
|
||||
Comparator ID = (b1, b2) -> b1.getBlockId() == b2.getBlockId();
|
||||
|
||||
Comparator STATE = (b1, b2) -> b1.getStateId() == b2.getStateId();
|
||||
|
||||
boolean equals(@NotNull Block b1, @NotNull Block b2);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
interface Supplier {
|
||||
@NotNull Block get(short stateId);
|
||||
|
Loading…
Reference in New Issue
Block a user