# Landtrain

Landtrain extends Towbars to support chained towing.

## Important

Project Zomboid base `BaseVehicle.addPointConstraint()` force-breaks existing constraints and chain state in MP.
To keep `1 -> 2` while attaching `2 -> 3` (and preserve movement replication), Landtrain includes a Java class override:

- client install: `zombie/vehicles/BaseVehicle.class`
- dedicated install: `java/zombie/vehicles/BaseVehicle.class`
- helper class (both): `LandtrainConstraintAuthHelper.class` in the same `zombie/vehicles` folder

This is the same override pattern used by mods like Realistic Car Physics (manual `zombie` folder copy).

## Apply patch to game

1. Patch your local client install:

```powershell
.\tools\patch-game-basevehicle.ps1
```

2. Patch the dedicated server install:

```powershell
.\tools\patch-game-basevehicle.ps1 -GameRoot "D:\SteamLibrary\steamapps\common\Project Zomboid Dedicated Server"
```

3. Ensure both mods are enabled:
   - `\hrsys_towbars`
   - `\hrsys_landtrain`

## MP requirement

For multiplayer, every connecting client and the dedicated server must run the patched class.
If only one side is patched, towing links can desync with no explicit Lua error.

## Restore vanilla class

```powershell
.\tools\restore-game-basevehicle.ps1
```

To restore dedicated server too:

```powershell
.\tools\restore-game-basevehicle.ps1 -GameRoot "D:\SteamLibrary\steamapps\common\Project Zomboid Dedicated Server"
```
