Replaceable Result Supplier
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
supply is called on an executor thread (async).
replaceQueries is invoked on the calling thread, before the async dispatch, to build the slot-to-item mapping.
All UI access (
getItem/setItem) is dispatched to the entity's regional scheduler via a singlerunAtEntitycall, ensuring thread safety for both Paper and Folia.After all slots are processed (or the timeout elapses), replaceResultHandler is called with the result of each slot operation.
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
A subset of ResultSupplier.Context passed to replaceQueries and replaceResultHandler.
Represents the outcome of a single slot write-back attempt.
Functions
Builds the mapping of crafting-grid slots to items that should be written back.
Called after all slot write-back attempts have completed (or timed out).
Executes the slot write-back logic and always returns an empty list.
Returns the maximum number of milliseconds to wait for the entity scheduler to execute the slot write-back.