Reduce performance impact when building ingredient filter

This commit is contained in:
embeddedt 2023-01-29 20:18:05 -05:00
parent dde3a3e517
commit f24f63d6d9
No known key found for this signature in database
GPG Key ID: A69433EC199B5613

View File

@ -13,8 +13,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(IngredientListElementFactory.class)
public class IngredientListElementFactoryMixin {
private static int ingredientNum = 0;
@Inject(method = "addToBaseList", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/NonNullList;add(Ljava/lang/Object;)Z"), remap = false)
private static void checkForInterrupt(NonNullList<IIngredientListElement<?>> baseList, IIngredientManager ingredientManager, IIngredientType ingredientType, CallbackInfo ci) {
IAsyncJeiStarter.checkForLoadInterruption();
if((ingredientNum++ % 100) == 0)
IAsyncJeiStarter.checkForLoadInterruption();
}
}