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

CyclopsMC / IntegratedDynamics / 22175890785

19 Feb 2026 09:22AM UTC coverage: 45.359% (+0.01%) from 45.348%
22175890785

push

github

rubensworks
Add config option to force unloaded network elements to tick

Related to #1605, #1571, #1567

2665 of 8644 branches covered (30.83%)

Branch coverage included in aggregate %.

12019 of 23729 relevant lines covered (50.65%)

2.4 hits per line

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

85.71
/src/main/java/org/cyclops/integrateddynamics/api/network/INetworkElement.java
1
package org.cyclops.integrateddynamics.api.network;
2

3
import net.minecraft.core.BlockPos;
4
import net.minecraft.core.Direction;
5
import net.minecraft.world.item.ItemStack;
6
import net.minecraft.world.level.BlockGetter;
7
import net.minecraft.world.level.Level;
8
import net.minecraft.world.level.LevelAccessor;
9
import net.minecraft.world.level.LevelReader;
10
import net.minecraft.world.level.block.Block;
11
import net.minecraft.world.level.block.state.BlockState;
12
import org.cyclops.cyclopscore.datastructure.DimPos;
13
import org.cyclops.integrateddynamics.GeneralConfig;
14

15
import javax.annotation.Nullable;
16
import java.util.List;
17

18
/**
19
 * Objects that can be an element of a {@link INetwork}.
20
 * Multiple instances for the same 'element' can be created, so the comparator implementation must
21
 * make sure that these instances are considered equal.
22
 * These instances are used as a simple way of referring to these elements.
23
 * @author rubensworks
24
 */
