Skip to content

Commit 78370e7

Browse files
committed
add debug logs for ingredients added or removed at runtime
1 parent 196b038 commit 78370e7

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Library/src/main/java/mezz/jei/library/ingredients/IngredientManager.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
import mezz.jei.common.util.ErrorUtil;
1111
import mezz.jei.common.util.Translator;
1212
import mezz.jei.core.util.WeakList;
13+
import net.minecraft.resources.ResourceLocation;
1314
import org.apache.logging.log4j.LogManager;
1415
import org.apache.logging.log4j.Logger;
1516
import org.jetbrains.annotations.Unmodifiable;
1617

1718
import java.util.Collection;
1819
import java.util.List;
1920
import java.util.Optional;
21+
import java.util.stream.Collectors;
2022

2123
public class IngredientManager implements IIngredientManager {
2224
private static final Logger LOGGER = LogManager.getLogger();
@@ -92,10 +94,17 @@ public <V> void addIngredientsAtRuntime(IIngredientType<V> ingredientType, Colle
9294
ErrorUtil.checkNotEmpty(ingredients, "ingredients");
9395

9496
IngredientInfo<V> ingredientInfo = this.registeredIngredients.getIngredientInfo(ingredientType);
97+
IIngredientHelper<V> ingredientHelper = ingredientInfo.getIngredientHelper();
9598

9699
LOGGER.info("Ingredients are being added at runtime: {} {}", ingredients.size(), ingredientType.getIngredientClass().getName());
100+
if (LOGGER.isDebugEnabled()) {
101+
String ingredientStrings = ingredients.stream()
102+
.map(ingredientHelper::getResourceLocation)
103+
.map(ResourceLocation::toString)
104+
.collect(Collectors.joining("\n", "[","]"));
105+
LOGGER.debug("Ingredients added at runtime: {}", ingredientStrings);
106+
}
97107

98-
IIngredientHelper<V> ingredientHelper = ingredientInfo.getIngredientHelper();
99108
Collection<V> validIngredients = ingredients.stream()
100109
.filter(i -> {
101110
if (!ingredientHelper.isValidIngredient(i)) {
@@ -149,8 +158,16 @@ public <V> void removeIngredientsAtRuntime(IIngredientType<V> ingredientType, Co
149158
ErrorUtil.checkNotEmpty(ingredients, "ingredients");
150159

151160
IngredientInfo<V> ingredientInfo = this.registeredIngredients.getIngredientInfo(ingredientType);
161+
IIngredientHelper<V> ingredientHelper = ingredientInfo.getIngredientHelper();
152162

153163
LOGGER.info("Ingredients are being removed at runtime: {} {}", ingredients.size(), ingredientType.getIngredientClass().getName());
164+
if (LOGGER.isDebugEnabled()) {
165+
String ingredientStrings = ingredients.stream()
166+
.map(ingredientHelper::getResourceLocation)
167+
.map(ResourceLocation::toString)
168+
.collect(Collectors.joining("\n", "[","]"));
169+
LOGGER.debug("Ingredients removed at runtime: {}", ingredientStrings);
170+
}
154171

155172
ingredientInfo.removeIngredients(ingredients);
156173

@@ -159,8 +176,6 @@ public <V> void removeIngredientsAtRuntime(IIngredientType<V> ingredientType, Co
159176
.flatMap(i -> TypedIngredient.createAndFilterInvalid(this, ingredientType, i, false).stream())
160177
.toList();
161178

162-
IIngredientHelper<V> ingredientHelper = ingredientInfo.getIngredientHelper();
163-
164179
this.listeners.forEach(listener -> listener.onIngredientsRemoved(ingredientHelper, typedIngredients));
165180
}
166181
}

0 commit comments

Comments
 (0)