Skip to content

Added Custom Interaction Handlers to Interactable Parts#1984

Draft
TechTastic wants to merge 2 commits intoDonBruce64:masterfrom
TechTastic:feature/computer-parts
Draft

Added Custom Interaction Handlers to Interactable Parts#1984
TechTastic wants to merge 2 commits intoDonBruce64:masterfrom
TechTastic:feature/computer-parts

Conversation

@TechTastic
Copy link
Contributor

@TechTastic TechTastic commented Oct 17, 2025

So, as part of my addon, Computerized Vehicles, I wanted to add an onboard computer via an interactable part. Unfortunately, despite much trial and error, I did not succeed. So, I have made yet another PR to expand what IV/MTS can do for mod integration!

To do this in a way where it did not apply to just computer mods, I added the new InteractableComponentType.CUSTOM enum value and a new customInteractionHandler field that is only required when the interaction type is set to custom.

Within PartInteractable, I proceeded to add the new static CUSTOM_INTRACTION_HANDLERS field which is a Map<String, CustomInteractionHandler>. CustomInteractionHandler being a new nested interface with functions to be called. Inside the constructor, I expanded the switch statement to include the custom type and to call the CustomInteractionHandler specified by the JSON. Likewise, I did the same for interact. and finally, within remove, update, and save, I also implemented the necessary calls for CustomInteraction Handler.

So, for example, lets say Computerized Vehicles setup an CustomInteractionHandler like so:

PartInteractable.registerCustomInteractionHandler("computerized_vehicles:onboard_computer", new PartInteractable.CustomInteractionHandler {...})

To utilize this new handler, the interactable JSON section would contain this:

"interactable": {
    "interactionType": "custom",
    "customInteractionHandler": "computerized_vehicles:onboard_computer"
}

With this, not only can I add onboard CC: Tweaked computers to vehicles, but anyone wanting to add new interactables with custom behavior can as well!

…InteractionHandler`, and `PartInteractable.registerCustomInteractionHandler`

Expanded `PartInteractable` constructor switch case, `PartInteractable.interact` switch case, `PartInteractable.remove`, and `PartInteractable.update` switch case to handle the selected custom interaction handler
@TechTastic TechTastic marked this pull request as draft October 17, 2025 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments