Skip to content

Commit 899b788

Browse files
committed
Actually only remove the output and not the whole Map Entry
1 parent 4e84eaa commit 899b788

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/main/java/gregtech/integration/exnihilo/recipes/SieveDrops.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,26 @@ private static boolean validateDrops(ItemStack output, int meshlevel, float chan
4949

5050
@SuppressWarnings("unused")
5151
public static void removeDrop(ItemStack input, ItemStack output) {
52-
siftables.entrySet().removeIf(siftable -> siftable.getKey().test(input) &&
53-
siftable.getValue().removeIf(drop -> drop.getDrop().getItemStack().isItemEqual(output)));
52+
if (input.isEmpty()) {
53+
IntegrationModule.logger.error("Input stack is empty!", new Throwable());
54+
return;
55+
}
56+
if (output.isEmpty()) {
57+
IntegrationModule.logger.error("Output stack is empty!", new Throwable());
58+
return;
59+
}
60+
Optional<Ingredient> optionalIngredient = siftables.keySet().stream()
61+
.filter(ingredient -> ingredient.apply(input)).findFirst();
62+
if (optionalIngredient.isPresent()) {
63+
Ingredient ingredient = optionalIngredient.get();
64+
if (!siftables.get(ingredient)
65+
.removeIf(siftable -> siftable.getDrop().getItemStack().isItemEqual(output))) {
66+
IntegrationModule.logger.error("Cannot find Output for stack {} and Input stack {}",
67+
output.getDisplayName(), input.getDisplayName(), new Throwable());
68+
}
69+
} else {
70+
IntegrationModule.logger.error("Cannot find Input for stack {}", input.getDisplayName(), new Throwable());
71+
}
5472
}
5573

5674
public static void addDrop(Block input, ItemStack output, int meshLevel, float chance) {

0 commit comments

Comments
 (0)