11package net .blay09 .mods .balm .fabric .client .internal ;
22
3+ import com .google .common .collect .ImmutableMap ;
4+ import com .google .common .collect .ImmutableMultimap ;
35import net .blay09 .mods .balm .Balm ;
6+ import net .blay09 .mods .balm .client .BalmClient ;
47import net .blay09 .mods .balm .client .platform .internal .BalmClientSafeClientAccess ;
58import net .blay09 .mods .balm .fabric .client .internal .platform .runtime .internal .FabricBalmClientRuntime ;
9+ import net .blay09 .mods .balm .fabric .internal .mixin .RecipeMapAccessor ;
610import net .blay09 .mods .balm .fabric .network .internal .FabricBalmNetworking ;
7- import net .blay09 .mods .balm .client .BalmClient ;
811import net .blay09 .mods .balm .network .internal .RemotePlayerModList ;
912import net .fabricmc .api .ClientModInitializer ;
1013import net .fabricmc .fabric .api .client .event .lifecycle .v1 .ClientLifecycleEvents ;
1114import net .fabricmc .fabric .api .client .recipe .v1 .sync .ClientRecipeSynchronizedEvent ;
12- import net .minecraft .world .item .crafting .RecipeMap ;
15+ import net .minecraft .resources .ResourceKey ;
16+ import net .minecraft .world .item .crafting .Recipe ;
17+ import net .minecraft .world .item .crafting .RecipeHolder ;
18+ import net .minecraft .world .item .crafting .RecipeType ;
1319
1420public class FabricBalmClient implements ClientModInitializer {
1521 @ Override
@@ -20,7 +26,15 @@ public void onInitializeClient() {
2026
2127 ClientRecipeSynchronizedEvent .EVENT .register ((client , synchronizedRecipes ) -> {
2228 if (Balm .safeClientAccess () instanceof BalmClientSafeClientAccess clientProxy ) {
23- clientProxy .setSyncedRecipes (RecipeMap .create (synchronizedRecipes .recipes ()));
29+ ImmutableMultimap .Builder <RecipeType <?>, RecipeHolder <?>> byType = ImmutableMultimap .builder ();
30+ ImmutableMap .Builder <ResourceKey <Recipe <?>>, RecipeHolder <?>> byKey = ImmutableMap .builder ();
31+ synchronizedRecipes .recipes ().forEach ((recipe ) -> {
32+ final var legacyRecipeHolder = new RecipeHolder <>(recipe .id (), recipe .value ());
33+ byType .put (recipe .value ().getType (), legacyRecipeHolder );
34+ byKey .put (recipe .id (), legacyRecipeHolder );
35+ });
36+ final var recipeMap = RecipeMapAccessor .balm$create (byType .build (), byKey .build ());
37+ clientProxy .setSyncedRecipes (recipeMap );
2438 }
2539 });
2640
0 commit comments