use of com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag in project ViaBackwards by ViaVersion.
the class BlockItemPackets1_14 method handleItemToServer.
@Override
public Item handleItemToServer(Item item) {
if (item == null)
return null;
// Lore now uses JSON
CompoundTag tag = item.tag();
CompoundTag display;
if (tag != null && (display = tag.get("display")) != null) {
// Transform to json if no backup tag is found (else process that in the super method)
ListTag lore = display.get("Lore");
if (lore != null && !hasBackupTag(display, "Lore")) {
for (Tag loreEntry : lore) {
if (loreEntry instanceof StringTag) {
StringTag loreEntryTag = (StringTag) loreEntry;
loreEntryTag.setValue(ChatRewriter.legacyTextToJsonString(loreEntryTag.getValue()));
}
}
}
}
enchantmentRewriter.handleToServer(item);
// Call this last to check for the backup lore above
super.handleItemToServer(item);
return item;
}
use of com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag in project ViaBackwards by ViaVersion.
the class BlockItemPackets1_16 method handleBlockEntity.
private void handleBlockEntity(CompoundTag tag) {
StringTag idTag = tag.get("id");
if (idTag == null)
return;
String id = idTag.getValue();
if (id.equals("minecraft:conduit")) {
Tag targetUuidTag = tag.remove("Target");
if (!(targetUuidTag instanceof IntArrayTag))
return;
// Target -> target_uuid
UUID targetUuid = UUIDIntArrayType.uuidFromIntArray((int[]) targetUuidTag.getValue());
tag.put("target_uuid", new StringTag(targetUuid.toString()));
} else if (id.equals("minecraft:skull")) {
Tag skullOwnerTag = tag.remove("SkullOwner");
if (!(skullOwnerTag instanceof CompoundTag))
return;
CompoundTag skullOwnerCompoundTag = (CompoundTag) skullOwnerTag;
Tag ownerUuidTag = skullOwnerCompoundTag.remove("Id");
if (ownerUuidTag instanceof IntArrayTag) {
UUID ownerUuid = UUIDIntArrayType.uuidFromIntArray((int[]) ownerUuidTag.getValue());
skullOwnerCompoundTag.put("Id", new StringTag(ownerUuid.toString()));
}
// SkullOwner -> Owner
CompoundTag ownerTag = new CompoundTag();
for (Map.Entry<String, Tag> entry : skullOwnerCompoundTag) {
ownerTag.put(entry.getKey(), entry.getValue());
}
tag.put("Owner", ownerTag);
}
}
use of com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag in project ViaBackwards by ViaVersion.
the class BlockItemPackets1_16 method handleItemToClient.
@Override
public Item handleItemToClient(Item item) {
if (item == null)
return null;
super.handleItemToClient(item);
CompoundTag tag = item.tag();
if (item.identifier() == 771 && tag != null) {
Tag ownerTag = tag.get("SkullOwner");
if (ownerTag instanceof CompoundTag) {
CompoundTag ownerCompundTag = (CompoundTag) ownerTag;
Tag idTag = ownerCompundTag.get("Id");
if (idTag instanceof IntArrayTag) {
UUID ownerUuid = UUIDIntArrayType.uuidFromIntArray((int[]) idTag.getValue());
ownerCompundTag.put("Id", new StringTag(ownerUuid.toString()));
}
}
}
InventoryPackets.newToOldAttributes(item);
enchantmentRewriter.handleToClient(item);
return item;
}
Aggregations