From 33aecef7b38dcedb0d2e383dadb986e4d7933464 Mon Sep 17 00:00:00 2001 From: EnZaXD Date: Fri, 1 Nov 2024 18:18:31 +0100 Subject: [PATCH] Handle custom name in block entities in 1.12->1.13 (#4232) Fixes https://github.com/ViaVersion/ViaFabricPlus/issues/592 --- .../provider/BlockEntityProvider.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/BlockEntityProvider.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/BlockEntityProvider.java index c27f04d45..188afcc76 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/BlockEntityProvider.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/provider/BlockEntityProvider.java @@ -33,6 +33,7 @@ import com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.blockentities. import com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.blockentities.FlowerPotHandler; import com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.blockentities.SkullHandler; import com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.blockentities.SpawnerHandler; +import com.viaversion.viaversion.util.ComponentUtil; import java.util.HashMap; import java.util.Map; @@ -46,6 +47,21 @@ public class BlockEntityProvider implements Provider { handlers.put("minecraft:skull", new SkullHandler()); handlers.put("minecraft:mob_spawner", new SpawnerHandler()); handlers.put("minecraft:command_block", new CommandBlockHandler()); + + final BlockEntityHandler customNameHandler = (user, tag) -> { + final StringTag name = tag.getStringTag("CustomName"); + if (name != null) { + name.setValue(ComponentUtil.legacyToJsonString(name.getValue())); + } + return -1; + }; + handlers.put("minecraft:chest", customNameHandler); + handlers.put("minecraft:dispenser", customNameHandler); + handlers.put("minecraft:dropper", customNameHandler); + handlers.put("minecraft:enchanting_table", customNameHandler); + handlers.put("minecraft:furnace", customNameHandler); + handlers.put("minecraft:hopper", customNameHandler); + handlers.put("minecraft:shulker_box", customNameHandler); } /**