Emit an event when a crafting job is completed - #222
Merged
Conversation
Adds CraftingJobFinishedEvent, which is emitted on the NeoForge event bus for jobs that ran to completion. Cancelled jobs are excluded: cancelling marks the job, because the crafting interface finalizes cancelled jobs through the regular finishing logic a tick later. Crafting jobs now also carry a notifyInitiator flag, so that initiators can indicate that they want to be notified once the job is completed, and an initialAmount, because the regular amount is decremented to zero while the job runs. Related to #175 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QNDY2pZtkXqJrhztYCvNbh
rubensworks
commented
Sep 2, 2026
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QNDY2pZtkXqJrhztYCvNbh
rubensworks
force-pushed
the
feature/crafting-job-finished-event
branch
from
September 2, 2026 18:50
5dbf41c to
e7662c1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Groundwork for #175 (toast notifications for completed crafting jobs). This PR only adds the hook; the toast itself lives in CyclopsMC/IntegratedTerminals#214.
What
CraftingJobFinishedEventA new event on the NeoForge event bus, emitted from
CraftingNetwork#onCraftingJobFinishedfor jobs that ran to completion.Two details worth calling out:
CraftingNetwork#cancelCraftingJobcannot simply skip emitting, because it delegates to the crafting interface, which finalizes the job through the regular finishing logic a tick later. So cancelling marks the job via a new transientCraftingJob#isCancelled, which the emit checks. Jobs that disappear together with their crafting interface never reachonCraftingJobFinishedat all, so they emit nothing either.isRootJob()is captured when the event is constructed. The event is emitted for every completed job, including dependencies, and consumers generally only care about the job that was requested.CraftingJobDependencyGraph#onCraftingJobFinishedclears the job's dependent links right after the emit, so readinggetDependentCraftingJobs()later would report every job as a root job.CraftingJob#notifyInitiatorA persisted flag next to the existing
initiatorUuid, with which an initiator indicates that it wants to be notified once the job is completed. Set through a newCraftingHelpers#scheduleCraftingJobsoverload; the existing signature delegates to it withfalse, so nothing changes for current callers.CraftingJob#initialAmountA persisted copy of the amount as it was when the job was scheduled. The regular
amountis decremented while the job runs and is zero by the time the job finishes, so it cannot be used to describe what the job produced. Set for every scheduled job, not just for initiator-driven ones.Tests
Three game tests in
GameTestsCraftingJobFinishedEvent, each on the basic crafting network:Each test filters events by a random initiator UUID, so concurrently running tests do not interfere.
Compatibility
Both new NBT fields default to
false/0when absent, so crafting jobs saved by older versions load unchanged. Jobs that were already running when a world is updated report aninitialAmountof0, which consumers should treat as unknown.🤖 Generated with Claude Code
https://claude.ai/code/session_01QNDY2pZtkXqJrhztYCvNbh