Interface IIngredientChannelInsertPreConsumer<T>
public interface IIngredientChannelInsertPreConsumer<T>
Allows (partially) consuming an ingredient before it is inserted into the network.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordThe outcome of a pre-consumer insertion. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,M> T applyAll(Collection<IIngredientChannelInsertPreConsumer<T>> preConsumers, org.cyclops.commoncapabilities.api.ingredient.IIngredientMatcher<T, M> matcher, int channel, T ingredient, T unclaimed, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction) Run the given ingredient instance through all the given pre-consumers.default Tinsert(int channel, T ingredient, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction) Deprecated.insert(int channel, T ingredient, T unclaimed, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction) Called before an ingredient is inserted into the network.
-
Method Details
-
insert
@Deprecated default T insert(int channel, @Nonnull T ingredient, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction) Deprecated.Implementinsert(int, Object, Object, TransactionContext)instead, which also tracks the part of the insertion that is still unclaimed.Called before an ingredient is inserted into the network. If nothing needs to be consumed, the same instance can be returned.- Parameters:
channel- The network channel.ingredient- The ingredient instance.transaction- The current transaction.- Returns:
- The remaining ingredient instance.
-
insert
default IIngredientChannelInsertPreConsumer.Result<T> insert(int channel, @Nonnull T ingredient, @Nonnull T unclaimed, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction) Called before an ingredient is inserted into the network. All pre-consumers of a network observe the same insertion, one after the other, each one receiving what the previous one left. A pre-consumer can do two independent things with it, seeIIngredientChannelInsertPreConsumer.Result: it can take part of it away, and it can claim part of it. Only the unclaimed part may be claimed, so that one insertion is never claimed by multiple pre-consumers.- Parameters:
channel- The network channel.ingredient- The part of the insertion that still has to be inserted into the network.unclaimed- The part of the insertion that no pre-consumer has claimed yet. This is never larger than the given ingredient.transaction- The current transaction.- Returns:
- What is left to insert into the network, and what of it is left unclaimed.
-
applyAll
static <T,M> T applyAll(Collection<IIngredientChannelInsertPreConsumer<T>> preConsumers, org.cyclops.commoncapabilities.api.ingredient.IIngredientMatcher<T, M> matcher, int channel, @Nonnull T ingredient, @Nonnull T unclaimed, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction) Run the given ingredient instance through all the given pre-consumers.- Parameters:
preConsumers- The pre-consumers of the network channel.matcher- The matcher of the ingredient component.channel- The network channel.ingredient- The ingredient instance that is being inserted.unclaimed- The part of the insertion that no pre-consumer has claimed yet, which is the whole instance unless a pre-consumer was already applied to it.transaction- The current transaction.- Returns:
- The remaining ingredient instance that still has to be inserted into the network.
-
insert(int, Object, Object, TransactionContext)instead, which also tracks the part of the insertion that is still unclaimed.