Uploaded image for project: 'Bedrock Dedicated Server'
  1. Bedrock Dedicated Server
  2. BDS-3080

Client Script works but Server Script doesn't

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • None
    • 1.14.0.9
    • None
    • Amazon Linux, JavaScript

      Hello,

      I am running a bedrock dedicated server. I am tapping into Scripting API to learn about its possibilities.

      I have created an addon which works perfectly fine on the local game copy, but it fails to fully operate on the server. The behaviour is quite strange, so I searched for a resolution but to no avail.

      When I say fully, I mean that the Client Script side works fine, but the Server Script side does not respond at all. As if it didn't exist.

      I tried a few variants finally resorting to the bare minimum which simply listens for an event and then displays a message in the chat. That didn't work either.

      Again, the Client Script works and if I call a chat message in the "minecraft:client_entered_world" event, it shows just fine. 

      I have been pulling my hairs out for a few days now trying to find the root of the issue. Then I waved a white flag and came here.

      1. I checked server file permissions to make sure the server can execute all its files.
      2. I tried to run the addon from [server]/behavior_packs, [server]/worlds/[world]/behavior_packs
      3. I experimented with versions and other settings in JSON files e.g. valid_known_packs.json or world_behavior_packs.json
      4. I tried installing the addon manually but also importing the world from the local game copy to the server
      5. I enabled/disable the experimental game mode on the server.
      6. ... and everything in between.

      Noting did the trick. Below I attach my code and server details so you can join in and see yourself.

      What am I missing?

      Addon ZIP
      Server Details

      Address: 52.16.178.68

      Port: 25655

      client.js
      const system = client.registerSystem(0, 0);
      
      system.initialize = function() {
      this.listenForEvent("minecraft:client_entered_world", (eventData) => this.onStartSetup(eventData));
      this.registerEventData("Kox:startSetup", {});
      };
      
      system.onStartSetup = function(eventData) {
      let playerData = this.createEventData("Kox:startSetup");
      playerData.data = eventData.data;
      this.broadcastEvent("Kox:startSetup", playerData);
      };
      server.js
      var system = server.registerSystem(0, 0);
      
      system.initialize = function () {
      this.listenForEvent("Kox:startSetup", eventData => this.onStartServerSetup(eventData));
      };
      
      system.onStartServerSetup = function (eventData) {
      let chatEventData = this.createEventData("minecraft:display_chat_event");
      chatEventData.data.message = "Yes, I am here!";
      this.broadcastEvent("minecraft:display_chat_event", chatEventData);
      };

       

       

            Unassigned Unassigned
            Temesz Tomasz Lisiecki
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: