Compare commits

...
10 Commits
Author SHA1 Message Date
tr7zw 0f926998f6 Tag 2.13.2 2024-08-10 20:28:54 +02:00
tr7zw 3a44a5e989 Add 1.21.1 Paper support 2024-08-10 20:21:32 +02:00
tr7zw 30b931945c Merge pull request #288 from SoSeDiK/chunkload
Prevent chunk loading during tile entity tests
2024-08-10 20:20:58 +02:00
tr7zw 88d8629541 Merge pull request #290 from tr7zw/dependabot/maven/org.apache.maven.plugins-maven-javadoc-plugin-3.8.0
Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.7.0 to 3.8.0
2024-07-21 20:56:57 +02:00
dependabot[bot] 00ae0448f4 Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.7.0 to 3.8.0
Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.7.0 to 3.8.0.
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.7.0...maven-javadoc-plugin-3.8.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-javadoc-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-21 18:53:26 +00:00
tr7zw ce26e180e6 Merge branch 'master' of https://github.com/tr7zw/Item-NBT-API 2024-07-21 20:51:52 +02:00
tr7zw c939105e45 Start 2.13.2-SNAPSHOT 2024-07-21 20:51:48 +02:00
tr7zw 2079123a42 Merge pull request #287 from SoSeDiK/wiki
Small wiki changes
2024-07-21 20:48:08 +02:00
SoSeDiK 31b17fe9c9 Update wiki
- Fix broken (block-)entities link in sidebar
- Change "(block)-entities" to "entities and block entities" in titles to better reflect title in links
- Move repository above artifact in Maven/Gradle usage
- Add info about preloadApi
- Add title for ItemMeta usage
- Small text changes
2024-07-01 15:53:10 +03:00
SoSeDiK b565902006 Prevent chunk loading during tile entity tests 2024-07-01 15:20:52 +03:00
16 changed files with 106 additions and 61 deletions

No files matched your search

