From 3bb0bdd74c0a11df687d9dfa1f0544c1a9e0fb3d Mon Sep 17 00:00:00 2001 From: SoSeDiK Date: Sat, 28 Dec 2024 15:50:49 +0200 Subject: [PATCH 1/4] Clarify persistent data storage availability --- wiki/FAQ.md | 4 +--- wiki/Using-the-NBT-API.md | 7 ++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/wiki/FAQ.md b/wiki/FAQ.md index b79fab5b5..f63d9b1c7 100644 --- a/wiki/FAQ.md +++ b/wiki/FAQ.md @@ -21,6 +21,4 @@ The experimental NBTInjector became unsupported since Minecraft 1.14 and was rem NBTInjector is incompatible with reloads and may break things, and thus is not recommended. -If you're using Minecraft 1.14+, you should switch to the persistent storage API instead. - -In versions prior to 1.14, you may use a workaround like storing data inside an item's nbt that the entity is wearing (e.g. having a button in mob's helmet, and storing data on that button). +See [this wiki section](https://github.com/tr7zw/Item-NBT-API/wiki/Using-the-NBT-API#accessing-custom-data) on how to handle custom entity nbt data without NBTInjector. diff --git a/wiki/Using-the-NBT-API.md b/wiki/Using-the-NBT-API.md index d81d77eee..48488826d 100644 --- a/wiki/Using-the-NBT-API.md +++ b/wiki/Using-the-NBT-API.md @@ -243,7 +243,12 @@ NBT.modify(entity, nbt -> { #### Accessing custom data -For reading/storing custom data on (block-)entities, you should use methods that end with PersistentData. +> [!WARNING] +> Persistent data storage for custom (block-)entity nbt is only available in 1.14+. +> +> If you need to support versions below that, for entities you may use a workaround like storing data inside an item's nbt that the entity is wearing (e.g. having a button in mob's helmet, and storing data on that button). + +For reading/storing custom data on (block-)entities, you should use methods that end with ``PersistentData``. > [!IMPORTANT] > When working with block entities, make sure that the block entity exists in the world. From aa35ee8333dc57a60657a3b34f762dfed66e81c6 Mon Sep 17 00:00:00 2001 From: SoSeDiK Date: Sat, 28 Dec 2024 15:51:28 +0200 Subject: [PATCH 2/4] Fixup modifyMeta example --- wiki/Using-the-NBT-API.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki/Using-the-NBT-API.md b/wiki/Using-the-NBT-API.md index 48488826d..60f8ae845 100644 --- a/wiki/Using-the-NBT-API.md +++ b/wiki/Using-the-NBT-API.md @@ -192,7 +192,7 @@ Alternatively, you may safely modify ItemMeta inside the NBT scope: // Updating ItemMeta using NBT NBT.modify(itemStack, nbt -> { nbt.setInteger("kills", nbt.getOrDefault("kills", 0) + 1); - nbt.modifyMeta((meta, readOnlyNbt) -> { // Do not modify the nbt while modifying the meta! + nbt.modifyMeta((readOnlyNbt, meta) -> { // Do not modify the nbt while modifying the meta! meta.setDisplayName("Kills: " + readOnlyNbt.getOrDefault("kills", 0)); }); // Do more stuff From ba374fe69ccd7d215b76dc03e9a7cf1cacc10bcf Mon Sep 17 00:00:00 2001 From: SoSeDiK Date: Sat, 28 Dec 2024 15:53:01 +0200 Subject: [PATCH 3/4] Update gradle shadow plugin info --- wiki/Using-Gradle.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wiki/Using-Gradle.md b/wiki/Using-Gradle.md index 6242e276b..ede078087 100644 --- a/wiki/Using-Gradle.md +++ b/wiki/Using-Gradle.md @@ -32,17 +32,17 @@ depend: [NBTAPI] # Option 2) Shading the NBT-API into your plugin -To include NBT-API directly in your plugin, you can use the gradle shadow plugin. +To include NBT-API directly in your plugin, you can use the [Gradle Shadow Plugin](https://gradleup.com/shadow/). Add the plugin to the build configuration, as shown here: ```groovy plugins { - id("com.github.johnrengelman.shadow") version "VERSION" + id("com.gradleup.shadow") version "VERSION" } ``` -The latest version of the shadow plugin can be found [here](https://github.com/johnrengelman/shadow/releases). +The latest version of the shadow plugin can be found [here](https://plugins.gradle.org/plugin/com.gradleup.shadow). Add NBT-API to your dependencies: From d9a93e9306a71ae0e36b0817d3955d31fb6f603b Mon Sep 17 00:00:00 2001 From: SoSeDiK Date: Sat, 28 Dec 2024 15:57:04 +0200 Subject: [PATCH 4/4] Add info about paper-plugin.yml --- wiki/Using-Gradle.md | 11 +++++++++++ wiki/Using-Maven.md | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/wiki/Using-Gradle.md b/wiki/Using-Gradle.md index ede078087..d0d1f3776 100644 --- a/wiki/Using-Gradle.md +++ b/wiki/Using-Gradle.md @@ -30,6 +30,17 @@ Add the API as dependency to your ``plugin.yml``: depend: [NBTAPI] ``` +Or, if you are using ``paper-plugin.yml``: + +```yml +dependencies: + server: + NBTAPI: + load: BEFORE + required: true + join-classpath: true +``` + # Option 2) Shading the NBT-API into your plugin To include NBT-API directly in your plugin, you can use the [Gradle Shadow Plugin](https://gradleup.com/shadow/). diff --git a/wiki/Using-Maven.md b/wiki/Using-Maven.md index 3f6643bad..d7255a6f3 100644 --- a/wiki/Using-Maven.md +++ b/wiki/Using-Maven.md @@ -37,6 +37,17 @@ Add the API as dependency to your ``plugin.yml``: depend: [NBTAPI] ``` +Or, if you are using ``paper-plugin.yml``: + +```yml +dependencies: + server: + NBTAPI: + load: BEFORE + required: true + join-classpath: true +``` + # Option 2) Shading the NBT-API into your plugin To include NBT-API directly in your plugin, you can use the maven shade plugin.