• 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

3.7
/src/main/java/org/cyclops/integrateddynamics/core/evaluate/variable/ValueObjectTypeRecipe.java
1
package org.cyclops.integrateddynamics.core.evaluate.variable;
2

3
import com.google.common.collect.Iterables;
4
import lombok.ToString;
5
import net.minecraft.network.chat.Component;
6
import net.minecraft.network.chat.MutableComponent;
7
import net.minecraft.world.level.storage.ValueInput;
8
import net.minecraft.world.level.storage.ValueOutput;
9
import org.cyclops.commoncapabilities.api.capability.recipehandler.IPrototypedIngredientAlternatives;
10
import org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition;
11
import org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient;
12
import org.cyclops.commoncapabilities.api.ingredient.IngredientComponent;
13
import org.cyclops.integrateddynamics.api.evaluate.variable.IValue;
14
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueTypeNamed;
15
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueTypeNullable;
16
import org.cyclops.integrateddynamics.api.ingredient.IIngredientComponentHandler;
17
import org.cyclops.integrateddynamics.core.ingredient.IngredientComponentHandlers;
18
import org.cyclops.integrateddynamics.core.logicprogrammer.ValueTypeLPElementBase;
19
import org.cyclops.integrateddynamics.core.logicprogrammer.ValueTypeRecipeLPElement;
20

21
/**
22
 * Value type with values that are recipes.
23
 * @author rubensworks
24
 */
25
public class ValueObjectTypeRecipe extends ValueObjectTypeBase<ValueObjectTypeRecipe.ValueRecipe> implements
26
        IValueTypeNamed<ValueObjectTypeRecipe.ValueRecipe>, IValueTypeNullable<ValueObjectTypeRecipe.ValueRecipe> {
27

28
    public ValueObjectTypeRecipe() {
29
        super("recipe", ValueObjectTypeRecipe.ValueRecipe.class);
4✔
30
    }
1✔
31

32
    @Override
33
    protected ValueObjectTypeRecipeClient constructClient() {
34
        return new ValueObjectTypeRecipeClient(this);
×
35
    }
36

37
    @Override
38
    public ValueRecipe getDefault() {
39
        return ValueRecipe.of(null);
×
40
    }
41

42
    @Override
43
    public MutableComponent toCompactString(ValueRecipe value) {
44
        if (value.getRawValue().isPresent()) {
×
45
            IRecipeDefinition recipe = value.getRawValue().get();
×
46
            MutableComponent sb = Component.literal("");
×
47

48
            sb.append(ValueObjectTypeIngredients.ingredientsToTextComponent(recipe.getOutput()));
×
49
            sb.append(Component.literal(" <- "));
×
50
            boolean first = true;
×
51

52
            for (IngredientComponent<?, ?> component : recipe.getInputComponents()) {
×
53
                IIngredientComponentHandler handler = IngredientComponentHandlers.REGISTRY.getComponentHandler(component);
×
54
                int i = 0;
×
55
                for (IPrototypedIngredientAlternatives<?, ?> instances : recipe.getInputs(component)) {
×
56
                    IPrototypedIngredient<?, ?> prototypedIngredient = Iterables.getFirst(instances.getAlternatives(), null);
×
57
                    IValue v;
58
                    if (prototypedIngredient == null) {
×
59
                        v  = handler.getValueType().getDefault();
×
60
                    } else {
61
                        v = handler.toValue(prototypedIngredient.getPrototype());
×
62
                    }
63
                    if (!first) {
×
64
                        sb.append(Component.literal(", "));
×
65
                    } else {
66
                        first = false;
×
67
                    }
68
                    sb.append(handler.toCompactString(v));
×
69
                    if (recipe.isInputReusable(component, i)) {
×
70
                        sb.append("*");
×
71
                    }
72
                    i++;
×
73
                }
×
74
            }
×
75
            return sb;
×
76
        }
77
        return Component.literal("");
×
78
    }
79

80
    @Override
81
    public void serialize(ValueOutput valueOutput, ValueRecipe value) {
82
        value.getRawValue().ifPresent(v -> IRecipeDefinition.serialize(valueOutput.child("v"), v));
×
83
    }
×
84

85
    @Override
86
    public ValueRecipe deserialize(ValueInput valueInput) {
87
        return ValueRecipe.of(valueInput.child("v").map(IRecipeDefinition::deserialize).orElse(null));
×
88
    }
89

90
    @Override
91
    public String getName(ValueRecipe a) {
92
        return toCompactString(a).getString();
×
93
    }
94

95
    @Override
96
    public boolean isNull(ValueRecipe a) {
97
        return !a.getRawValue().isPresent();
×
98
    }
99

100
    @Override
101
    public ValueTypeLPElementBase createLogicProgrammerElement() {
102
        return new ValueTypeRecipeLPElement();
×
103
    }
104

105
    @ToString
×
106
    public static class ValueRecipe extends ValueOptionalBase<IRecipeDefinition> {
107

108
        private ValueRecipe(IRecipeDefinition recipe) {
109
            super(ValueTypes.OBJECT_RECIPE, recipe);
×
110
        }
×
111

112
        public static ValueRecipe of(IRecipeDefinition recipe) {
113
            return new ValueRecipe(recipe);
×
114
        }
115

116
        @Override
117
        protected boolean isEqual(IRecipeDefinition a, IRecipeDefinition b) {
118
            return a.equals(b);
×
119
        }
120
    }
121

122
}
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