• 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

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.cyclopscore.init.ModBaseNeoForge;
6
import org.cyclops.integrateddynamics.api.evaluate.EvaluationException;
7
import org.cyclops.integrateddynamics.api.evaluate.variable.IValue;
8
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueType;
9
import org.cyclops.integrateddynamics.api.network.INetwork;
10
import org.cyclops.integrateddynamics.api.network.IPartNetwork;
11
import org.cyclops.integrateddynamics.api.part.IPartState;
12
import org.cyclops.integrateddynamics.api.part.IPartType;
13
import org.cyclops.integrateddynamics.api.part.PartTarget;
14
import org.cyclops.integrateddynamics.api.part.aspect.AspectUpdateType;
15
import org.cyclops.integrateddynamics.api.part.aspect.IAspectRead;
16
import org.cyclops.integrateddynamics.api.part.aspect.IAspectVariable;
17
import org.cyclops.integrateddynamics.api.part.aspect.property.IAspectProperties;
18
import org.cyclops.integrateddynamics.api.part.read.IPartStateReader;
19
import org.cyclops.integrateddynamics.api.part.read.IPartTypeReader;
20
import org.cyclops.integrateddynamics.core.part.aspect.LazyAspectVariable;
21
import org.cyclops.integrateddynamics.part.aspect.AspectBase;
22
import org.cyclops.integrateddynamics.part.aspect.Aspects;
23

24
import java.util.function.Supplier;
25

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

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

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

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

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

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

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

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

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