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

CyclopsMC / IntegratedDynamics / 18384427956

09 Oct 2025 05:46PM UTC coverage: 53.031% (-0.04%) from 53.071%
18384427956

push

github

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

2863 of 8762 branches covered (32.68%)

Branch coverage included in aggregate %.

17326 of 29308 relevant lines covered (59.12%)

3.07 hits per line

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

68.18
/src/main/java/org/cyclops/integrateddynamics/part/aspect/read/AspectReadBase.java
1
package org.cyclops.integrateddynamics.part.aspect.read;
2

3
import net.minecraft.resources.ResourceLocation;
4
import org.cyclops.cyclopscore.helper.IModHelpers;
5
import org.cyclops.integrateddynamics.api.evaluate.EvaluationException;
6
import org.cyclops.integrateddynamics.api.evaluate.variable.IValue;
7
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueType;
8
import org.cyclops.integrateddynamics.api.network.INetwork;
9
import org.cyclops.integrateddynamics.api.network.IPartNetwork;
10
import org.cyclops.integrateddynamics.api.part.IPartState;
11
import org.cyclops.integrateddynamics.api.part.IPartType;
12
import org.cyclops.integrateddynamics.api.part.PartTarget;
13
import org.cyclops.integrateddynamics.api.part.aspect.AspectUpdateType;
14
import org.cyclops.integrateddynamics.api.part.aspect.IAspectRead;
15
import org.cyclops.integrateddynamics.api.part.aspect.IAspectVariable;
16
import org.cyclops.integrateddynamics.api.part.aspect.property.IAspectProperties;
17
import org.cyclops.integrateddynamics.api.part.read.IPartStateReader;
18
import org.cyclops.integrateddynamics.api.part.read.IPartTypeReader;
19
import org.cyclops.integrateddynamics.core.part.aspect.LazyAspectVariable;
20
import org.cyclops.integrateddynamics.part.aspect.AspectBase;
21
import org.cyclops.integrateddynamics.part.aspect.Aspects;
22

23
import java.util.function.Supplier;
24

25
/**
26
 * Base class for read aspects.
27
 * @author rubensworks
28
 */
29
public abstract class AspectReadBase<V extends IValue, T extends IValueType<V>> extends AspectBase<V, T>
30
        implements IAspectRead<V, T> {
31

32
    private final String unlocalizedTypeSuffix;
33
    private final AspectUpdateType updateType;
34

35
    public AspectReadBase(String modId, String unlocalizedTypeSuffix,
36
                          IAspectProperties defaultProperties, AspectUpdateType updateType) {
37
        super(modId, defaultProperties);
4✔
38
        if(unlocalizedTypeSuffix == null) {
2!
39
            unlocalizedTypeSuffix = "";
×
40
        }
41
        this.unlocalizedTypeSuffix = unlocalizedTypeSuffix;
3✔
42
        this.updateType = updateType;
3✔
43
        if(IModHelpers.get().getMinecraftHelpers().isClientSide()) {
4!
44
            registerModelResourceLocation();
×
45
        }
46
    }
1✔
47

48
    @SuppressWarnings("unchecked")
49
    @Override
50
    public <P extends IPartType<P, S>, S extends IPartState<P>> void update(INetwork network, IPartNetwork partNetwork, P partType, PartTarget target, S state) {
51
        IAspectVariable variable = ((IPartTypeReader) partType).getVariable(target, (IPartStateReader) state, this);
8✔
52
        variable.invalidate();
2✔
53
    }
1✔
54

55
    protected String getUnlocalizedType() {
56
        return "read" + this.unlocalizedTypeSuffix;
4✔
57
    }
58

59
    protected void registerModelResourceLocation() {
60
        Aspects.REGISTRY.getClient().registerAspectModel(this,
×
61
                ResourceLocation.parse(getModId() + ":aspect/" + getUnlocalizedType().replaceAll("\\.", "/")));
×
62
    }
×
63

64
    /**
65
     * This is only called lazy.
66
     * @param target The target to get the value for.
67
     * @param properties The optional properties for this aspect.
68
     * @return The value that will be inserted into a variable so it can be used elsewhere.
69
     * @throws EvaluationException If evaluation has gone wrong.
70
     */
71
    protected abstract V getValue(PartTarget target, IAspectProperties properties) throws EvaluationException;
72

73
    @Override
74
    public IAspectVariable<V> createNewVariable(Supplier<PartTarget> target) {
75
        return new LazyAspectVariable<V>(getValueType(), target, this) {
18✔
76
            @Override
77
            public V getValueLazy() throws EvaluationException {
78
                return AspectReadBase.this.getValue(getTarget(), getAspectProperties());
8✔
79
            }
80
        };
81
    }
82

83
    @Override
84
    public AspectUpdateType getUpdateType() {
85
        return updateType;
3✔
86
    }
87
}
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