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

CyclopsMC / IntegratedDynamics / 16552051255

27 Jul 2025 01:58PM UTC coverage: 53.206% (+8.0%) from 45.161%
16552051255

push

github

rubensworks
Resolve minor TODOs

2888 of 8740 branches covered (33.04%)

Branch coverage included in aggregate %.

17341 of 29280 relevant lines covered (59.22%)

3.08 hits per line

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

0.0
/src/main/java/org/cyclops/integrateddynamics/api/evaluate/variable/IValueType.java
1
package org.cyclops.integrateddynamics.api.evaluate.variable;
2

3
import net.minecraft.ChatFormatting;
4
import net.minecraft.network.chat.Component;
5
import net.minecraft.network.chat.MutableComponent;
6
import net.minecraft.resources.ResourceLocation;
7
import net.minecraft.world.level.storage.ValueInput;
8
import net.minecraft.world.level.storage.ValueOutput;
9
import org.cyclops.integrateddynamics.api.evaluate.EvaluationException;
10
import org.cyclops.integrateddynamics.api.logicprogrammer.IValueTypeLogicProgrammerElement;
11

12
import javax.annotation.Nullable;
13
import java.util.Comparator;
14
import java.util.function.Consumer;
15

16
/**
17
 * Type of value
18
 * @author rubensworks
19
 */
20
public interface IValueType<V extends IValue> {
21

22
    public IValueTypeClient<V> getClient();
23

24
    /**
25
     * @return If this type is a category and should be handled accordingly.
26
     */
27
    public boolean isCategory();
28

29
    /**
30
     * @return If this type is an object type, otherwise it is a raw type.
31
     */
32
    public boolean isObject();
33

34
    /**
35
     * Create an immutable default value.
36
     * @return The default value of this type.
37
     */
38
    public V getDefault();
39

40
    /**
41
     * @return The name of this type without any prefixes.
42
     */
43
    public String getTypeName();
44

45
    /**
46
     * @return The unique name for this value type, only used for internal storage.
47
     */
48
    public ResourceLocation getUniqueName();
49

50
    /**
51
     * @return The unique name of this type that will also be used for display.
52
     */
53
    public String getTranslationKey();
54

55
    /**
56
     * Add tooltip lines for this aspect when hovered in a gui.
57
     *
58
     * @param tooltipAdder       The list to add lines to.
59
     * @param appendOptionalInfo If shift-to-show info should be added.
60
     * @param value              The value to show the tooltip for.
61
     */
62
    public void loadTooltip(Consumer<Component> tooltipAdder, boolean appendOptionalInfo, @Nullable V value);
63

64
    /**
65
     * @param value The value
66
     * @return A short string representation used in guis to show the value.
67
     */
68
    public MutableComponent toCompactString(V value);
69

70
    /**
71
     * @return The color that is used to identify this value type.
72
     */
73
    public int getDisplayColor();
74

75
    /**
76
     * @return The color that is used to identify this value type using MC formatting codes.
77
     */
78
    public ChatFormatting getDisplayColorFormat();
79

80
    /**
81
     * Check if the given type corresponds with this type.
82
     * To check bidirectional, use {@link org.cyclops.integrateddynamics.core.evaluate.variable.ValueHelpers#correspondsTo(IValueType, IValueType)}.
83
     * @param valueType The value type to check correspondence with.
84
     * @return If the given value type can be used with this value type.
85
     */
86
    public boolean correspondsTo(IValueType<?> valueType);
87

88
    /**
89
     * Serialize the given value.
90
     *
91
     * @param valueOutput Where to write the value to.
92
     * @param value       The value to serialize.
93
     */
94
    public void serialize(ValueOutput valueOutput, V value);
95

96
    /**
97
     * Check if the given value can be deserialized.
98
     *
99
     * @param valueInput The value to deserialize.
100
     * @return An error or null.
101
     */
102
    @Nullable
103
    public Component canDeserialize(ValueInput valueInput);
104

105
    /**
106
     * Deserialize the given value.
107
     *
108
     * @param valueInput The value to deserialize.
109
     * @return The deserialized value.
110
     */
111
    public V deserialize(ValueInput valueInput);
112

113
    /**
114
     * Materialize the given value so that it can exist without any external references.
115
     * @param value The value to materialize.
116
     * @return The materialized value.
117
     * @throws EvaluationException if materialization fails because of a variable evaluation.
118
     */
119
    public V materialize(V value) throws EvaluationException;
120

121
    /**
122
     * Get the string representation of the given value.
123
     * This is useful for cases when the value needs to be edited in a GUI.
124
     *
125
     * This corresponds to {@link #parseString(String)}.
126
     *
127
     * @param value A value.
128
     * @return A string representation of the given value.
129
     */
130
    public String toString(V value);
131

132
    /**
133
     * Parse the given string representation of a value.
134
     *
135
     * This corresponds to {@link #toString(IValue)}.
136
     *
137
     * @param value A string representation of a value.
138
     * @return A value.
139
     * @throws EvaluationException If parsing failed.
140
     */
141
    public V parseString(String value) throws EvaluationException;
142

143
    /**
144
     * @return A new logic programmer element for this value type.
145
     */
146
    public IValueTypeLogicProgrammerElement createLogicProgrammerElement();
147

148
    /**
149
     * Attempt to cast the given value to a value of this value type.
150
     * @param value A value of unknown type.
151
     * @return The casted value.
152
     * @throws EvaluationException If the incorrect value type was found.
153
     */
154
    public V cast(IValue value) throws EvaluationException;
155

156
    /**
157
     * Use this comparator for any comparisons with value types.
158
     */
159
    public static class ValueTypeComparator implements Comparator<IValueType<?>> {
160

161
        private static ValueTypeComparator INSTANCE = null;
×
162

163
        private ValueTypeComparator() {
164

165
        }
166

167
        public static ValueTypeComparator getInstance() {
168
            if(INSTANCE == null) INSTANCE = new ValueTypeComparator();
×
169
            return INSTANCE;
×
170
        }
171

172
        @Override
173
        public int compare(IValueType<?> o1, IValueType<?> o2) {
174
            return o1.getUniqueName().compareTo(o2.getUniqueName());
×
175
        }
176
    }
177

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