2023-02-26 12:49:00 +01:00
|
|
|
package io.gitlab.jfronny.libjf.data.manipulation.impl.mixin;
|
2021-09-10 19:02:15 +02:00
|
|
|
|
|
|
|
import com.google.gson.JsonObject;
|
2021-09-27 20:55:48 +02:00
|
|
|
import io.gitlab.jfronny.libjf.LibJf;
|
2021-10-03 13:43:16 +02:00
|
|
|
import io.gitlab.jfronny.libjf.data.manipulation.api.RecipeUtil;
|
2021-09-10 19:02:15 +02:00
|
|
|
import net.minecraft.recipe.RecipeManager;
|
|
|
|
import net.minecraft.util.Identifier;
|
|
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
|
|
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
|
|
|
|
2023-02-26 12:49:00 +01:00
|
|
|
import java.util.*;
|
2021-09-10 19:02:15 +02:00
|
|
|
|
|
|
|
@Mixin(RecipeManager.class)
|
|
|
|
public class RecipeManagerMixin {
|
2021-10-03 13:43:16 +02:00
|
|
|
@ModifyVariable(method = "apply(Ljava/util/Map;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;)V", at = @At(value = "INVOKE_ASSIGN", target = "Ljava/util/Set;iterator()Ljava/util/Iterator;", ordinal = 0, remap = false))
|
2021-09-10 19:02:15 +02:00
|
|
|
private Iterator<Map.Entry<Identifier, JsonObject>> filterIterator(Iterator<Map.Entry<Identifier, JsonObject>> iterator) {
|
|
|
|
ArrayList<Map.Entry<Identifier, JsonObject>> replacement = new ArrayList<>();
|
|
|
|
while(iterator.hasNext()) {
|
|
|
|
Map.Entry<Identifier, JsonObject> cur = iterator.next();
|
|
|
|
Identifier recipeId = cur.getKey();
|
|
|
|
|
2021-09-27 18:25:19 +02:00
|
|
|
if (RecipeUtil.isIdBlocked(recipeId)) {
|
2021-09-27 20:55:48 +02:00
|
|
|
LibJf.LOGGER.info("Blocking recipe by identifier: " + recipeId);
|
2021-09-10 19:02:15 +02:00
|
|
|
} else {
|
|
|
|
replacement.add(cur);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return replacement.iterator();
|
|
|
|
}
|
|
|
|
}
|