• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CyclopsMC / IntegratedDynamics / 20210191346

14 Dec 2025 03:32PM UTC coverage: 19.514% (-33.5%) from 53.061%
20210191346

push

github

rubensworks
Remove deprecations

663 of 8728 branches covered (7.6%)

Branch coverage included in aggregate %.

6786 of 29445 relevant lines covered (23.05%)

1.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/PositionedOperatorRecipeHandlerInputs.java
1
package org.cyclops.integrateddynamics.core.evaluate.operator;
2

3
import com.google.common.cache.Cache;
4
import com.google.common.cache.CacheBuilder;
5
import com.google.common.collect.Lists;
6
import net.minecraft.core.Direction;
7
import org.apache.commons.lang3.tuple.Pair;
8
import org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition;
9
import org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeHandler;
10
import org.cyclops.commoncapabilities.api.ingredient.IMixedIngredients;
11
import org.cyclops.commoncapabilities.api.ingredient.MixedIngredients;
12
import org.cyclops.cyclopscore.datastructure.DimPos;
13
import org.cyclops.integrateddynamics.api.evaluate.EvaluationException;
14
import org.cyclops.integrateddynamics.api.evaluate.variable.IValue;
15
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueType;
16
import org.cyclops.integrateddynamics.core.evaluate.variable.ValueObjectTypeIngredients;
17
import org.cyclops.integrateddynamics.core.evaluate.variable.ValueTypeList;
18
import org.cyclops.integrateddynamics.core.evaluate.variable.ValueTypes;
19

20
import java.util.Collections;
21
import java.util.List;
22
import java.util.concurrent.ExecutionException;
23
import java.util.concurrent.TimeUnit;
24

25
/**
26
 * An operator that gets the input of a recipe based on an output.
27
 * @author rubensworks
28
 */
29
public class PositionedOperatorRecipeHandlerInputs<T extends IValueType<V>, V extends IValue> extends PositionedOperatorRecipeHandler<T, V> {
30

31
    private static final Cache<Pair<Pair<DimPos, Direction>, ValueObjectTypeIngredients.ValueIngredients>,
32
            ValueTypeList.ValueList> CACHE = CacheBuilder.newBuilder()
×
33
            .expireAfterAccess(20, TimeUnit.SECONDS).build();
×
34

35
    public PositionedOperatorRecipeHandlerInputs(DimPos pos, Direction side) {
36
        super("recipeinputsbyoutput", new Function(), ValueTypes.LIST, pos, side);
×
37
    }
×
38

39
    public PositionedOperatorRecipeHandlerInputs() {
40
        this(null, null);
×
41
    }
×
42

43
    public static class Function extends PositionedOperatorRecipeHandler.Function {
×
44

45
        @Override
46
        public IValue evaluate(SafeVariablesGetter variables) throws EvaluationException {
47
            ValueObjectTypeIngredients.ValueIngredients ingredients = variables.getValue(0, ValueTypes.OBJECT_INGREDIENTS);
×
48
            IRecipeHandler recipeHandler = (IRecipeHandler) this.getOperator().getRecipeHandler().orElse(null);
×
49
            if (recipeHandler != null && ingredients.getRawValue().isPresent()) {
×
50
                Pair<Pair<DimPos, Direction>, ValueObjectTypeIngredients.ValueIngredients> key =
×
51
                        Pair.of(Pair.of(this.getOperator().getPos(), this.getOperator().getSide()), ingredients);
×
52
                try {
53
                    return CACHE.get(key, () -> {
×
54
                        IMixedIngredients givenIngredients = ingredients.getRawValue().get();
×
55
                        List<ValueObjectTypeIngredients.ValueIngredients> validIngredients = Lists.newArrayList();
×
56
                        for (IRecipeDefinition recipe : recipeHandler.getRecipes()) {
×
57
                            IMixedIngredients outputIngredients = recipe.getOutput();
×
58
                            // If one valid recipe is found, add to list
59
                            if (validateIngredientsPartial(outputIngredients, givenIngredients)) {
×
60
                                validIngredients.add(ValueObjectTypeIngredients.ValueIngredients.of(
×
61
                                        MixedIngredients.fromRecipeInput(recipe)));
×
62
                            }
63
                        }
×
64
                        return ValueTypeList.ValueList.ofList(ValueTypes.OBJECT_INGREDIENTS, validIngredients);
×
65
                    });
66
                } catch (ExecutionException e) {
×
67

68
                }
69
            }
70
            return ValueTypeList.ValueList.ofList(ValueTypes.OBJECT_INGREDIENTS, Collections.emptyList());
×
71
        }
72
    }
73

74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc