File tree Expand file tree Collapse file tree 4 files changed +25
-13
lines changed
src/main/java/com/azuriom/azlink/fabric/command
src/main/java/com/azuriom/azlink/neoforge/command Expand file tree Collapse file tree 4 files changed +25
-13
lines changed Original file line number Diff line number Diff line change 11plugins {
2- id ' fabric-loom' version ' 1.9.2 '
2+ id ' fabric-loom' version ' 1.11-SNAPSHOT '
33 id ' com.gradleup.shadow' version ' 8.3.5'
44}
55
99}
1010
1111ext {
12- minecraft_version = ' 1.21.4 '
13- yarn_mappings = ' 1.21.4 +build.8 '
14- loader_version = ' 0.16.14 '
15- fabric_version = ' 0.119.3 +1.21.4 '
12+ minecraft_version = ' 1.21.8 '
13+ yarn_mappings = ' 1.21.8 +build.1 '
14+ loader_version = ' 0.17.2 '
15+ fabric_version = ' 0.132.0 +1.21.8 '
1616}
1717
1818dependencies {
Original file line number Diff line number Diff line change 11package com .azuriom .azlink .fabric .command ;
22
3- import com .google .gson .JsonElement ;
3+ import com .google .gson .JsonParseException ;
4+ import com .mojang .serialization .JsonOps ;
45import net .kyori .adventure .text .TextComponent ;
56import net .kyori .adventure .text .serializer .gson .GsonComponentSerializer ;
67import net .kyori .adventure .text .serializer .legacy .LegacyComponentSerializer ;
78import net .minecraft .registry .DynamicRegistryManager ;
89import net .minecraft .text .Text ;
10+ import net .minecraft .text .TextCodecs ;
911
1012public final class TextAdapter {
1113
@@ -20,8 +22,12 @@ private TextAdapter() {
2022
2123 public static Text toText (String message ) {
2224 TextComponent component = LEGACY_SERIALIZER .deserialize (message );
23- JsonElement json = GsonComponentSerializer .gson ().serializeToTree (component );
2425
25- return Text .Serialization .fromJsonTree (json , DynamicRegistryManager .EMPTY );
26+ // Code from LuckPerms, under MIT License
27+ // https://github.com/LuckPerms/LuckPerms
28+ return TextCodecs .CODEC .decode (
29+ DynamicRegistryManager .EMPTY .getOps (JsonOps .INSTANCE ),
30+ GsonComponentSerializer .gson ().serializeToTree (component )
31+ ).getOrThrow (JsonParseException ::new ).getFirst ();
2632 }
2733}
Original file line number Diff line number Diff line change 99}
1010
1111ext {
12- minecraft_version = ' 1.21.4 '
13- neo_version = ' 21.4.10 -beta'
12+ minecraft_version = ' 1.21.8 '
13+ neo_version = ' 21.8.4 -beta'
1414}
1515
1616neoForge {
Original file line number Diff line number Diff line change 11package com .azuriom .azlink .neoforge .command ;
22
3- import com .google . gson . JsonElement ;
3+ import com .mojang . serialization . JsonOps ;
44import net .kyori .adventure .text .TextComponent ;
55import net .kyori .adventure .text .serializer .gson .GsonComponentSerializer ;
66import net .kyori .adventure .text .serializer .legacy .LegacyComponentSerializer ;
77import net .minecraft .core .RegistryAccess ;
88import net .minecraft .network .chat .Component ;
9+ import net .minecraft .network .chat .ComponentSerialization ;
910
1011public final class ComponentAdapter {
1112
@@ -20,7 +21,12 @@ private ComponentAdapter() {
2021
2122 public static Component toComponent (String message ) {
2223 TextComponent component = LEGACY_SERIALIZER .deserialize (message );
23- JsonElement json = GsonComponentSerializer .gson ().serializeToTree (component );
2424
25- return Component .Serializer .fromJson (json , RegistryAccess .EMPTY ); }
25+ // Code from LuckPerms, under MIT License
26+ // https://github.com/LuckPerms/LuckPerms
27+ return ComponentSerialization .CODEC .decode (
28+ RegistryAccess .EMPTY .createSerializationContext (JsonOps .INSTANCE ),
29+ GsonComponentSerializer .gson ().serializeToTree (component )
30+ ).getOrThrow (IllegalArgumentException ::new ).getFirst ();
31+ }
2632}
You can’t perform that action at this time.
0 commit comments