+1 -1
View File
@@ -8,7 +8,7 @@ updates:
ignore:
- dependency-name: com.github.ekryd.sortpom:sortpom-maven-plugin
versions:
- 2.13.1
- 2.13.2
- 2.14.0
- 2.14.1
- 2.15.0
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-parent</artifactId>
<version>2.13.1</version>
<version>2.13.2</version>
</parent>
<artifactId>item-nbt-api</artifactId>
@@ -39,7 +39,7 @@ public enum MinecraftVersion {
private static Logger logger = Logger.getLogger("NBTAPI");
// NBT-API Version
protected static final String VERSION = "2.13.1";
protected static final String VERSION = "2.13.2";
private final int versionId;
private final boolean mojangMapping;
@@ -56,6 +56,7 @@ public enum MinecraftVersion {
this.put("1.20.5", MC1_20_R4);
this.put("1.20.6", MC1_20_R4);
this.put("1.21", MC1_21_R1);
this.put("1.21.1", MC1_21_R1);
}
};
+2 -2
View File
@@ -4,7 +4,7 @@
<parent>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-parent</artifactId>
<version>2.13.1</version>
<version>2.13.2</version>
</parent>
<artifactId>item-nbt-api-plugin</artifactId>
<packaging>jar</packaging>
@@ -12,7 +12,7 @@
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.13.1</version>
<version>2.13.2</version>
<scope>compile</scope>
</dependency>
<dependency>
@@ -22,7 +22,7 @@ public class TileTest implements Test {
try {
Block block = world.getBlockAt(world.getSpawnLocation().getBlockX(), 254,
world.getSpawnLocation().getBlockZ());
if (block.getChunk().isLoaded() && block.getType() == Material.AIR) {
if (world.isChunkLoaded(block.getX() >> 4, block.getZ() >> 4) && block.getType() == Material.AIR) {
block.setType(Material.CHEST);
NBTTileEntity tile = new NBTTileEntity(block.getState());
if (!MinecraftVersion.isNewerThan(MinecraftVersion.MC1_17_R1)) {
@@ -25,7 +25,7 @@ public class TilesCustomNBTPersistentTest implements Test {
try {
Block block = world.getBlockAt(world.getSpawnLocation().getBlockX(), 250,
world.getSpawnLocation().getBlockZ());
if (block.getType() == Material.AIR) {
if (world.isChunkLoaded(block.getX() >> 4, block.getZ() >> 4) && block.getType() == Material.AIR) {
block.setType(Material.CHEST);
NBTTileEntity comp = new NBTTileEntity(block.getState());
NBTCompound persistentData = comp.getPersistentDataContainer();
+2 -2
View File
@@ -4,7 +4,7 @@
<parent>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-parent</artifactId>
<version>2.13.1</version>
<version>2.13.2</version>
</parent>
<artifactId>mappings-parser</artifactId>
<packaging>jar</packaging>
@@ -12,7 +12,7 @@
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.13.1</version>
<version>2.13.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-parent</artifactId>
<version>2.13.1</version>
<version>2.13.2</version>
</parent>
<artifactId>nbt-data-api</artifactId>
@@ -14,7 +14,7 @@
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.13.1</version>
<version>2.13.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
+2 -2
View File
@@ -4,7 +4,7 @@
<parent>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-parent</artifactId>
<version>2.13.1</version>
<version>2.13.2</version>
</parent>
<artifactId>nbt-injector</artifactId>
<packaging>jar</packaging>
@@ -12,7 +12,7 @@
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.13.1</version>
<version>2.13.2</version>
<scope>compile</scope>
</dependency>
<dependency>
+2 -2
View File
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-parent</artifactId>
<version>2.13.1</version>
<version>2.13.2</version>
<packaging>pom</packaging>
<inceptionYear>2015</inceptionYear>
<organization>
@@ -110,7 +110,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.7.0</version>
<version>3.8.0</version>
<configuration>
<source>8</source>
</configuration>
+2 -2
View File
@@ -112,7 +112,7 @@ Just use the Plugin as Maven dependency and remember to add "NBTAPI" as dependen
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api-plugin</artifactId>
<version>2.13.1</version>
<version>2.13.2</version>
</dependency>
[/CODE]
[/SPOILER]
@@ -122,7 +122,7 @@ Using this method the API gets copied into your plugin. Server owners don't have
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.13.1</version>
<version>2.13.2</version>
</dependency>
...
<plugins>
+3
View File
@@ -118,5 +118,8 @@ NBTFile playerNbtFile = new NBTFile(playerFile);
// Change player's health
float health = playerNbtFile.getFloat("Health");
playerNbtFile.setFloat("Health", health + 5);
// Once finished, save the file
playerNbtFile.save();
```
+31 -15
View File
@@ -7,12 +7,6 @@ To start using NB-API, you either need to depend on its plugin version, or shade
Add the following entries to your Gradle build at the correct locations:
```groovy
compileOnly("de.tr7zw:item-nbt-api-plugin:VERSION")
```
(Get the current ``VERSION`` from [here](https://modrinth.com/plugin/nbtapi/versions))
```groovy
repositories {
...
@@ -24,6 +18,12 @@ repositories {
}
```
```groovy
compileOnly("de.tr7zw:item-nbt-api-plugin:VERSION")
```
(Get the current ``VERSION`` from [here](https://modrinth.com/plugin/nbtapi/versions))
Add the API as dependency to your ``plugin.yml``:
```yml
@@ -46,15 +46,6 @@ The latest version of the shadow plugin can be found [here](https://github.com/j
Add NBT-API to your dependencies:
```groovy
implementation("de.tr7zw:item-nbt-api:VERSION")
```
(Get the current ``VERSION`` from [here](https://modrinth.com/plugin/nbtapi/versions))
> [!WARNING]
> Make sure you're using ``item-nbt-api`` as ``artifactId``, never shade the ``-plugin`` artifact!
```groovy
repositories {
...
@@ -66,6 +57,15 @@ repositories {
}
```
```groovy
implementation("de.tr7zw:item-nbt-api:VERSION")
```
(Get the current ``VERSION`` from [here](https://modrinth.com/plugin/nbtapi/versions))
> [!WARNING]
> Make sure you're using ``item-nbt-api`` as ``artifactId``, never shade the ``-plugin`` artifact!
After this you can add the shadowJar configuration to relocate the API package:
```groovy
@@ -82,3 +82,19 @@ build {
}
```
###### Initializing NBT-API early
If you are shading NBT-API, you may call ``NBT.preloadApi()`` during ``onEnable`` to initialize NBT-API early and check whether everything works. If you omit this step, NBT-API will be initialized on the first call to the API.
```java
@Override
public void onEnable() {
if (!NBT.preloadApi()) {
getLogger().warning("NBT-API wasn't initialized properly, disabling the plugin");
getPluginLoader().disablePlugin(this);
return;
}
// Load other things
}
```
+40 -24
View File
@@ -7,6 +7,19 @@ To start using NB-API, you either need to depend on its plugin version, or shade
Add the following entries to your pom at the correct locations:
```xml
<repositories>
...
<!-- CodeMC -->
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
<layout>default</layout>
</repository>
...
</repositories>
```
```xml
<dependency>
<groupId>de.tr7zw</groupId>
@@ -18,19 +31,6 @@ Add the following entries to your pom at the correct locations:
(Get the current ``VERSION`` from [here](https://modrinth.com/plugin/nbtapi/versions))
```xml
<repositories>
...
<!-- CodeMC -->
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
<layout>default</layout>
</repository>
...
</repositories>
```
Add the API as dependency to your ``plugin.yml``:
```yaml
@@ -83,6 +83,19 @@ Replace ``YOUR PACKAGE WHERE THE API SHOULD END UP`` with your own unique packag
Then, add NBT-API to your dependencies by including the following entries to your pom at the correct locations:
```xml
<repositories>
...
<!-- CodeMC -->
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
<layout>default</layout>
</repository>
...
</repositories>
```
```xml
<dependency>
<groupId>de.tr7zw</groupId>
@@ -96,16 +109,19 @@ Then, add NBT-API to your dependencies by including the following entries to you
> [!WARNING]
> Make sure you're using ``item-nbt-api`` as ``artifactId``, never shade the ``-plugin`` artifact!
```xml
<repositories>
...
<!-- CodeMC -->
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
<layout>default</layout>
</repository>
...
</repositories>
###### Initializing NBT-API early
If you are shading NBT-API, you may call ``NBT.preloadApi()`` during ``onEnable`` to initialize NBT-API early and check whether everything works. If you omit this step, NBT-API will be initialized on the first call to the API.
```java
@Override
public void onEnable() {
if (!NBT.preloadApi()) {
getLogger().warning("NBT-API wasn't initialized properly, disabling the plugin");
getPluginLoader().disablePlugin(this);
return;
}
// Load other things
}
```
+12 -3
View File
@@ -128,6 +128,8 @@ boolean bar = nbt.resolveOrDefault("foo.other_key[0].bar", false);
### Working with items
You can read/write nbt data on items using ``NBT.get``/``NBT.modify`` methods.
```java
// Setting data
NBT.modify(itemStack, nbt -> {
@@ -154,7 +156,14 @@ int someValue = NBT.modify(itemStack, nbt -> {
nbt.setInteger(i);
return i;
});
```
###### ItemMeta usage
> [!WARNING]
> Never mix the usage of ItemMeta and NBT.
```java
// Updating ItemMeta using NBT
NBT.modify(itemStack, nbt -> {
nbt.setInteger("kills", nbt.getOrDefault("kills", 0) + 1);
@@ -180,9 +189,9 @@ NBT.modifyComponents(item, nbt -> {
});
```
### Working with (block-)entities
### Working with entities and block entities
Working with entities and block entities is similar to working items.
Working with entities and block entities is similar to working with items.
#### Accessing vanilla nbt
@@ -313,7 +322,7 @@ String json = nbt.toString();
ReadWriteNBT nbt = NBT.parseNBT(json);
```
#### (Block-)Entities
#### Entities and block entities
```java
// Saving
+2 -2
View File
@@ -9,9 +9,9 @@
### General
* [Basics](https://github.com/tr7zw/Item-NBT-API/wiki/Using-the-NBT-API#basics-overview)
* [Basics](https://github.com/tr7zw/Item-NBT-API/wiki/Using-the-NBT-API)
* [Items](https://github.com/tr7zw/Item-NBT-API/wiki/Using-the-NBT-API#working-with-items)
* [Block-Entities/Entities](https://github.com/tr7zw/Item-NBT-API/wiki/Using-the-NBT-API#working-with-(block-)entities)
* [Block-Entities/Entities](https://github.com/tr7zw/Item-NBT-API/wiki/Using-the-NBT-API#working-with-entities-and-block-entities)
* [Blocks](https://github.com/tr7zw/Item-NBT-API/wiki/Using-the-NBT-API#working-with-blocks)
### Extras