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

CyclopsMC / IntegratedDynamics / 18042102834

26 Sep 2025 03:25PM UTC coverage: 44.791% (-0.1%) from 44.905%
18042102834

push

github

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

2572 of 8540 branches covered (30.12%)

Branch coverage included in aggregate %.

11761 of 23460 relevant lines covered (50.13%)

2.38 hits per line

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

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

25
import java.util.function.Supplier;
26

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

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

37
    public AspectReadBase(String modId, String unlocalizedTypeSuffix,
38
                          IAspectProperties defaultProperties, AspectUpdateType updateType) {
39
        super(modId, defaultProperties);
×
40
        if(unlocalizedTypeSuffix == null) {
×
41
            unlocalizedTypeSuffix = "";
×
42
        }
43
        this.unlocalizedTypeSuffix = unlocalizedTypeSuffix;
×
44
        this.updateType = updateType;
×
45
        if(MinecraftHelpers.isClientSide()) {
×
46
            registerModelResourceLocation();
×
47
        }
48
    }
×
49

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

57
    protected String getUnlocalizedType() {
58
        return "read" + this.unlocalizedTypeSuffix;
×
59
    }
60

61
    @OnlyIn(Dist.CLIENT)
62
    protected void registerModelResourceLocation() {
63
        Aspects.REGISTRY.registerAspectModel(this,
×
64
                ResourceLocation.parse(getModId() + ":aspect/" + getUnlocalizedType().replaceAll("\\.", "/")));
×
65
    }
×
66

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

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

86
    @Override
87
    public AspectUpdateType getUpdateType() {
88
        return updateType;
×
89
    }
90
}
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