mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-27 11:38:03 +01:00
Fix default tag value on blocks
This commit is contained in:
parent
204089d53d
commit
a31f885cc7
@ -128,7 +128,7 @@ record BlockImpl(@NotNull Registry.BlockEntry registry,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
|
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
|
||||||
return nbt != null ? tag.read(nbt) : null;
|
return tag.read(Objects.requireNonNullElse(nbt, NBTCompound.EMPTY));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Map<String, String>, Block> possibleProperties() {
|
private Map<Map<String, String>, Block> possibleProperties() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package instance;
|
package instance;
|
||||||
|
|
||||||
import net.minestom.server.instance.block.Block;
|
import net.minestom.server.instance.block.Block;
|
||||||
|
import net.minestom.server.tag.Tag;
|
||||||
import net.minestom.server.utils.block.BlockUtils;
|
import net.minestom.server.utils.block.BlockUtils;
|
||||||
import org.jglrxavpok.hephaistos.nbt.NBT;
|
import org.jglrxavpok.hephaistos.nbt.NBT;
|
||||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||||
@ -27,6 +28,9 @@ public class BlockTest {
|
|||||||
block = block.withNbt(null);
|
block = block.withNbt(null);
|
||||||
assertFalse(block.hasNbt());
|
assertFalse(block.hasNbt());
|
||||||
assertNull(block.nbt());
|
assertNull(block.nbt());
|
||||||
|
|
||||||
|
var value = block.getTag(Tag.String("key").defaultValue("Default"));
|
||||||
|
assertEquals("Default", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user