25
public interface INetworkElement extends Comparable<INetworkElement> {
26

27
    /**
28
     * @return The tick interval to update this element.
29
     */
30
    public int getUpdateInterval();
31

32
    /**
33
     * @return If this element should be updated. This method is only called once during network initialization.
34
     */
35
    public boolean isUpdate();
36

37
    /**
38
     * Update at the tick interval specified.
39
     * @param network The network to update in.
40
     */
41
    public void update(INetwork network);
42

43
    /**
44
     * Called right before the network is terminated or will be reset.
45
     * @param network The network to update in.
46
     */
47
    @Deprecated // TODO: try to rm in next major
48
    public void beforeNetworkKill(INetwork network);
49

50
    /**
51
     * Called right before the network is terminated or will be reset.
52
     * @param network The network to update in.
53
     * @param blockState The block state.
54
     */
55
    public default void beforeNetworkKill(INetwork network, BlockState blockState) {
56
        beforeNetworkKill(network);
3✔
57
    }
1✔
58

59
    /**
60
     * Called right after this network is initialized.
61
     * @param network The network to update in.
62
     */
63
    public void afterNetworkAlive(INetwork network);
64

65
    /**
66
     * Called right after this network has come alive again,
67
     * for example after a network restart.
68
     * @param network The network to update in.
69
     */
70
    public void afterNetworkReAlive(INetwork network);
71

72
    /**
73
     * Add the itemstacks to drop when this element is removed.
74
     * @param itemStacks The itemstack list to add to.
75
     * @param dropMainElement If the part itself should also be dropped.
76
     * @param saveState If the element state should be saved in the item.
77
     */
78
    @Deprecated // TODO: try to rm in next major
79
    public void addDrops(List<ItemStack> itemStacks, boolean dropMainElement, boolean saveState);
80

81
    /**
82
     * Add the itemstacks to drop when this element is removed.
83
     * @param blockState The block state of the container block.
84
     * @param itemStacks The itemstack list to add to.
85
     * @param dropMainElement If the part itself should also be dropped.
86
     * @param saveState If the element state should be saved in the item.
87
     */
88
    public default void addDrops(BlockState blockState, List<ItemStack> itemStacks, boolean dropMainElement, boolean saveState) {
89
        this.addDrops(itemStacks, dropMainElement, saveState);
5✔
90
    }
1✔
91

92
    /**
93
     * Called when this element is added to the network.
94
     * @param network The network.
95
     * @return If the addition succeeded.
96
     */
97
    public boolean onNetworkAddition(INetwork network);
98

99
    /**
100
     * Called when this element is removed from the network.
101
     * @param network The network.
102
     */
103
    @Deprecated // TODO: try to rm in next major
104
    public void onNetworkRemoval(INetwork network);
105

106
    /**
107
     * Called when this element is removed from the network.
108
     * @param network The network.
109
     * @param blockState The block state.
110
     */
111
    public default void onNetworkRemoval(INetwork network, BlockState blockState) {
112
        onNetworkRemoval(network);
3✔
113
    }
1✔
114

115
    /**
116
     * Called when this element is about to be removed.
117
     * This is called before {@link INetwork#removeNetworkElementPre(INetworkElement)}.
118
     * @param network The network.
119
     */
120
    public void onPreRemoved(INetwork network);
121

122
    /**
123
     * Called when this element has been removed.
124
     * This is called after {@link IFullNetworkListener#removeNetworkElementPost(INetworkElement, BlockState)}.
125
     * @param network The network.
126
     */
127
    public void onPostRemoved(INetwork network);
128

129
    /**
130
     * Called when a neighbouring block is updated, more specifically when
131
     * {@link Block#neighborChanged(BlockState, Level, BlockPos, Block, BlockPos, boolean)},
132
     * {@link Block#onNeighborChange(BlockState, LevelReader, BlockPos, BlockPos)}
133
     * or {@link Block#updateShape(BlockState, Direction, BlockState, LevelAccessor, BlockPos, BlockPos)} is called.
134
     * @param network The network to update in.
135
     * @param world The world in which the neighbour was updated.
136
     * @param neighbourBlock block type of the neighbour that was updated.
137
     * @param neighbourBlockPos The position of the neighbour that was updated.
138
     */
139
    public void onNeighborBlockChange(@Nullable INetwork network, BlockGetter world, Block neighbourBlock,
140
                                      BlockPos neighbourBlockPos);
141

142
    /**
143
     * Set the priority and channel of this element in the network.
144
     * @deprecated Should only be called from {@link INetwork#setPriorityAndChannel(INetworkElement, int, int)}!
145
     * @param network The network this element is present in.
146
     * @param priority The new priority
147
     * @param channel The new channel
148
     */
149
    @Deprecated
150
    public void setPriorityAndChannel(INetwork network, int priority, int channel);
151

152
    /**
153
     * @return The priority of this element in the network.
154
     */
155
    public int getPriority();
156

157
    /**
158
     * @return The channel of this element in the network.
159
     */
160
    public int getChannel();
161

162
    /**
163
     * Invalidate this network element.
164
     * @param network The network.
165
     */
166
    public void invalidate(INetwork network);
167
    /**
168
     * Check if this element can be revalidated if it has been invalidated.
169
     * @param network The network.
170
     * @return If it can be revalidated.
171
     */
172
    public boolean canRevalidate(INetwork network);
173
    /**
174
     * Revalidate this network element after it has been invalidated.
175
     * @param network The network.
176
     */
177
    public void revalidate(INetwork network);
178

179
    /**
180
     * @return If this element's position is currently loaded in the world.
181
     */
182
    public default boolean isLoaded() { // TODO: in next major, remove default implementation
183
        return true;
×
184
    }
185

186
    /**
187
     * If a network element on the given position should tick.
188
     * This can be used as implementation for {@link INetworkElement#isLoaded()}.
189
     * @param pos A position.
190
     * @return If it should tick.
191
     */
192
    public static boolean shouldTick(DimPos pos) {
193
        return pos.isLoaded() && (GeneralConfig.tickUnloadedNetworkElements || pos.getLevel(true).shouldTickBlocksAt(pos.getBlockPos()));
16!
194
    }
195

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