mirror of
https://github.com/ViaVersion/mcstructs-viafier.git
synced 2025-01-07 18:58:16 +01:00
Update ViaNBT
This commit is contained in:
parent
f19c889c90
commit
29d2ceab78
13
mcstructs.py
13
mcstructs.py
@ -2,7 +2,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
via_nbt_version = '4.4.0'
|
via_nbt_version = '5.0.0'
|
||||||
|
|
||||||
# All of this would work better with bytecode rewriting, but here we go
|
# All of this would work better with bytecode rewriting, but here we go
|
||||||
replacements = {
|
replacements = {
|
||||||
@ -12,17 +12,16 @@ replacements = {
|
|||||||
'api project(":MCStructs-nbt")': f'api "com.viaversion:nbt:{via_nbt_version}"',
|
'api project(":MCStructs-nbt")': f'api "com.viaversion:nbt:{via_nbt_version}"',
|
||||||
'maven_group=net.lenni0451.mcstructs': 'maven_group=com.viaversion.mcstructs',
|
'maven_group=net.lenni0451.mcstructs': 'maven_group=com.viaversion.mcstructs',
|
||||||
# Code changes
|
# Code changes
|
||||||
'import net.lenni0451.mcstructs.nbt.tags.': 'import com.github.steveice10.opennbt.tag.builtin.',
|
'import net.lenni0451.mcstructs.nbt.tags.': 'import com.viaversion.nbt.tag.',
|
||||||
'import net.lenni0451.mcstructs.nbt.': 'import com.github.steveice10.opennbt.tag.builtin.',
|
'import net.lenni0451.mcstructs.nbt.': 'import com.viaversion.nbt.tag.',
|
||||||
'INbtTag': 'Tag',
|
'INbtTag': 'Tag',
|
||||||
'INbtNumber': 'NumberTag',
|
'INbtNumber': 'NumberTag',
|
||||||
'tag.getNbtType()': 'tag',
|
'tag.getNbtType()': 'tag',
|
||||||
'ArrayTag.getLength()': 'ArrayTag.length()',
|
'ArrayTag.getLength()': 'ArrayTag.length()',
|
||||||
'ArrayTag.get(': 'ArrayTag.getValue(',
|
|
||||||
'type.name()': 'type.getClass().getSimpleName()',
|
'type.name()': 'type.getClass().getSimpleName()',
|
||||||
'NbtType': 'Tag',
|
'NbtType': 'Tag',
|
||||||
'import com.github.steveice10.opennbt.tag.builtin.Tag': 'import com.github.steveice10.opennbt.tag.builtin.*',
|
'import com.viaversion.nbt.tag.Tag': 'import com.viaversion.nbt.tag.*',
|
||||||
'import com.github.steveice10.opennbt.tag.builtin.CompoundTag': 'import com.github.steveice10.opennbt.tag.builtin.*',
|
'import com.viaversion.nbt.tag.CompoundTag': 'import com.viaversion.nbt.tag.*',
|
||||||
# A special one
|
# A special one
|
||||||
' if (!list.canAdd(tag)) throw new SNbtDeserializeException("Unable to insert " + tag.getClass().getSimpleName() + " into ListTag of type " + list.getType().name());': ''
|
' if (!list.canAdd(tag)) throw new SNbtDeserializeException("Unable to insert " + tag.getClass().getSimpleName() + " into ListTag of type " + list.getType().name());': ''
|
||||||
}
|
}
|
||||||
@ -40,7 +39,7 @@ extra_replacements = {
|
|||||||
'.addAll(': '.putAll(',
|
'.addAll(': '.putAll(',
|
||||||
'.getTag().name()': '.getClass()',
|
'.getTag().name()': '.getClass()',
|
||||||
'tag.name()': 'tag.getClass()',
|
'tag.name()': 'tag.getClass()',
|
||||||
'list.getType().isNumber()': 'list.getElementType().isAssignableFrom(com.github.steveice10.opennbt.tag.builtin.NumberTag.class)',
|
'list.getType().isNumber()': 'list.getElementType().isAssignableFrom(com.viaversion.nbt.tag.NumberTag.class)',
|
||||||
'values.get(i).asNumberTag().intValue()': '((NumberTag) values.get(i)).asInt()',
|
'values.get(i).asNumberTag().intValue()': '((NumberTag) values.get(i)).asInt()',
|
||||||
'this.styleSerializer.serialize(object.getStyle()).asCompoundTag()': '(CompoundTag) this.styleSerializer.serialize(object.getStyle())',
|
'this.styleSerializer.serialize(object.getStyle()).asCompoundTag()': '(CompoundTag) this.styleSerializer.serialize(object.getStyle())',
|
||||||
'JsonNbtConverter.toNbt(json).asCompoundTag()': '((CompoundTag) JsonNbtConverter.toNbt(json))',
|
'JsonNbtConverter.toNbt(json).asCompoundTag()': '((CompoundTag) JsonNbtConverter.toNbt(json))',
|
||||||
|
@ -14,21 +14,21 @@ index 851d33c..2a55603 100644
|
|||||||
+ final ListTag<ByteTag> tags = this.readPrimitiveList(reader, ByteTag.class, ByteArrayTag.class);
|
+ final ListTag<ByteTag> tags = this.readPrimitiveList(reader, ByteTag.class, ByteArrayTag.class);
|
||||||
+ final byte[] array = new byte[tags.size()];
|
+ final byte[] array = new byte[tags.size()];
|
||||||
+ for (int i = 0; i < tags.size(); i++) {
|
+ for (int i = 0; i < tags.size(); i++) {
|
||||||
+ array[i] = tags.get(i).value();
|
+ array[i] = tags.get(i).asByte();
|
||||||
+ }
|
+ }
|
||||||
+ return new ByteArrayTag(array);
|
+ return new ByteArrayTag(array);
|
||||||
+ } else if (c == 'L') {
|
+ } else if (c == 'L') {
|
||||||
+ final ListTag<LongTag> tags = this.readPrimitiveList(reader, LongTag.class, LongArrayTag.class);
|
+ final ListTag<LongTag> tags = this.readPrimitiveList(reader, LongTag.class, LongArrayTag.class);
|
||||||
+ final long[] array = new long[tags.size()];
|
+ final long[] array = new long[tags.size()];
|
||||||
+ for (int i = 0; i < tags.size(); i++) {
|
+ for (int i = 0; i < tags.size(); i++) {
|
||||||
+ array[i] = tags.get(i).value();
|
+ array[i] = tags.get(i).asLong();
|
||||||
+ }
|
+ }
|
||||||
+ return new LongArrayTag(array);
|
+ return new LongArrayTag(array);
|
||||||
+ } else if (c == 'I') {
|
+ } else if (c == 'I') {
|
||||||
+ final ListTag<IntTag> tags = this.readPrimitiveList(reader, IntTag.class, IntArrayTag.class);
|
+ final ListTag<IntTag> tags = this.readPrimitiveList(reader, IntTag.class, IntArrayTag.class);
|
||||||
+ final int[] array = new int[tags.size()];
|
+ final int[] array = new int[tags.size()];
|
||||||
+ for (int i = 0; i < tags.size(); i++) {
|
+ for (int i = 0; i < tags.size(); i++) {
|
||||||
+ array[i] = tags.get(i).value();
|
+ array[i] = tags.get(i).asInt();
|
||||||
+ }
|
+ }
|
||||||
+ return new IntArrayTag(array);
|
+ return new IntArrayTag(array);
|
||||||
+ } else throw new SNbtDeserializeException("Invalid array type '" + c + "' found");
|
+ } else throw new SNbtDeserializeException("Invalid array type '" + c + "' found");
|
||||||
|
Loading…
Reference in New Issue
Block a user