mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-22 01:55:47 +01:00
Clone tags instead of abusing double conversion
This commit is contained in:
parent
e3224281a9
commit
9387b86e4a
@ -17,8 +17,13 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.packets;
|
||||
|
||||
import com.github.steveice10.opennbt.conversion.ConverterRegistry;
|
||||
import com.github.steveice10.opennbt.tag.builtin.*;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.ShortTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
@ -36,7 +41,6 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.SoundSource
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.SpawnEggRewriter;
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -357,7 +361,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
||||
if (tag.get("CanPlaceOn") instanceof ListTag) {
|
||||
ListTag old = tag.get("CanPlaceOn");
|
||||
ListTag newCanPlaceOn = new ListTag(StringTag.class);
|
||||
tag.put(NBT_TAG_NAME + "|CanPlaceOn", ConverterRegistry.convertToTag(ConverterRegistry.convertToValue(old))); // There will be data losing
|
||||
tag.put(NBT_TAG_NAME + "|CanPlaceOn", old.clone());
|
||||
for (Tag oldTag : old) {
|
||||
Object value = oldTag.getValue();
|
||||
String oldId = Key.stripMinecraftNamespace(value.toString());
|
||||
@ -379,7 +383,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
||||
if (tag.get("CanDestroy") instanceof ListTag) {
|
||||
ListTag old = tag.get("CanDestroy");
|
||||
ListTag newCanDestroy = new ListTag(StringTag.class);
|
||||
tag.put(NBT_TAG_NAME + "|CanDestroy", ConverterRegistry.convertToTag(ConverterRegistry.convertToValue(old))); // There will be data losing
|
||||
tag.put(NBT_TAG_NAME + "|CanDestroy", old.clone());
|
||||
for (Tag oldTag : old) {
|
||||
Object value = oldTag.getValue();
|
||||
String oldId = Key.stripMinecraftNamespace(value.toString());
|
||||
@ -617,8 +621,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
||||
tag.put("StoredEnchantments", newStoredEnch);
|
||||
}
|
||||
if (tag.get(NBT_TAG_NAME + "|CanPlaceOn") instanceof ListTag) {
|
||||
tag.put("CanPlaceOn", ConverterRegistry.convertToTag(ConverterRegistry.convertToValue(tag.get(NBT_TAG_NAME + "|CanPlaceOn"))));
|
||||
tag.remove(NBT_TAG_NAME + "|CanPlaceOn");
|
||||
tag.put("CanPlaceOn", tag.remove(NBT_TAG_NAME + "|CanPlaceOn"));
|
||||
} else if (tag.get("CanPlaceOn") instanceof ListTag) {
|
||||
ListTag old = tag.get("CanPlaceOn");
|
||||
ListTag newCanPlaceOn = new ListTag(StringTag.class);
|
||||
@ -638,10 +641,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
||||
tag.put("CanPlaceOn", newCanPlaceOn);
|
||||
}
|
||||
if (tag.get(NBT_TAG_NAME + "|CanDestroy") instanceof ListTag) {
|
||||
tag.put("CanDestroy", ConverterRegistry.convertToTag(
|
||||
ConverterRegistry.convertToValue(tag.get(NBT_TAG_NAME + "|CanDestroy"))
|
||||
));
|
||||
tag.remove(NBT_TAG_NAME + "|CanDestroy");
|
||||
tag.put("CanDestroy", tag.remove(NBT_TAG_NAME + "|CanDestroy"));
|
||||
} else if (tag.get("CanDestroy") instanceof ListTag) {
|
||||
ListTag old = tag.get("CanDestroy");
|
||||
ListTag newCanDestroy = new ListTag(StringTag.class);
|
||||
|
Loading…
Reference in New Issue
Block a user