Pack Making JSON Roads - DonBruce64/MinecraftTransportSimulator GitHub Wiki

Roads are pretty much what you'd think them to be: roads. Exactly how you model a road will vary depending on what type of component you are making, but even so they still follow all the requirements for a road model. Really, the big part is the JSON. This defines not only the size of the road, but the paths, lanes, directions, and all other properties that will make the road actually function.

Inherited JSON

Roads inherit the following core JSON sections:

Road

All road components, no matter what they do, contain a road section. This tells MTS what type of road component the road is, and a few other core things. It contains the following parameters:

  • type – The type of this road component. This defines its properties. Valid types are:
  • core_static - The core component. This must be placed down before any other road components. This is a static component with defined lanes and collision.
  • core_dynamic - The core component. This must be placed down before any other road components. This is a dynamic component with flexible collision and lane paths, but defined lane counts and offsets.
  • laneOffsets – The offsets for the lanes for this road if this is a dynamic core component. 0 starts at X=0.
  • borderOffset – The offsets for the opposite side of the road if this is a dynamic core component. Essentially the width of the road.
  • segmentLength – "How long each segment in this road is. This allows for variable-length repeating model segments.
  • collisionHeight – How high collision should be for this dynamic core component, in pixels. Normally a low value.
  • sectors – A list of lane sectors that define the paths for this road. These contain a start position, angle, and lanes. Each sector is basically a single end of an intersection, with a 4-way intersection having 4 sectors. The properties in a sector is used to determine what lanes can connect to the sector, and where these connections are.
  • collisionAreas – A list of collision areas. This allows for collision to be applied in a multi-block format for this road. Normally just a single square entry, but may extend in the +Y direction for complex road components like bridges. Think of how you seelect ares with the World Edit mod.

Sectors

  • sectorStartPos – The start position for this sector. This should be the right-most side. For example, on a 4-lane intersection this would be 0,0,0 for the south-facing sector.
  • sectorStartAngles – The start angles for this sector. Roads are normally considered to be heading south, so any angles applied will modify that orientation. Pitch and roll are supported here, though be advised they are not considered when doing connection checks.
  • borderOffset – How far from the start position the border of this sector is. Similar to dynamic roads, this is used to calculate the total road width.
  • lanes - A list of Lanes that make up the paths for this sector.

Lanes

  • startPoint - The starting point for this lane. Note that vehicles arriving at junctions will only transition to the next road segment if there's a start position for it. This allows for merge areas where two lanes go into one, as well as one-way roads. Note that this point does not take into account the collision height of the road: you must account for this as needed.
  • endPoints - A list of Sector End Points for this lane. This may be, and likely will, be the same as the start points for the lanes from other sectors.

Sector End Points

  • pos - The ending position for this sector-point.
  • angles - The ending rotation for this sector-point.

Collision Areas

  • firstCorner - The first corner point that defines this collision area.
  • secondCorner - The second corner point that defines this collision area. The Y-position MUST be the same as the first point!
  • collisionHeight - The height of the collision for this area, in pixels. Not that this may NOT exceed 15 and go above the height of a block. If you want collision that's over 1-block high, use another collision area with the two points at a higher Y position.