|
6 | 6 |
|
7 | 7 | import net.minecraft.block.Block; |
8 | 8 | import net.minecraft.item.Item; |
| 9 | +import net.minecraft.item.ItemStack; |
9 | 10 | import net.minecraft.item.crafting.IRecipe; |
10 | 11 | import net.minecraft.util.ResourceLocation; |
11 | 12 | import net.minecraftforge.common.MinecraftForge; |
|
22 | 23 | import com.google.common.base.Preconditions; |
23 | 24 | import com.google.common.collect.ImmutableList; |
24 | 25 |
|
| 26 | +import gregtech.api.unification.OreDictUnifier; |
| 27 | +import gregtech.api.unification.stack.ItemAndMetadata; |
| 28 | +import gregtech.api.unification.stack.ItemMaterialInfo; |
| 29 | +import gregtech.loaders.recipe.RecyclingRecipes; |
| 30 | + |
25 | 31 | import com.github.gtexpert.core.api.GTEValues; |
26 | 32 | import com.github.gtexpert.core.api.modules.*; |
27 | 33 |
|
@@ -262,10 +268,26 @@ public void registerRecipesLow(RegistryEvent.Register<IRecipe> event) { |
262 | 268 | } |
263 | 269 |
|
264 | 270 | public void registerRecipesLowest(RegistryEvent.Register<IRecipe> event) { |
| 271 | + // Take a snapshot of all item material infos before GTE registers its LOWEST recipes. |
| 272 | + // Any new entries added by .withRecycling() during buildAndRegister() will need |
| 273 | + // recycling recipes generated, since GregTech's RecyclingRecipes.init() has already run. |
| 274 | + Set<ItemAndMetadata> existingInfos = new HashSet<>(); |
| 275 | + for (Map.Entry<ItemStack, ItemMaterialInfo> entry : OreDictUnifier.getAllItemInfos()) { |
| 276 | + existingInfos.add(new ItemAndMetadata(entry.getKey())); |
| 277 | + } |
| 278 | + |
265 | 279 | for (IGTEModule module : loadedModules) { |
266 | 280 | currentContainer = containers.get(getContainerID(module)); |
267 | 281 | module.registerRecipesLowest(event); |
268 | 282 | } |
| 283 | + |
| 284 | + // Generate recycling recipes for items newly registered via .withRecycling() |
| 285 | + for (Map.Entry<ItemStack, ItemMaterialInfo> entry : OreDictUnifier.getAllItemInfos()) { |
| 286 | + if (!existingInfos.contains(new ItemAndMetadata(entry.getKey()))) { |
| 287 | + RecyclingRecipes.registerRecyclingRecipes(entry.getKey(), |
| 288 | + new ArrayList<>(entry.getValue().getMaterials()), false, null); |
| 289 | + } |
| 290 | + } |
269 | 291 | } |
270 | 292 |
|
271 | 293 | private void configureModules(Map<String, List<IGTEModule>> modules) { |
|
0 commit comments