Expose the machine that a crafting interface targets - #225
Open
rubensworks wants to merge 1 commit into
Open
Conversation
Crafting interfaces know which block they are targeting, but only exposed their own (center) position through getPosition(). Callers that want the machine had to look the part up again and re-derive its target, which duplicates the logic that decides where a part points at. Add ICraftingInterface#getTargetMachineItem(), which the part state answers from the target it already holds. It is a default method returning an empty stack, so other implementations keep working. Needed by CyclopsMC/IntegratedTerminals#181, to show the crafting machine in the storage terminal's tooltips. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RM86uiqD4soLkMyjC9Eeid
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.
Adds
ICraftingInterface#getTargetMachineItem(), an item representation of the block that a crafting interface is targeting.Why
Crafting interfaces already know which block they point at: the part state holds a
PartTarget, andgetPosition()returns the center half of it. The target half was not exposed, so a caller that wanted the machine had to look the part up again throughPartHelpersand re-runIPartType#getTargetto reconstruct what the state was already holding. That duplicates the logic deciding where a part points at (offsets, side overrides), and drifts silently if that logic ever changes.What
PartTypeInterfaceCraftingBase.Stateanswers it from the target it already holds, returning an empty stack when there is no target yet or the position is not loaded. It is adefaultmethod, so other implementations of the interface keep working unchanged.This also covers running crafting jobs:
ICraftingNetwork#getCraftingJobInterfacealready hands out the interface a job runs in, so its machine is now reachable too.Needed by
CyclopsMC/IntegratedTerminals#181 — showing the crafting machine in the storage terminal's tooltips. The IntegratedTerminals side is CyclopsMC/IntegratedTerminals#216, which needs a release of this change before its CI can pass.
Testing
New game tests in
GameTestsCraftingInterfaceTargetMachine, covering both the regular and the attuned crafting interface against a crafting table and a furnace../gradlew buildand./gradlew runGameTestServerboth pass.🤖 Generated with Claude Code
https://claude.ai/code/session_01RM86uiqD4soLkMyjC9Eeid
Generated by Claude Code