mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-11 09:51:35 +01:00
Add Block::nbtOrEmpty (#2389)
This commit is contained in:
parent
7ce047b22e
commit
d955f51899
@ -92,6 +92,15 @@ public sealed interface Block extends StaticProtocolObject, TagReadable, Blocks
|
||||
@Contract(pure = true)
|
||||
@Nullable CompoundBinaryTag nbt();
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable view of the block nbt or an empty compound.
|
||||
*
|
||||
* @return the block nbt or an empty compound if not present
|
||||
*/
|
||||
default @NotNull CompoundBinaryTag nbtOrEmpty() {
|
||||
return Objects.requireNonNullElse(nbt(), CompoundBinaryTag.empty());
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
default boolean hasNbt() {
|
||||
return nbt() != null;
|
||||
|
Loading…
Reference in New Issue
Block a user