Skip to content

Pack Making Mod Integration

DonBruce64 edited this page Feb 4, 2022 · 3 revisions

Nearly all packs will be created as stand-alone items. However, there exists the possibility to extend the MTS codebase via modding to make custom pack content with custom functionality. This is mainly intended for custom parts, though if you're brave try and create custom vehicles!

The steps to do this are as follows:

  1. Make a new JSONPart definition. This is basically the code form of the JSON files that MTS loads during pack loading, and is what it uses to define the various item properties. The fields are explained in both the internal comments and the wiki. You will want to override AJSONMultiModelProvider#getModelLocation() and AJSONMultiModelProvider#getTextureLocation(), as these normally query the built-in packloader.json file for information on where to get your assets, and those assume a standard external pack file.
  2. Extend AItemPack, passing the JSONPart you made into its constructor. This will create a new part item that works with MTS. Make sure AItemBase#autoGenerate() return false. Normally MTS auto-creates wrapped pack items once they are registered, but that won't work since you're (presumably) using your own mod's items.
  3. For any items in your mod that also can be MTS parts, implement IBuilderItemInterface, and return the item you created in the step above. This is needed to let MTS know your item is a part when it's in item form in the player's hand or in an inventory.
  4. Register your new item with PackParserSystem#registerItem()
  5. If your mod needs to make a custom part with custom logic, simply extend APart. Then create an AItemPartCreator, and register that creator with PackParserSystem#addItemPartCreator(). This will link your part with the item that spawns it in the system. To return that item when you wrench and remove the part, modify AEntityD_Definable#getItem() with the item to return.
  6. If you want to have custom rendering of your part-model (and you probably do), override APart#getRender(). You will need to create a render class that extends RenderPart, which will then handle all render calls for you.
  7. If you are wanting to change between the internal wrapper-based and builder-based systems and into your own systems, you can use the methods in InterfaceInterface. These offer ways to access the protected fields in wappers and builders, as well as get the wrapper that goes with the MC-specific object.

At this point, you've got a custom MTS item that's linked to an item in your mod, that is also linked to a part that links back to the item, and has custom rendering and model locations. So basically, you're done!

Clone this wiki locally