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

CyclopsMC / IntegratedDynamics / 19406420189

16 Nov 2025 01:33PM UTC coverage: 45.124% (+0.3%) from 44.866%
19406420189

push

github

rubensworks
Bump mod version

2610 of 8554 branches covered (30.51%)

Branch coverage included in aggregate %.

11856 of 23504 relevant lines covered (50.44%)

2.39 hits per line

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

91.67
/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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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