|
47 | 47 | import com.gregtechceu.gtceu.api.pattern.MultiblockShapeInfo; |
48 | 48 | import com.gregtechceu.gtceu.api.pattern.Predicates; |
49 | 49 | import com.gregtechceu.gtceu.api.recipe.DummyCraftingContainer; |
50 | | -import com.gregtechceu.gtceu.api.recipe.GTRecipe; |
51 | 50 | import com.gregtechceu.gtceu.api.recipe.GTRecipeSerializer; |
52 | 51 | import com.gregtechceu.gtceu.api.recipe.GTRecipeType; |
53 | 52 | import com.gregtechceu.gtceu.api.recipe.OverclockingLogic; |
54 | 53 | import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; |
55 | 54 | import com.gregtechceu.gtceu.api.recipe.chance.logic.ChanceLogic; |
56 | 55 | import com.gregtechceu.gtceu.api.recipe.ingredient.EnergyStack; |
| 56 | +import com.gregtechceu.gtceu.api.recipe.lookup.RecipeManagerHandler; |
57 | 57 | import com.gregtechceu.gtceu.api.recipe.modifier.ModifierFunction; |
58 | 58 | import com.gregtechceu.gtceu.api.registry.GTRegistries; |
59 | 59 | import com.gregtechceu.gtceu.api.registry.registrate.MultiblockMachineBuilder; |
|
92 | 92 | import com.gregtechceu.gtceu.integration.kjs.recipe.components.GTRecipeComponents; |
93 | 93 | import com.gregtechceu.gtceu.utils.data.RuntimeBlockStateProvider; |
94 | 94 |
|
95 | | -import net.minecraft.core.registries.BuiltInRegistries; |
96 | 95 | import net.minecraft.data.PackOutput; |
97 | 96 | import net.minecraft.nbt.NbtOps; |
98 | 97 | import net.minecraft.resources.ResourceLocation; |
|
105 | 104 | import net.minecraft.world.level.block.SoundType; |
106 | 105 | import net.minecraft.world.level.levelgen.placement.HeightRangePlacement; |
107 | 106 | import net.minecraftforge.items.ItemStackHandler; |
| 107 | +import net.minecraftforge.registries.ForgeRegistries; |
108 | 108 |
|
109 | 109 | import com.mojang.serialization.DataResult; |
110 | 110 | import dev.latvian.mods.kubejs.KubeJSPaths; |
|
133 | 133 | import java.util.*; |
134 | 134 | import java.util.Map; |
135 | 135 | import java.util.stream.Collectors; |
136 | | -import java.util.stream.Stream; |
137 | 136 |
|
138 | 137 | import static dev.latvian.mods.kubejs.recipe.schema.minecraft.ShapedRecipeSchema.KEY; |
139 | 138 | import static dev.latvian.mods.kubejs.recipe.schema.minecraft.ShapedRecipeSchema.PATTERN; |
@@ -523,39 +522,29 @@ public void injectRuntimeRecipes(RecipesEventJS event, RecipeManager manager, |
523 | 522 | GTRecipeSerializer.SERIALIZER.fromJson(builtRecipe.getId(), builtRecipe.serializeRecipe()))); |
524 | 523 |
|
525 | 524 | // clone vanilla recipes for stuff like electric furnaces, etc |
526 | | - for (RecipeType<?> recipeType : BuiltInRegistries.RECIPE_TYPE) { |
527 | | - if (recipeType instanceof GTRecipeType gtRecipeType) { |
528 | | - gtRecipeType.getLookup().removeAllRecipes(); |
529 | | - |
530 | | - var proxyRecipes = gtRecipeType.getProxyRecipes(); |
531 | | - for (Map.Entry<RecipeType<?>, List<GTRecipe>> entry : proxyRecipes.entrySet()) { |
532 | | - var type = entry.getKey(); |
533 | | - var recipes = entry.getValue(); |
534 | | - recipes.clear(); |
535 | | - for (var recipe : recipesByName.entrySet().stream() |
536 | | - .filter(recipe -> recipe.getValue().getType() == type).collect(Collectors.toSet())) { |
537 | | - recipes.add(gtRecipeType.toGTrecipe(recipe.getKey(), recipe.getValue())); |
538 | | - } |
539 | | - } |
540 | | - |
541 | | - Stream.concat( |
542 | | - recipesByName.values().stream() |
543 | | - .filter(recipe -> recipe.getType() == gtRecipeType), |
544 | | - proxyRecipes.entrySet().stream() |
545 | | - .flatMap(entry -> entry.getValue().stream())) |
546 | | - .filter(GTRecipe.class::isInstance) |
547 | | - .map(GTRecipe.class::cast) |
548 | | - .forEach(gtRecipe -> gtRecipeType.getLookup().addRecipe(gtRecipe)); |
| 525 | + for (RecipeType<?> recipeType : ForgeRegistries.RECIPE_TYPES) { |
| 526 | + if (!(recipeType instanceof GTRecipeType gtRecipeType)) { |
| 527 | + continue; |
549 | 528 | } |
| 529 | + gtRecipeType.getLookup().removeAllRecipes(); |
| 530 | + gtRecipeType.getProxyRecipes().forEach((type, list) -> { |
| 531 | + RecipeManagerHandler.addProxyRecipesToLookup(recipesByName, gtRecipeType, type, list); |
| 532 | + }); |
| 533 | + RecipeManagerHandler.addRecipesToLookup(recipesByName, gtRecipeType); |
550 | 534 | } |
551 | 535 | } |
552 | 536 |
|
553 | 537 | private static void handleGTRecipe(Map<ResourceLocation, Recipe<?>> recipesByName, |
554 | 538 | GTRecipeSchema.GTRecipeJS gtRecipe) { |
555 | | - // get the recipe ID without the leading type path |
556 | | - GTRecipeBuilder builder = ((GTRecipeType) BuiltInRegistries.RECIPE_TYPE.get(gtRecipe.type.id)) |
557 | | - .recipeBuilder(gtRecipe.idWithoutType()); |
| 539 | + GTRecipeType gtRecipeType = (GTRecipeType) ForgeRegistries.RECIPE_TYPES.getValue(gtRecipe.getType()); |
| 540 | + if (gtRecipeType == null) { |
| 541 | + GTCEu.LOGGER.error("Failed to get GTRecipeType from GTRecipe: '{}' with type '{}'", gtRecipe.getId(), |
| 542 | + gtRecipe.getType()); |
| 543 | + return; |
| 544 | + } |
558 | 545 |
|
| 546 | + // get the recipe ID without the leading type path |
| 547 | + GTRecipeBuilder builder = gtRecipeType.recipeBuilder(gtRecipe.idWithoutType()); |
559 | 548 | if (gtRecipe.getValue(GTRecipeSchema.DURATION) != null) { |
560 | 549 | builder.duration = gtRecipe.getValue(GTRecipeSchema.DURATION).intValue(); |
561 | 550 | } |
|
0 commit comments