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

CyclopsMC / IntegratedDynamics / 20379879716

19 Dec 2025 07:05PM UTC coverage: 53.083% (+0.02%) from 53.067%
20379879716

push

github

rubensworks
Merge remote-tracking branch 'origin/master-1.21-lts' into master-1.21

2853 of 8730 branches covered (32.68%)

Branch coverage included in aggregate %.

17395 of 29414 relevant lines covered (59.14%)

3.07 hits per line

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

16.07
/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 com.google.gson.JsonParseException;
5
import lombok.ToString;
6
import net.minecraft.network.chat.Component;
7
import net.minecraft.network.chat.MutableComponent;
8
import net.minecraft.world.level.storage.ValueInput;
9
import net.minecraft.world.level.storage.ValueOutput;
10
import org.cyclops.commoncapabilities.api.capability.recipehandler.IPrototypedIngredientAlternatives;
11
import org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition;
12
import org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient;
13
import org.cyclops.commoncapabilities.api.ingredient.IngredientComponent;
14
import org.cyclops.integrateddynamics.api.evaluate.variable.IValue;
15
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueTypeNamed;
16
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueTypeNullable;
17
import org.cyclops.integrateddynamics.api.ingredient.IIngredientComponentHandler;
18
import org.cyclops.integrateddynamics.core.ingredient.IngredientComponentHandlers;
19
import org.cyclops.integrateddynamics.core.logicprogrammer.ValueTypeLPElementBase;
20
import org.cyclops.integrateddynamics.core.logicprogrammer.ValueTypeRecipeLPElement;
21

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

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

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

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

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

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

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

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

86
    @Override
87
    public ValueRecipe deserialize(ValueInput valueInput) {
88
        try {
89
            return ValueRecipe.of(valueInput.child("v").map(IRecipeDefinition::deserialize).orElse(null));
10✔
90
        } catch (IllegalArgumentException | JsonParseException e) {
×
91
            return ValueRecipe.of(null);
×
92
        }
93
    }
94

95
    @Override
96
    public String getName(ValueRecipe a) {
97
        return toCompactString(a).getString();
×
98
    }
99

100
    @Override
101
    public boolean isNull(ValueRecipe a) {
102
        return !a.getRawValue().isPresent();
×
103
    }
104

105
    @Override
106
    public ValueTypeLPElementBase createLogicProgrammerElement() {
107
        return new ValueTypeRecipeLPElement();
×
108
    }
109

110
    @ToString
×
111
    public static class ValueRecipe extends ValueOptionalBase<IRecipeDefinition> {
112

113
        private ValueRecipe(IRecipeDefinition recipe) {
114
            super(ValueTypes.OBJECT_RECIPE, recipe);
4✔
115
        }
1✔
116

117
        public static ValueRecipe of(IRecipeDefinition recipe) {
118
            return new ValueRecipe(recipe);
5✔
119
        }
120

121
        @Override
122
        protected boolean isEqual(IRecipeDefinition a, IRecipeDefinition b) {
123
            return a.equals(b);
4✔
124
        }
125
    }
126

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