Developers should have a way to schedule an action to happen at a later time (x amount of ticks, or other time unit.)
- Schedule task to happen when a certain point is reached.
- Cancel a scheduled task.
- read the state of a scheduled task (so the progress can be used in the GUI)
- Not dependent on world time (sun position) or GUI
- Allow for repeating events, as well as single fired events
Justification and Use Case:
This'll allow machines to run and plants to grow, even in unloaded chunks.
For example a furnace:
- when a furnace is filled, it directly removes a single item and schedules two tasks, one to take a new item from the cooking slot, and another to take more fuel.
- If a furnace is emptied before completion, the cook task gets canceled.
- If there is no new item to cook available when the scheduled task for the fuel source is triggered, nothing happens, otherwise the furnace takes another item from the fuel source (and schedules the new fuel task).
- If there is no fuel anymore, the furnace cancels the cook task.
- If the cook task is complete, the original item is taken from the input slot, and the the resulting item is added to the output slot.
- If there is another item in the input slot, and the output can stack with the item currently in the output slot, a new cook tasks gets added to the scheduler.
Another example are Saplings:
- When a sapling is planted, a task with a random time amount (within certain boundaries) is scheduled that'll indicate the tree is grown.
- Removing the sapling removes the scheduled task.
- When the scheduled task is complete, the tree is grown. (how this is done is outside the scope of this proposal.)
- When bonemeal gets used on a sapling, the scheduled task is canceled, and instead, the tree will grow directly.
Additionally, this'll allow a mod similar to Somnia to simulate the world at max speed, by just running the scheduled events up to a certain point, while vanilla beds basically only change the world time.
None discovered at this time.