| 
 | 1 | +package net.swedz.tesseract.neoforge.compat.mi.mixin.client.fix;  | 
 | 2 | + | 
 | 3 | +import aztech.modern_industrialization.compat.rei.machines.MachineCategoryParams;  | 
 | 4 | +import aztech.modern_industrialization.compat.viewer.usage.MachineCategory;  | 
 | 5 | +import aztech.modern_industrialization.machines.init.MIMachineRecipeTypes;  | 
 | 6 | +import aztech.modern_industrialization.machines.recipe.MachineRecipe;  | 
 | 7 | +import net.minecraft.client.Minecraft;  | 
 | 8 | +import net.minecraft.core.RegistryAccess;  | 
 | 9 | +import net.minecraft.world.item.crafting.RecipeHolder;  | 
 | 10 | +import net.minecraft.world.item.crafting.RecipeManager;  | 
 | 11 | +import org.spongepowered.asm.mixin.Final;  | 
 | 12 | +import org.spongepowered.asm.mixin.Mixin;  | 
 | 13 | +import org.spongepowered.asm.mixin.Shadow;  | 
 | 14 | +import org.spongepowered.asm.mixin.injection.At;  | 
 | 15 | +import org.spongepowered.asm.mixin.injection.Inject;  | 
 | 16 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;  | 
 | 17 | + | 
 | 18 | +import java.util.Comparator;  | 
 | 19 | +import java.util.function.Consumer;  | 
 | 20 | + | 
 | 21 | +@Mixin(  | 
 | 22 | +		value = MachineCategory.class,  | 
 | 23 | +		remap = false  | 
 | 24 | +)  | 
 | 25 | +public class BuildRecipesMachineCategoryClientMixin  | 
 | 26 | +{  | 
 | 27 | +	@Shadow  | 
 | 28 | +	@Final  | 
 | 29 | +	private MachineCategoryParams params;  | 
 | 30 | +	  | 
 | 31 | +	@Inject(  | 
 | 32 | +			method = "buildRecipes",  | 
 | 33 | +			at = @At("HEAD"),  | 
 | 34 | +			cancellable = true  | 
 | 35 | +	)  | 
 | 36 | +	private void buildRecipes(RecipeManager recipeManager, RegistryAccess registryAccess,  | 
 | 37 | +							  Consumer<RecipeHolder<MachineRecipe>> consumer,  | 
 | 38 | +							  CallbackInfo callback)  | 
 | 39 | +	{  | 
 | 40 | +		callback.cancel();  | 
 | 41 | +		  | 
 | 42 | +		MIMachineRecipeTypes.getRecipeTypes().stream()  | 
 | 43 | +				.flatMap((type) -> type.getRecipes(Minecraft.getInstance().level).stream())  | 
 | 44 | +				.filter((recipe) -> params.recipePredicate.test(recipe.value()))  | 
 | 45 | +				.sorted(Comparator.comparing(RecipeHolder::id))  | 
 | 46 | +				.forEach(consumer);  | 
 | 47 | +	}  | 
 | 48 | +}  | 
0 commit comments