Handle item_name item data for component rewriting

This commit is contained in:
Nassim Jahnke 2024-06-17 12:58:39 +02:00
parent bba0a3a3a6
commit e662640377
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
3 changed files with 4 additions and 11 deletions

View File

@ -69,7 +69,7 @@ import java.util.logging.Logger;
public interface ViaBackwardsPlatform { public interface ViaBackwardsPlatform {
String MINIMUM_VV_VERSION = "5.0.0"; String MINIMUM_VV_VERSION = "5.0.1";
/** /**
* Initialize ViaBackwards. * Initialize ViaBackwards.

View File

@ -67,14 +67,8 @@ public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S
if (protocol.getComponentRewriter() != null) { if (protocol.getComponentRewriter() != null) {
// Handle name and lore components // Handle name and lore components
final StructuredData<Tag> customNameData = dataContainer.getNonEmpty(StructuredDataKey.CUSTOM_NAME); updateComponent(connection, item, StructuredDataKey.ITEM_NAME, "item_name");
if (customNameData != null) { updateComponent(connection, item, StructuredDataKey.CUSTOM_NAME, "custom_name");
final Tag originalName = customNameData.value().copy();
protocol.getComponentRewriter().processTag(connection, customNameData.value());
if (!customNameData.value().equals(originalName)) {
saveTag(createCustomTag(item), originalName, "Name");
}
}
final StructuredData<Tag[]> loreData = dataContainer.getNonEmpty(StructuredDataKey.LORE); final StructuredData<Tag[]> loreData = dataContainer.getNonEmpty(StructuredDataKey.LORE);
if (loreData != null) { if (loreData != null) {
@ -115,7 +109,7 @@ public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S
// Set custom name - only done if there is no original one // Set custom name - only done if there is no original one
if (!dataContainer.contains(StructuredDataKey.CUSTOM_NAME)) { if (!dataContainer.contains(StructuredDataKey.CUSTOM_NAME)) {
dataContainer.set(StructuredDataKey.CUSTOM_NAME, mappedItem.tagName()); dataContainer.set(StructuredDataKey.CUSTOM_NAME, mappedItem.tagName());
tag.putBoolean(nbtTagName("customName"), true); tag.putBoolean(nbtTagName("added_custom_name"), true);
} }
updateItemComponents(connection, dataContainer, this::handleItemToClient, itemIdRewriter, blockIdRewriter); updateItemComponents(connection, dataContainer, this::handleItemToClient, itemIdRewriter, blockIdRewriter);

View File

@ -4,7 +4,6 @@ rootProject.name = "viabackwards-parent"
dependencyResolutionManagement { dependencyResolutionManagement {
repositories { repositories {
mavenLocal()
maven("https://repo.viaversion.com") maven("https://repo.viaversion.com")
maven("https://repo.papermc.io/repository/maven-public/") maven("https://repo.papermc.io/repository/maven-public/")
mavenCentral() mavenCentral()