Zhincore / dynmap-trains

DynMap integration for Create Track Map
GNU General Public License v3.0
20 stars 3 forks source link

Tracks, portals, stations, and trains not showing up on dynmap #17

Open PuffyTato opened 2 months ago

PuffyTato commented 2 months ago

I'm quite sure I configured it properly but just in case:

 - class: org.dynmap.ClientComponent
    type: trains
    # Base url of CTM server. "" will try the current address (which is for example `localhost:8123/api/trains`), you can make this work using a reverse proxy (like Nginx).
    # If specified, it should be a publicly available address.
    # The default address of CTM is `http://localhost:3876` (which will NOT work on the internet, just saying)
    base-url: "SERVERIP:SERVERPORT"
    # Dynmap world name to CTM world name mapping 
    worlds:
      worldname: "minecraft:overworld"
      DIM-1: "minecraft:the_nether"
      DIM1:  "minecraft:the_end"
    # Configuration for each layer
    #   `hidden` - Whether or not should the layer be hidden by default
    #   `label` - The label of the layer to show in the UI
    layers: 
      trains:
        hidden: false
        label: Trains
      blocks:
        hidden: false
        label: Train Tracks
      signals:
        hidden: false
        label: Train Signals
      stations:
        hidden: false
        label: Train Stations
      portals:
        hidden: false
        label: Train Portals
    # Additional texts used in the UI 
    labels: 
      # Tooltip for portal marker 
      portal: "Portal to "
      # Tooltip for station marker 
      station: Station
      # Tooltip whether the station is assembling 
      assembling: Assembling
      # Tooltip for train marker 
      train: Train
      # Owner of train 
      owner: Owner
    # Width of the rectangles representing trains (in blocks) 
    train-width: 3
    # Width of the lines representing tracks 
    track-width: 0.75
    # Width of the outline around the track lines 
    track-outline: 1
    # Whether or not should the track outline visually separate track segments 
    track-separation-outline: true

There's not listed compatible server version, but the server is running forge 47.3.6 on the version 1.20.1. Dynmap Version: Dynmap® 3.7-beta-6 for Forge 1.20.0-1

Create Track map version: 1.4

I have quadruple checked everything as far as documentation goes, so I'm quite sure this is an issue, rather than misconfiguration. If a version is wrong, or I misconfigured something, my apologies.

Zhincore commented 2 months ago

Hey, I assume SERVERIP:SERVERPORT points to where your Create Track Map is?

PuffyTato commented 2 months ago

Yes. I quadruple checked this, as well as the Create Track Map configuration to be sure it was pointed to exactly where the track map was.

Zhincore commented 2 months ago

Any errors in server console on in your browser's console on dynmap?

PuffyTato commented 2 months ago

Not as far as I can tell. It seems the it's loading to some degree, because dynmap has the buttons to toggle off stations, tracks, trains, etc. There's just no display of those things on the map itself.

image
KylePRowe commented 1 month ago

Hey just wanting to mention I'm also having this issue on Forge 1.20.1. Same thing where it loads in the information (even has the train itself)

One error I did notice is that if I click on the train to go to it, it'll give an error mentioning "can't open map 'null'" or something to that effect

KylePRowe commented 1 month ago

Hey just wanting to mention I'm also having this issue on Forge 1.20.1. Same thing where it loads in the information (even has the train itself)

One error I did notice is that if I click on the train to go to it, it'll give an error mentioning "can't open map 'null'" or something to that effect

Hi again! Just wanted to mention that I fixed my issue with elements not appearing. It was because my world name is not "world" and therefore I had to modify the world binding. Silly mistake on my end.

As for the "map cannot be null" console error I mentioned, that still happens when trying to pan over to a train. Not really sure why but, that doesn't really matter too much to me @PuffyTato is it possible that you're having the same issue with world name definitions?

PuffyTato commented 1 month ago

The world name was one of the things I tried, unfortunately it didn't work. No errors last time I checked so I'm unsure of how to fix the issue.

joshhunt commented 2 weeks ago

@KylePRowe @PuffyTato If you're still around, I should have a fix for both your problems.

If you don't have any train lines showing at all, check to see if you need to specify the world mapping that was previously suggestion.

Then, if you're getting the 'cannot open map null' error and you specify a custom name for the overworld, you'll probably also need to undo the default world value to something random (and likewise if you override DIM-1 or DIM1). Here's what I have in my config:

  - class: org.dynmap.ClientComponent
    type: trains
    base-url: "http://example.com"
    worlds:
      world: "poo-poo" # this is the magic sauce
      "First Adventure": "minecraft:overworld"
      DIM-1: "minecraft:the_nether"
      DIM1:  "minecraft:the_end"

After you do this change, you might notice that it still won't pan you to the correct train. I have a PR to fix that here https://github.com/Zhincore/dynmap-trains/pull/18, but you can do it yourself by editing trains.js. Below approx line 727 in, add a single line:

      this.#streams.trains.onMessage((data) => {
        for (const train of data.trains) {
          const position = train.cars[0].leading;
          const map = getMapForDimension(position.dimension, dynmap, config);
+         position.location.world = map?.options.world.name;
          let $el = $("#train-" + train.id);

Make sure the leading + isn't there. Save, clear cache, etc and it should all work properly now ✨