ReplaceableResultSupplier

A subinterface of ResultSupplier that writes items back into the crafting UI slots after a craft completes, instead of (or in addition to) giving them to the player.

Typical use cases include ingredient transformation (e.g. returning a modified tool to the grid) and byproduct placement (e.g. returning an empty bucket after consuming a filled one).

Execution flow

  1. supply is called on an executor thread (async).

  2. replaceQueries is invoked on the calling thread, before the async dispatch, to build the slot-to-item mapping.

  3. All UI access (getItem / setItem) is dispatched to the entity's regional scheduler via a single runAtEntity call, ensuring thread safety for both Paper and Folia.

  4. After all slots are processed (or the timeout elapses), replaceResultHandler is called with the result of each slot operation.

  5. supply itself always returns an empty list; item delivery to the player's inventory is the responsibility of replaceResultHandler if needed.

Timeout behaviour

If the entity scheduler does not execute within timeoutMilli milliseconds, all slots that have not been processed yet are marked ReplaceState.TIMEOUT and replaceResultHandler is still called.

Since

5.0.21

See also

Types

Link copied to clipboard
Link copied to clipboard

Represents the outcome of a single slot write-back attempt.

Functions

Link copied to clipboard

Builds the mapping of crafting-grid slots to items that should be written back.

Link copied to clipboard

Called after all slot write-back attempts have completed (or timed out).

Link copied to clipboard
open override fun supply(ctx: ResultSupplier.Context): List<ItemStack>

Executes the slot write-back logic and always returns an empty list.

Link copied to clipboard
open fun timeoutMilli(): Long

Returns the maximum number of milliseconds to wait for the entity scheduler to execute the slot write-back.