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

CyclopsMC / IntegratedDynamics / 20655316865

02 Jan 2026 09:52AM UTC coverage: 45.142% (+0.1%) from 45.043%
20655316865

push

github

rubensworks
Bump mod version

2622 of 8584 branches covered (30.55%)

Branch coverage included in aggregate %.

11898 of 23581 relevant lines covered (50.46%)

2.4 hits per line

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

52.63
/src/main/java/org/cyclops/integrateddynamics/api/network/IPositionedAddonsNetworkIngredients.java
1
package org.cyclops.integrateddynamics.api.network;
2

3
import com.google.common.collect.Iterators;
4
import net.minecraft.world.level.Level;
5
import net.minecraft.world.level.block.entity.BlockEntity;
6
import net.neoforged.neoforge.capabilities.BlockCapability;
7
import org.cyclops.commoncapabilities.api.ingredient.IngredientComponent;
8
import org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage;
9
import org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorageSlotted;
10
import org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorageWrapperHandler;
11
import org.cyclops.cyclopscore.datastructure.DimPos;
12
import org.cyclops.cyclopscore.helper.BlockEntityHelpers;
13
import org.cyclops.integrateddynamics.api.ingredient.IIngredientComponentStorageObservable;
14
import org.cyclops.integrateddynamics.api.part.PartPos;
15
import org.cyclops.integrateddynamics.core.network.IIngredientChannelInsertPreConsumer;
16

17
import javax.annotation.Nullable;
18
import java.util.Collection;
19
import java.util.Iterator;
20
import java.util.Map;
21

22
/**
23
 * An ingredient network that can hold prioritized positions.
24
 * @param <T> The instance type.
25
 * @param <M> The matching condition parameter, may be Void. Instances MUST properly implement the equals method.
26
 * @author rubensworks
27
 */
28
public interface IPositionedAddonsNetworkIngredients<T, M> extends IPositionedAddonsNetwork,
29
        IIngredientComponentStorageObservable<T, M> {
30

31
    /**
32
     * @return The ingredient component type this storage applies to.
33
     */
34
    public IngredientComponent<T, M> getComponent();
35

36
    /**
37
     * @return The quantity rate limit for each storage mutation.
38
     */
39
    public long getRateLimit();
40

41
    /**
42
     * Get the storage at the given position.
43
     * @param pos A position.
44
     * @return The storage, or an empty storage if none is available.
45
     */
46
    public IIngredientComponentStorage<T, M> getPositionedStorage(PartPos pos);
47

48
    /**
49
     * Set an ingredient filter for the given storage position.
50
     * Unsets the filter if null is provided.
51
     * @param pos A position.
52
     * @param filter An ingredient filter.
53
     */
54
    public void setPositionedStorageFilter(PartPos pos, @Nullable PositionedAddonsNetworkIngredientsFilter<T> filter);
55

56
    /**
57
     * @param pos A position.
58
     * @return An optional ingredient filter for the given storage position.
59
     */
60
    @Nullable
61
    public PositionedAddonsNetworkIngredientsFilter<T> getPositionedStorageFilter(PartPos pos);
62

63
    /**
64
     * Get all instances at the target position.
65
     * @param pos A part position.
66
     * @return A collection of instances. This can not be a view, and must be a deep copy of the target.
67
     */
68
    public default Iterator<T> getRawInstances(PartPos pos) {
69
        Iterator<T> it = getPositionedStorage(pos).iterator();
5✔
70
        PositionedAddonsNetworkIngredientsFilter<T> filter = getPositionedStorageFilter(pos);
4✔
71
        if (filter != null) {
2!
72
            it = Iterators.filter(it, filter::testView);
×
73
        }
74
        return it;
2✔
75
    }
76

77
    /**
78
     * Get the storage at the given position.
79
     * @param pos A position.
80
     * @return The storage.
81
     */
82
    @Nullable
83
    public default IIngredientComponentStorage<T, M> getPositionedStorageUnsafe(PartPos pos) {
84
        DimPos dimPos = pos.getPos();
3✔
85
        Level level = dimPos.getLevel(true);
4✔
86
        if (level == null) {
2!
87
            return null;
×
88
        }
89
        return getComponent().getBlockStorage(level, pos.getPos().getBlockPos(), level.getBlockState(dimPos.getBlockPos()), BlockEntityHelpers.get(level, dimPos.getBlockPos(), BlockEntity.class).orElse(null), pos.getSide());
22✔
90
    }
91

92
    /**
93
     * Get the storage at the given channel.
94
     * @param channel A channel id.
95
     * @return A storage.
96
     */
97
    public INetworkIngredientsChannel<T, M> getChannel(int channel);
98

99
    /**
100
     * Get the slotted storage at the given channel.
101
     * @param channel A channel id.
102
     * @return A slotted storage.
103
     */
104
    public IIngredientComponentStorageSlotted<T, M> getChannelSlotted(int channel);
105

106
    /**
107
     * Get the external storage at the given channel.
108
     * @param capability A capability to wrap the channel in.
109
     * @param channel A channel id.
110
     * @param <S> The external storage type.
111
     * @return An external storage, or null if no wrapping is possible for the given capability.
112
     */
113
    @Nullable
114
    public default <S, C> S getChannelExternal(BlockCapability<S, C> capability, int channel) {
115
        IIngredientComponentStorageWrapperHandler<T, M, S, C> wrapperHandler = getComponent()
×
116
                .getStorageWrapperHandler(capability);
×
117
        return wrapperHandler != null ? wrapperHandler.wrapStorage(getChannel(channel)) : null;
×
118
    }
119

120
    /**
121
     * Get the last tick duration of the index observer.
122
     * @return Duration in nanoseconds
123
     */
124
    public Map<PartPos, Long> getLastSecondDurationIndex();
125

126
    /**
127
     * Reset the last second duration count.
128
     */
129
    public void resetLastSecondDurationsIndex();
130

131
    /**
132
     * Register an insert pre-consumer.
133
     * @param preConsumer The consumer.
134
     */
135
    public void registerInsertPreConsumer(IIngredientChannelInsertPreConsumer<T> preConsumer);
136

137
    /**
138
     * Unregister an insert pre-consumer.
139
     * @param preConsumer The consumer.
140
     */
141
    public void unregisterInsertPreConsumer(IIngredientChannelInsertPreConsumer<T> preConsumer);
142

143
    /**
144
     * @return All registered insert pre-consumers.
145
     */
146
    public Collection<IIngredientChannelInsertPreConsumer<T>> getInsertPreConsumers();
147

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