mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-02 21:41:41 +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();
|
@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) {
|
static @Nullable Block fromNamespaceId(@NotNull NamespaceID namespaceID) {
|
||||||
return BlockRegistry.fromNamespaceId(namespaceID);
|
return BlockRegistry.fromNamespaceId(namespaceID);
|
||||||
}
|
}
|
||||||
@ -64,6 +72,17 @@ public interface Block extends Keyed, TagReadable, BlockConstants {
|
|||||||
return getData().isAir();
|
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
|
@FunctionalInterface
|
||||||
interface Supplier {
|
interface Supplier {
|
||||||
@NotNull Block get(short stateId);
|
@NotNull Block get(short stateId);
|
||||||
|
Loading…
Reference in New Issue
Block a user