From 4db9bc68d9be490b17979fcd6461a606f30edb6f Mon Sep 17 00:00:00 2001 From: Dennis C Date: Sat, 27 Aug 2022 20:17:17 +0200 Subject: [PATCH] Fix circular dependency in static init of RecipeBookRegistry (#8996) --- .../net/minecraft/client/Minecraft.java.patch | 3 ++- .../client/RecipeBookRegistry.java | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index f5889b98d5..e67d8e15fe 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -41,10 +41,11 @@ this.f_91068_ = new KeyboardHandler(this); this.f_91068_.m_90887_(this.f_90990_.m_85439_()); RenderSystem.m_69580_(this.f_91066_.f_92035_, false); -@@ -456,6 +_,7 @@ +@@ -456,6 +_,8 @@ this.f_91042_.m_83931_(0.0F, 0.0F, 0.0F, 0.0F); this.f_91042_.m_83954_(f_91002_); this.f_91036_ = new ReloadableResourceManager(PackType.CLIENT_RESOURCES); ++ net.minecraftforge.client.RecipeBookRegistry.initDefaultValues(); + net.minecraftforge.client.loading.ClientModLoader.begin(this, this.f_91038_, this.f_91036_, this.f_91037_); this.f_91038_.m_10506_(); this.f_91066_.m_92145_(this.f_91038_); diff --git a/src/main/java/net/minecraftforge/client/RecipeBookRegistry.java b/src/main/java/net/minecraftforge/client/RecipeBookRegistry.java index 5b54ec5e9b..20eb1ce921 100644 --- a/src/main/java/net/minecraftforge/client/RecipeBookRegistry.java +++ b/src/main/java/net/minecraftforge/client/RecipeBookRegistry.java @@ -11,6 +11,7 @@ import net.minecraft.client.RecipeBookCategories; import net.minecraft.world.inventory.RecipeBookType; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeType; +import org.jetbrains.annotations.ApiStatus; import javax.annotation.Nullable; import java.util.*; @@ -20,8 +21,7 @@ import static net.minecraft.client.RecipeBookCategories.*; public class RecipeBookRegistry { - // The ImmutableMap is the patched out value of AGGREGATE_CATEGORIES - private static final Map> MUTABLE_AGGREGATE_CATEGORIES = new HashMap<>(ImmutableMap.of(CRAFTING_SEARCH, ImmutableList.of(CRAFTING_EQUIPMENT, CRAFTING_BUILDING_BLOCKS, CRAFTING_MISC, CRAFTING_REDSTONE), FURNACE_SEARCH, ImmutableList.of(FURNACE_FOOD, FURNACE_BLOCKS, FURNACE_MISC), BLAST_FURNACE_SEARCH, ImmutableList.of(BLAST_FURNACE_BLOCKS, BLAST_FURNACE_MISC), SMOKER_SEARCH, ImmutableList.of(SMOKER_FOOD))); + private static final Map> MUTABLE_AGGREGATE_CATEGORIES = new HashMap<>(); private static final Map> TYPE_TO_CATEGORIES = new HashMap<>(); private static final Map, Function, RecipeBookCategories>> FIND_CATEGORIES_FOR_TYPE = new HashMap<>(); @@ -50,4 +50,16 @@ public class RecipeBookRegistry { return Optional.ofNullable(FIND_CATEGORIES_FOR_TYPE.get(type)).map(f -> f.apply(recipe)).orElse(null); } + + @ApiStatus.Internal + public static void initDefaultValues() + { + // The ImmutableMap is the patched out value of AGGREGATE_CATEGORIES + MUTABLE_AGGREGATE_CATEGORIES.putAll(ImmutableMap.of( + CRAFTING_SEARCH, ImmutableList.of(CRAFTING_EQUIPMENT, CRAFTING_BUILDING_BLOCKS, CRAFTING_MISC, CRAFTING_REDSTONE), + FURNACE_SEARCH, ImmutableList.of(FURNACE_FOOD, FURNACE_BLOCKS, FURNACE_MISC), + BLAST_FURNACE_SEARCH, ImmutableList.of(BLAST_FURNACE_BLOCKS, BLAST_FURNACE_MISC), + SMOKER_SEARCH, ImmutableList.of(SMOKER_FOOD) + )); + } }