@@ -60,9 +60,7 @@ class BlockEntity::Impl {
6060 if (!result->fTileEntity ->string (u8" CustomName" )) {
6161 auto customName = tag.string (u8" CustomName" );
6262 if (customName) {
63- props::Json json;
64- props::SetJsonString (json, u8" text" , *customName);
65- result->fTileEntity ->set (u8" CustomName" , props::StringFromJson (json));
63+ result->fTileEntity ->set (u8" CustomName" , props::CreateJavaTextComponent (*customName, outputDataVersion));
6664 }
6765 }
6866 }
@@ -393,9 +391,7 @@ class BlockEntity::Impl {
393391
394392 auto customName = tagB.string (u8" CustomName" , u8" " );
395393 if (!customName.empty ()) {
396- props::Json json;
397- props::SetJsonString (json, u8" text" , customName);
398- t->set (u8" CustomName" , props::StringFromJson (json));
394+ t->set (u8" CustomName" , props::CreateJavaTextComponent (customName, opt.fOutputDataVersion ));
399395 }
400396
401397 Result r;
@@ -781,43 +777,22 @@ class BlockEntity::Impl {
781777 }
782778 for (size_t i = 0 ; i < 4 ; i++) {
783779 u8string line = i < linesB.size () ? linesB[i] : u8" " ;
784- if (outputDataVersion >= (int )JavaDataVersions::Snapshot25w02a) {
785- // 1.21.8
786- // 1.21.6
787- // 1.21.5
788- // 25w07a
789- // 25w04a
790- // 25w02a
791- auto text = Compound ();
792- text->set (u8" text" , String (line));
793- messagesJ->push_back (text);
794- } else {
795- // 1.21.4
796- // 1.20.6
797- // 1.20
798- if (line.empty ()) {
799- messagesJ->push_back (String (u8R"( {"text":""})" ));
800- } else {
801- props::Json json;
802- props::SetJsonString (json, u8" text" , line);
803- messagesJ->push_back (String (props::StringFromJson (json)));
804- }
805- }
780+ messagesJ->push_back (props::CreateJavaTextComponent (line, outputDataVersion));
806781 }
807782 ret->set (u8" messages" , messagesJ);
808783
809784 return ret;
810785 }
811786
812- static CompoundTagPtr SignTextEmpty () {
787+ static CompoundTagPtr SignTextEmpty (int outputDataVersion ) {
813788 auto ret = Compound ();
814789 ret->set (u8" color" , u8" black" );
815790 ret->set (u8" has_glowing_text" , Bool (false ));
816791 auto messages = List<Tag::Type::String>();
817- messages->push_back (String ( u8R"( {"text":""} )" ));
818- messages->push_back (String ( u8R"( {"text":""} )" ));
819- messages->push_back (String ( u8R"( {"text":""} )" ));
820- messages->push_back (String ( u8R"( {"text":""} )" ));
792+ messages->push_back (props::CreateJavaTextComponent ( u8" " , outputDataVersion ));
793+ messages->push_back (props::CreateJavaTextComponent ( u8" " , outputDataVersion ));
794+ messages->push_back (props::CreateJavaTextComponent ( u8" " , outputDataVersion ));
795+ messages->push_back (props::CreateJavaTextComponent ( u8" " , outputDataVersion ));
821796 ret->set (u8" messages" , messages);
822797 return ret;
823798 }
@@ -1127,13 +1102,13 @@ class BlockEntity::Impl {
11271102 auto frontTextJ = SignText (*frontTextB, opt.fOutputDataVersion );
11281103 te->set (u8" front_text" , frontTextJ);
11291104 } else {
1130- te->set (u8" front_text" , SignTextEmpty ());
1105+ te->set (u8" front_text" , SignTextEmpty (opt. fOutputDataVersion ));
11311106 }
11321107 if (backTextB) {
11331108 auto backTextJ = SignText (*backTextB, opt.fOutputDataVersion );
11341109 te->set (u8" back_text" , backTextJ);
11351110 } else {
1136- te->set (u8" back_text" , SignTextEmpty ());
1111+ te->set (u8" back_text" , SignTextEmpty (opt. fOutputDataVersion ));
11371112 }
11381113 } else {
11391114 auto frontTextJ = Compound ();
@@ -1150,14 +1125,12 @@ class BlockEntity::Impl {
11501125 for (int i = 0 ; i < 4 ; i++) {
11511126 u8string key = u8" Text" + mcfile::String::ToString (i + 1 );
11521127 u8string line = i < lines.size () ? lines[i] : u8" " ;
1153- props::Json json;
1154- props::SetJsonString (json, u8" text" , line);
1155- messagesJ->push_back (String (props::StringFromJson (json)));
1128+ messagesJ->push_back (props::CreateJavaTextComponent (line, opt.fOutputDataVersion ));
11561129 }
11571130 frontTextJ->set (u8" messages" , messagesJ);
11581131
11591132 te->set (u8" front_text" , frontTextJ);
1160- te->set (u8" back_text" , SignTextEmpty ());
1133+ te->set (u8" back_text" , SignTextEmpty (opt. fOutputDataVersion ));
11611134 }
11621135
11631136 CopyBoolValues (tag, *te, {{u8" IsWaxed" , u8" is_waxed" }});
@@ -1290,7 +1263,6 @@ class BlockEntity::Impl {
12901263 static std::optional<Result> Null (Pos3i const &pos, mcfile::be::Block const &block, CompoundTag const &tagB, mcfile::je::Block const &blockJ, Context &ctx, Options const &opt) {
12911264 return std::nullopt ;
12921265 }
1293-
12941266#pragma endregion
12951267
12961268 static std::unordered_map<std::u8string_view, Converter> *CreateTable () {
0 commit comments