Skip to content

Adding Custom Resources

Jonathan Ho edited this page May 18, 2022 · 4 revisions

User-created content can be added to the Minecraft Transit Railway mod via resource packs. Currently, players can add the following:

It is highly recommended to be familiar with creating a resource pack before proceeding with this guide.

Resource Pack Format

The file mtr_custom_resources.json is the main file that will get loaded. This file defines custom content for the mod to register. It must be placed under the mtr namespace; in other words, it must have the file path of assets/mtr/mtr_custom_resources.json.

Adding Texture Variants for Existing Trains

To add texture variants, the custom_trains JSON object should be added to mtr_custom_resouces.json. Each JSON object under custom_trains, representing a texture variant for a train, should have a unique key and serveral required entries.

Key Data Type Description Notes
name String The name to be shown on dashboards when selecting trains for a route Required
color String (colour hex code) The colour to be shown on dashboards when selecting trains for a route Optional, defaults to the colour black if none specified
base_train_type String (train ID) The train model to apply the texture on Required, see the trains page for a list of train identifiers
texture_id String (texture ID) The namespaced ID of the texture file Required

An example is shown below.

{
  "custom_trains": {
    "my_custom_train": {
      "name": "My Custom SP1900 Train",
      "color": "FEC5E5",
      "base_train_type": "sp1900",
      "texture_id": "mtr:custom_directory/custom_sp1900.png"
    }
  }
}

Adding New Railway Sign Textures or Text

To add new railway signs textures or text, the custom_signs JSON object should be added to mtr_custom_resouces.json. Each JSON object under custom_signs, representing a new sign, should have a unique key and serveral required entries.

Key Data Type Description Notes
texture_id String (texture ID) The namespaced ID of the texture file Required
flip_texture Boolean If true, the texture will be flipped horizontally Optional
custom_text String If set, the text will be shown to the right of the image; the pipe character | is supported, for example 客務中心|Customer Service Centre Optional
flip_custom_text Boolean If custom_text is set and flip_custom_text is true, the text will be shown to the left of the image Optional
small Boolean If true, the image will be rendered with a margin around it Optional
background_color String (colour hex code) The colour for the backgound Optional, defaults to the colour black if none specified

An example is shown below.

{
  "custom_signs": {
    "my_custom_sign": {
      "texture_id": "mtr:custom_directory/custom_sign.png",
      "flip_texture": false,
      "custom_text": "你好|Hello",
      "flip_custom_text": false,
      "small": true,
      "background_color": "1167B1"
    }
  }
}

Verifying the Resource Pack

Use a JSON validator to check for any syntax errors of the JSON files.

The resource pack (zip file) can be installed either clientside or as a server resource pack. If installed as a server resource pack, all players joining the server will be able to see the new additions after accepting the server resource pack.

Download the example resource pack to see a full example and to test out the functionality.