Add part offset support to crafting interfaces, Closes #138, Closes #152 - #215
Open
rubensworks wants to merge 1 commit into
Open
Add part offset support to crafting interfaces, Closes #138, Closes #152#215rubensworks wants to merge 1 commit into
rubensworks wants to merge 1 commit into
Conversation
Crafting interfaces already accepted Part Offset enhancements, but there was no way to configure the offset, and the offset was not taken into account when interacting with the targeted machine. * Let PartTypeCraftingBase extend PartTypeConfigurable, so that crafting interfaces expose the part offsets gui. * Add a part offsets button to the crafting interface gui and to the crafting interface settings gui. The latter is needed for the attuned crafting interface, which shows the settings gui as its main gui. * Re-target crafting interfaces when their target changes, so that the offset is picked up without having to save the part settings first. Recipes are reloaded and re-registered in the crafting network for the new target, which makes recipe validation, recipe attuning, and ingredient insertion happen at the offset position. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NHfm2FRdBFfrNNRxJSCPDX
|
|
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.
Closes #138, closes #152.
Crafting interfaces already accepted Part Offset enhancements, but there was no way to configure the offset, and the offset was ignored when interacting with the targeted machine. This implements both halves.
Cause
Two independent problems, matching the three symptoms reported in #152:
PartTypeCraftingBaseextendedPartTypeBaserather thanPartTypeConfigurable, sogetContainerProviderOffsets()returned empty and the offsets gui could never be opened (symptom 1).PartTypeInterfaceCraftingBase.Statecaches itsPartTarget, which was only set on network addition, network re-alive, and priority/channel changes. A changed offset left that cache stale, so the interface kept validating recipes against, and inserting ingredients into, the directly adjacent block (symptoms 2 and 3). This also explains the reported workaround of re-saving the part settings: that path goes throughsetPriorityAndChannel, which re-registers the target as a side effect.Changes
core/part/PartTypeCraftingBaseextendsPartTypeConfigurable, so crafting parts expose the part offsets gui. ItswriteExtraGuiDataSettingsoverride was dropped, as the new parent already provides an identical one.core/part/PartTypeInterfaceCraftingBasegains aretargetmethod, called fromupdatewhenever the recomputed target differs from the cached one. It unregisters the old recipes from the crafting network before reloading them (removeCraftingInterfaceiteratesgetRecipes(), so it needs the old values), sets the new target, reloads recipes, and re-registers. Unlike remove + add, it retains the network and channel, since only the targeted position changes. The target is recomputed insideupdaterather than reusing the passed one, so variable-driven offsets are picked up in the same tick.gui.integrateddynamics.part_offsetstranslation key, so no new lang entries are needed.Tests
New
gametest/GameTestsPartOffsetsadds three game tests, plus asetPartOffsethelper inGameTestHelpersIntegratedCrafting:testItemsCraftChestOffset— interface faces air, reaches the crafting table via an offset.testItemsCraftChestOffsetIgnoresAdjacentMachine— a furnace sits at the adjacent position while the offset points at a crafting table, covering symptom 3 directly.testItemsCraftAttunedPlanksOffset— the attuned interface reads its recipes through an offset.Each sets the offset after the network is already alive, so they exercise the re-registration path rather than just initial setup.
Verified the tests are meaningful: with the
retargetcall removed fromupdate, all three fail (Crafting interface has no valid target,Expected Slot 1 item is incorrect to be minecraft:chest, but was minecraft:air,Recipe in crafting interface is not valid). With it in place,./gradlew buildsucceeds and./gradlew runGameTestServerreports all 41 game tests passing.Known limitation
PartTypeInterfaceCraftingAttuned.onBlockNeighborChangeonly fires for blocks adjacent to the part. Setting an offset first and then placing the machine at the offset position will therefore not refresh the attuned recipe list until something else re-targets the part. Changing the offset itself (the repro path in #152) does refresh correctly. Left as-is to keep this change scoped.🤖 Generated with Claude Code
https://claude.ai/code/session_01NHfm2FRdBFfrNNRxJSCPDX