User Tools

Site Tools


mtr:adding_custom_resources

This is an old revision of the document!


<!DOCTYPE markdown>

# Adding Custom Resources

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

* Texture variants for existing [trains](https://github.com/jonafanho/Minecraft-Transit-Railway/wiki/Trains) * New textures or text for [railway signs](https://github.com/jonafanho/Minecraft-Transit-Railway/wiki/Railway-Sign)

It is highly recommended to be familiar with [creating a resource pack](https://minecraft.fandom.com/wiki/Tutorials/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](https://github.com/jonafanho/Minecraft-Transit-Railway/wiki/Dashboards) when selecting trains for a route Required
`color` String (colour hex code) The colour to be shown on [dashboards](https://github.com/jonafanho/Minecraft-Transit-Railway/wiki/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](https://github.com/jonafanho/Minecraft-Transit-Railway/wiki/Trains) for a list of train identifiers
`texture_id` String (texture ID) The [namespaced ID](https://minecraft.fandom.com/wiki/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](https://github.com/jonafanho/Minecraft-Transit-Railway/wiki/Railway-Sign) 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](https://minecraft.fandom.com/wiki/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](https://jsonlint.com/) 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](https://github.com/jonafanho/Minecraft-Transit-Railway/blob/master/examples/MTR%20Custom%20Resources.zip?raw=true) to see a full example and to test out the functionality.

mtr/adding_custom_resources.1677138859.txt.gz · Last modified: 2023/02/23 07:54 by zbx1425