Interface IIngredientChannelInsertPreConsumer<T>


public interface IIngredientChannelInsertPreConsumer<T>
Allows (partially) consuming an ingredient before it is inserted into the network.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    The outcome of a pre-consumer insertion.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <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.
    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

      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, see IIngredientChannelInsertPreConsumer.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.