11package net .blay09 .mods .shogi .common .network ;
22
3- import com .google .gson .JsonElement ;
43import net .blay09 .mods .shogi .common .effect .compose .AggregateEffect ;
54import net .blay09 .mods .shogi .common .effect .compose .AndEffect ;
65import net .blay09 .mods .shogi .common .effect .compose .AnyEffect ;
1918import net .blay09 .mods .shogi .common .effect .variable .MacroAssignmentEffect ;
2019import net .blay09 .mods .shogi .common .effect .variable .MissingVariableFailure ;
2120import net .blay09 .mods .shogi .common .effect .variable .VariableEffect ;
22- import net .blay09 .mods .shogi .effect .ConstantEffect ;
23- import net .blay09 .mods .shogi .effect .EmptyEffect ;
2421import net .blay09 .mods .shogi .effect .ShogiEffect ;
25- import net .blay09 .mods .shogi .effect .ShogiEmpty ;
26- import net .blay09 .mods .shogi .effect .failure .ShogiDeferred ;
2722import net .blay09 .mods .shogi .network .ShogiStreamCodecs ;
2823import net .minecraft .network .RegistryFriendlyByteBuf ;
29- import net .minecraft .network .chat .Component ;
30- import net .minecraft .network .chat .ComponentSerialization ;
3124import net .minecraft .network .codec .ByteBufCodecs ;
3225import net .minecraft .network .codec .StreamCodec ;
3326
3730
3831public final class ShogiDefaultStreamCodecs {
3932 private static boolean initialized ;
40- private static final StreamCodec <RegistryFriendlyByteBuf , Throwable > THROWABLE_CODEC = StreamCodec .unit (new Exception ());
41- private static final StreamCodec <RegistryFriendlyByteBuf , ShogiDeferred > DEFERRED_CODEC = StreamCodec .unit (ShogiDeferred .INSTANCE );
42- private static final StreamCodec <RegistryFriendlyByteBuf , ShogiEmpty > EMPTY_CODEC = StreamCodec .unit (EmptyEffect .INSTANCE );
43- private static final StreamCodec <RegistryFriendlyByteBuf , JsonElement > JSON_CODEC = ByteBufCodecs .lenientJson (Short .MAX_VALUE ).cast ();
4433 private static final StreamCodec <RegistryFriendlyByteBuf , ShogiEffect <?>> EFFECT_CODEC = ShogiStreamCodecs .dynamicObjectCodec ()
4534 .map (value -> (ShogiEffect <?>) value , value -> value );
4635 private static final StreamCodec <RegistryFriendlyByteBuf , List <ShogiEffect <?>>> EFFECT_LIST_CODEC = EFFECT_CODEC .apply (ByteBufCodecs .list ());
@@ -54,14 +43,6 @@ public static synchronized void registerDefaults() {
5443 }
5544 initialized = true ;
5645
57- ShogiStreamCodecs .register (id ("int" ), Integer .class , ByteBufCodecs .VAR_INT .cast ());
58- ShogiStreamCodecs .register (id ("float" ), Float .class , ByteBufCodecs .FLOAT .cast ());
59- ShogiStreamCodecs .register (id ("bool" ), Boolean .class , ByteBufCodecs .BOOL .cast ());
60- ShogiStreamCodecs .register (id ("string" ), String .class , ByteBufCodecs .STRING_UTF8 .cast ());
61- ShogiStreamCodecs .register (id ("json" ), JsonElement .class , JSON_CODEC .cast ());
62- ShogiStreamCodecs .register (id ("component" ), Component .class , ComponentSerialization .STREAM_CODEC );
63- ShogiStreamCodecs .register (id ("throwable" ), Throwable .class , THROWABLE_CODEC );
64- ShogiStreamCodecs .register (id ("list" ), List .class , ShogiStreamCodecs .LIST_STREAM_CODEC );
6546 ShogiStreamCodecs .register (id ("failure" ), FailureInformation .class , FailureInformation .STREAM_CODEC );
6647 ShogiStreamCodecs .register (id ("refusal" ), RefusalInformation .class , RefusalInformation .STREAM_CODEC );
6748 ShogiStreamCodecs .register (id ("missing_variable_failure" ), MissingVariableFailure .class , MissingVariableFailure .STREAM_CODEC );
@@ -71,13 +52,6 @@ public static synchronized void registerDefaults() {
7152 ShogiStreamCodecs .register (id ("hunger_cost" ), HungerCostInformation .class , HungerCostInformation .STREAM_CODEC );
7253 ShogiStreamCodecs .register (id ("item_cost" ), ItemCostInformation .class , ItemCostInformation .STREAM_CODEC );
7354 ShogiStreamCodecs .register (id ("cooldown" ), CooldownInformation .class , CooldownInformation .STREAM_CODEC );
74- ShogiStreamCodecs .register (id ("deferred" ), ShogiDeferred .class , DEFERRED_CODEC );
75- ShogiStreamCodecs .register (id ("empty" ), ShogiEmpty .class , EMPTY_CODEC );
76- ShogiStreamCodecs .register (id ("constant_effect" ), ConstantEffect .class , StreamCodec .composite (
77- JSON_CODEC ,
78- ConstantEffect ::value ,
79- ConstantEffect ::new
80- ));
8155 ShogiStreamCodecs .register (id ("aggregate_effect" ), AggregateEffect .class , StreamCodec .composite (
8256 EFFECT_LIST_CODEC ,
8357 AggregateEffect ::effects ,
0 commit comments