mirror of
https://github.com/ViaVersion/mcstructs-viafier.git
synced 2025-01-04 18:28:00 +01:00
New replacements
This commit is contained in:
parent
6f7392262f
commit
9b14d8d2fe
@ -40,9 +40,11 @@ extra_replacements = {
|
|||||||
'.addCompound(': '.put(',
|
'.addCompound(': '.put(',
|
||||||
'.addAll(': '.putAll(',
|
'.addAll(': '.putAll(',
|
||||||
'.getTag().name()': '.getClass()',
|
'.getTag().name()': '.getClass()',
|
||||||
|
'.intValue()': '.asInt()',
|
||||||
'tag.name()': 'tag.getClass()',
|
'tag.name()': 'tag.getClass()',
|
||||||
|
'super.serialize(object).asCompoundTag()': '((CompoundTag) super.serialize(object))',
|
||||||
'list.getType().isNumber()': 'list.getElementType().isAssignableFrom(com.viaversion.nbt.tag.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().asInt()': '((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))',
|
||||||
'Tag.COMPOUND.equals(list.getType())': 'CompoundTag.class == list.getElementType()',
|
'Tag.COMPOUND.equals(list.getType())': 'CompoundTag.class == list.getElementType()',
|
||||||
@ -157,9 +159,13 @@ def handle_file(path):
|
|||||||
changed_content = changed_content.replace('.add("', '.put("')
|
changed_content = changed_content.replace('.add("', '.put("')
|
||||||
|
|
||||||
# tag.isXTag() -> (tag instanceof XTag)
|
# tag.isXTag() -> (tag instanceof XTag)
|
||||||
|
# Special case ArrayTag
|
||||||
|
changed_content = re.sub(r'(\w+)\.isArrayTag\(\)', r'(\1 instanceof NumberArrayTag)', changed_content)
|
||||||
changed_content = re.sub(r'(\w+)\.is(\w+Tag)\(\)', r'(\1 instanceof \2)', changed_content)
|
changed_content = re.sub(r'(\w+)\.is(\w+Tag)\(\)', r'(\1 instanceof \2)', changed_content)
|
||||||
|
|
||||||
# asXTag() -> cast
|
# asXTag() -> cast
|
||||||
|
# Deal with the base ArrayTag separately
|
||||||
|
changed_content = re.sub(r'(\w+)\.asArrayTag\(\)', r'((NumberArrayTag) \1)', changed_content)
|
||||||
changed_content = re.sub(r'(\w+)\.as(\w+Tag)\(\)', r'((\2) \1)', changed_content)
|
changed_content = re.sub(r'(\w+)\.as(\w+Tag)\(\)', r'((\2) \1)', changed_content)
|
||||||
changed_content = re.sub(r'tags.get\(i\)\.as(\w+Tag)\(\)', r'((\1) tags.get(i))', changed_content)
|
changed_content = re.sub(r'tags.get\(i\)\.as(\w+Tag)\(\)', r'((\1) tags.get(i))', changed_content)
|
||||||
|
|
||||||
|
@ -278,13 +278,13 @@ index 8bd6503..e512af7 100644
|
|||||||
- } else if (listType == Tag.INT) {
|
- } else if (listType == Tag.INT) {
|
||||||
+ } else if (listType instanceof IntTag) {
|
+ } else if (listType instanceof IntTag) {
|
||||||
int[] ints = new int[nbtTags.size()];
|
int[] ints = new int[nbtTags.size()];
|
||||||
- for (int i = 0; i < nbtTags.size(); i++) ints[i] = nbtTags.get(i).asIntTag().intValue();
|
- for (int i = 0; i < nbtTags.size(); i++) ints[i] = nbtTags.get(i).asIntTag().asInt();
|
||||||
+ for (int i = 0; i < nbtTags.size(); i++) ints[i] = ((NumberTag) nbtTags.get(i)).asInt();
|
+ for (int i = 0; i < nbtTags.size(); i++) ints[i] = ((NumberTag) nbtTags.get(i)).asInt();
|
||||||
return new IntArrayTag(ints);
|
return new IntArrayTag(ints);
|
||||||
- } else if (listType == Tag.LONG) {
|
- } else if (listType == Tag.LONG) {
|
||||||
+ } else if (listType instanceof LongTag) {
|
+ } else if (listType instanceof LongTag) {
|
||||||
long[] longs = new long[nbtTags.size()];
|
long[] longs = new long[nbtTags.size()];
|
||||||
- for (int i = 0; i < nbtTags.size(); i++) longs[i] = nbtTags.get(i).asIntTag().intValue();
|
- for (int i = 0; i < nbtTags.size(); i++) longs[i] = nbtTags.get(i).asIntTag().asInt();
|
||||||
+ for (int i = 0; i < nbtTags.size(); i++) longs[i] = ((NumberTag) nbtTags.get(i)).asLong();
|
+ for (int i = 0; i < nbtTags.size(); i++) longs[i] = ((NumberTag) nbtTags.get(i)).asLong();
|
||||||
return new LongArrayTag(longs);
|
return new LongArrayTag(longs);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user