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

CyclopsMC / IntegratedDynamics / 20210191346

14 Dec 2025 03:32PM UTC coverage: 19.514% (-33.5%) from 53.061%
20210191346

push

github

rubensworks
Remove deprecations

663 of 8728 branches covered (7.6%)

Branch coverage included in aggregate %.

6786 of 29445 relevant lines covered (23.05%)

1.09 hits per line

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

13.64
/src/main/java/org/cyclops/integrateddynamics/core/TickHandler.java
1
package org.cyclops.integrateddynamics.core;
2

3
import net.neoforged.bus.api.SubscribeEvent;
4
import net.neoforged.neoforge.event.tick.ServerTickEvent;
5
import org.cyclops.cyclopscore.helper.IModHelpers;
6
import org.cyclops.integrateddynamics.IntegratedDynamics;
7
import org.cyclops.integrateddynamics.api.network.IFullNetworkListener;
8
import org.cyclops.integrateddynamics.api.network.INetwork;
9
import org.cyclops.integrateddynamics.api.network.IPositionedAddonsNetworkIngredients;
10
import org.cyclops.integrateddynamics.core.helper.NetworkHelpers;
11
import org.cyclops.integrateddynamics.core.network.PartOffsetsClientNotifier;
12
import org.cyclops.integrateddynamics.core.network.diagnostics.NetworkDiagnostics;
13
import org.cyclops.integrateddynamics.core.persist.world.NetworkWorldStorage;
14

15
/**
16
 * Handles server ticks to delegate to networks.
17
 * @author rubensworks
18
 */
19
public final class TickHandler {
20

21
    private static TickHandler INSTANCE;
22
    private int tick = 0;
3✔
23
    private boolean shouldCrash = false;
3✔
24
    public boolean ticked = false;
3✔
25

26
    private TickHandler() {
2✔
27

28
    }
1✔
29

30
    public static TickHandler getInstance() {
31
        if(INSTANCE == null) {
2!
32
            INSTANCE = new TickHandler();
4✔
33
        }
34
        return INSTANCE;
2✔
35
    }
36

37
    public void setShouldCrash() {
38
        this.shouldCrash = true;
×
39
    }
×
40

41
    @SubscribeEvent
42
    public void onTick(ServerTickEvent.Post event) {
43
        if (shouldCrash) {
×
44
            throw new RuntimeException("Forcefully crashed the server.");
×
45
        }
46
        // Invoke update logic irrespective of safe-mode
47
        for (INetwork network : NetworkWorldStorage.Access.getInstance(IntegratedDynamics._instance).get().getNetworks()) {
×
48
            network.updateGuaranteed();
×
49
        }
×
50

51
        // Do further network updates only when safe-mode is not enabled
52
        if (NetworkHelpers.shouldWork()) {
×
53
            boolean isBeingDiagnozed = NetworkDiagnostics.getInstance().isBeingDiagnozed();
×
54
            if (isBeingDiagnozed) {
×
55
                tick = (tick + 1) % IModHelpers.get().getMinecraftHelpers().getSecondInTicks();
×
56
            }
57
            boolean shouldSendTickDurationInfo = isBeingDiagnozed && tick == 0;
×
58
            for (INetwork network : NetworkWorldStorage.Access.getInstance(IntegratedDynamics._instance).get().getNetworks()) {
×
59
                if (isBeingDiagnozed && (shouldSendTickDurationInfo || network.hasChanged())) {
×
60
                    NetworkDiagnostics.getInstance().sendNetworkUpdate(network);
×
61
                    network.resetLastSecondDurations();
×
62

63
                    // Also reset durations of indexes
64
                    for (IFullNetworkListener fullNetworkListener : network.getFullNetworkListeners()) {
×
65
                        if (fullNetworkListener instanceof IPositionedAddonsNetworkIngredients) {
×
66
                            IPositionedAddonsNetworkIngredients<?, ?> networkIngredients = (IPositionedAddonsNetworkIngredients<?, ?>) fullNetworkListener;
×
67
                            networkIngredients.resetLastSecondDurationsIndex();
×
68
                        }
69
                    }
70
                }
71
                try {
72
                    if (!network.isCrashed()) {
×
73
                        network.update();
×
74
                    }
75
                } catch (Throwable e) {
×
76
                    network.setCrashed(true);
×
77
                    throw e;
×
78
                }
×
79
            }
×
80
        }
81

82
        ticked = true;
×
83

84
        PartOffsetsClientNotifier.getInstance().tick();
×
85
    }
×
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