• 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

0.0
/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.util.RandomSource;
6
import net.minecraft.world.item.ItemStack;
7
import net.minecraft.world.level.BlockGetter;
8
import net.minecraft.world.level.Level;
9
import net.minecraft.world.level.LevelReader;
10
import net.minecraft.world.level.ScheduledTickAccess;
11
import net.minecraft.world.level.block.Block;
12
import net.minecraft.world.level.block.entity.BlockEntity;
13
import net.minecraft.world.level.block.state.BlockState;
14
import net.minecraft.world.level.redstone.Orientation;
15
import org.cyclops.cyclopscore.datastructure.DimPos;
16

17
import javax.annotation.Nullable;
18
import java.util.List;
19

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

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

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

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

45
    /**
46
     * Called right before the network is terminated or will be reset.
47
     *
48
     * @param network     The network to update in.
49
     * @param blockState  The block state.
50
     * @param blockEntity The block entity.
51
     */
52
    public void beforeNetworkKill(INetwork network, @Nullable BlockState blockState, @Nullable BlockEntity blockEntity);
53

54
    /**
55
     * Called right after this network is initialized.
56
     * @param network The network to update in.
57
     */
58
    public void afterNetworkAlive(INetwork network);
59

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

67
    /**
68
     * Add the itemstacks to drop when this element is removed.
69
     *
70
     * @param blockState      The block state of the container block.
71
     * @param blockEntity     The block entity of the container block.
72
     * @param itemStacks      The itemstack list to add to.
73
     * @param dropMainElement If the part itself should also be dropped.
74
     * @param saveState       If the element state should be saved in the item.
75
     */
76
    public void addDrops(BlockState blockState, BlockEntity blockEntity, List<ItemStack> itemStacks, boolean dropMainElement, boolean saveState);
77

78
    /**
79
     * Called when this element is added to the network.
80
     * @param network The network.
81
     * @return If the addition succeeded.
82
     */
83
    public boolean onNetworkAddition(INetwork network);
84

85
    /**
86
     * Called when this element is removed from the network.
87
     *
88
     * @param network     The network.
89
     * @param blockState  The block state.
90
     * @param blockEntity The block entity.
91
     */
92
    public void onNetworkRemoval(INetwork network, BlockState blockState, BlockEntity blockEntity);
93

94
    /**
95
     * Called when this element is about to be removed.
96
     * This is called before {@link INetwork#removeNetworkElementPre(INetworkElement)}.
97
     * @param network The network.
98
     */
99
    public void onPreRemoved(INetwork network);
100

101
    /**
102
     * Called when this element has been removed.
103
     * This is called after {@link IFullNetworkListener#removeNetworkElementPost(INetworkElement, BlockState, BlockEntity)}.
104
     * @param network The network.
105
     */
106
    public void onPostRemoved(INetwork network);
107

108
    /**
109
     * Called when a neighbouring block is updated, more specifically when
110
     * {@link Block#neighborChanged(BlockState, Level, BlockPos, Block, Orientation, boolean)},
111
     * {@link Block#onNeighborChange(BlockState, LevelReader, BlockPos, BlockPos)}
112
     * or {@link Block#updateShape(BlockState, LevelReader, ScheduledTickAccess, BlockPos, Direction, BlockPos, BlockState, RandomSource)} is called.
113
     *
114
     * @param network The network to update in.
115
     * @param world   The world in which the neighbour was updated.
116
     * @param side    The side at the center block.
117
     */
118
    public void onNeighborBlockChange(@Nullable INetwork network, BlockGetter world, @Nullable Direction side);
119

120
    /**
121
     * Set the priority and channel of this element in the network.
122
     * @deprecated Should only be called from {@link INetwork#setPriorityAndChannel(INetworkElement, int, int)}!
123
     * @param network The network this element is present in.
124
     * @param priority The new priority
125
     * @param channel The new channel
126
     */
127
    @Deprecated
128
    public void setPriorityAndChannel(INetwork network, int priority, int channel);
129

130
    /**
131
     * @return The priority of this element in the network.
132
     */
133
    public int getPriority();
134

135
    /**
136
     * @return The channel of this element in the network.
137
     */
138
    public int getChannel();
139

140
    /**
141
     * Invalidate this network element.
142
     * @param network The network.
143
     */
144
    public void invalidate(INetwork network);
145
    /**
146
     * Check if this element can be revalidated if it has been invalidated.
147
     * @param network The network.
148
     * @return If it can be revalidated.
149
     */
150
    public boolean canRevalidate(INetwork network);
151
    /**
152
     * Revalidate this network element after it has been invalidated.
153
     * @param network The network.
154
     */
155
    public void revalidate(INetwork network);
156

157
    /**
158
     * @return If this element's position is currently loaded in the world.
159
     */
160
    public boolean isLoaded();
161

162
    /**
163
     * If a network element on the given position should tick.
164
     * This can be used as implementation for {@link INetworkElement#isLoaded()}.
165
     * @param pos A position.
166
     * @return If it should tick.
167
     */
168
    public static boolean shouldTick(DimPos pos) {
169
        return pos.isLoaded() && pos.getLevel(true).shouldTickBlocksAt(pos.getBlockPos());
×
170
    }
171

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