4.1.0: Add helper getters to CompoundTag

This commit is contained in:
Nassim Jahnke 2024-02-10 19:26:53 +01:00
parent 18754b7774
commit ea616b1e44
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
2 changed files with 22 additions and 3 deletions

View File

@ -5,7 +5,7 @@
<groupId>com.viaversion</groupId> <groupId>com.viaversion</groupId>
<artifactId>nbt</artifactId> <artifactId>nbt</artifactId>
<version>4.0.1</version> <version>4.1.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>ViaNBT</name> <name>ViaNBT</name>

View File

@ -140,6 +140,26 @@ public class CompoundTag extends Tag implements Iterable<Entry<String, Tag>> {
return (T) this.value.get(tagName); return (T) this.value.get(tagName);
} }
public @Nullable StringTag getStringTag(String tagName) {
final Tag tag = this.value.get(tagName);
return tag instanceof StringTag ? (StringTag) tag : null;
}
public @Nullable CompoundTag getCompoundTag(String tagName) {
final Tag tag = this.value.get(tagName);
return tag instanceof CompoundTag ? (CompoundTag) tag : null;
}
public @Nullable ListTag getListTag(String tagName) {
final Tag tag = this.value.get(tagName);
return tag instanceof ListTag ? (ListTag) tag : null;
}
public @Nullable NumberTag getNumberTag(String tagName) {
final Tag tag = this.value.get(tagName);
return tag instanceof NumberTag ? (NumberTag) tag : null;
}
/** /**
* Puts the tag into this compound tag. * Puts the tag into this compound tag.
* *
@ -258,8 +278,7 @@ public class CompoundTag extends Tag implements Iterable<Entry<String, Tag>> {
tag.write(out); tag.write(out);
} }
// End out.writeByte(TagRegistry.END);
out.writeByte(0);
} }
@Override @Override