{
   "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
   "id": "549097",
   "self": "https://bugs.mojang.com/rest/api/2/issue/549097",
   "key": "BDS-18964",
   "fields": {
      "issuetype": "1",
      "project": "11700",
      "fixVersions": [],
      "resolution": "10001",
      "customfield_10500": {
         "self": "https://bugs.mojang.com/rest/api/2/customFieldOption/10300",
         "value": "Unconfirmed",
         "id": "10300",
         "disabled": false
      },
      "customfield_12800": null,
      "customfield_12602": [],
      "customfield_12601": null,
      "customfield_12604": null,
      "customfield_12603": null,
      "customfield_12606": null,
      "customfield_12605": null,
      "customfield_12608": null,
      "resolutiondate": "2024-06-12T09:47:10.000+0300",
      "customfield_12607": null,
      "customfield_12609": null,
      "workratio": -1,
      "lastViewed": null,
      "watches": {
         "self": "https://bugs.mojang.com/rest/api/2/issue/BDS-18964/watchers",
         "watchCount": 0,
         "isWatching": false
      },
      "created": "2024-01-14T06:56:35.000+0200",
      "customfield_12000": null,
      "customfield_12201": null,
      "customfield_12600": null,
      "labels": [],
      "customfield_11700": "{}",
      "versions": [
         "21831"
      ],
      "issuelinks": [],
      "assignee": null,
      "updated": "2024-06-12T09:47:10.000+0300",
      "status": "5",
      "description": "Mojang please fix this, it is limiting us developers and causing immeasurable headaches. I'm tired of having to come up with dumb workarounds that bloats my code, wrapping my code in a system.run() that doesn't work half the time, and giving up on some projects because I'm unable to call some functions in a beforeEvent.\u00a0\r\n\r\n\u00a0\r\n\r\nTested JS Code:\r\nworld.beforeEvents.playerLeave.subscribe((\\{ player }) =>\r\n\r\n{ // teleporting a player back to spawn when they leave \u00a0 \u00a0 player.teleport(new Vector(0, 0, 0)) }\r\n\r\n)\r\n\r\n\u00a0\r\n\r\nAffects @minecraft/server version 1.3.0-beta and up\r\n\u00a0\r\nExpected Result: Player is teleported to 0, 0, 0 before they leave the realm.\r\nActual Result: [Scripting][error]-ReferenceError: Native function [Entity::teleport] does not have required privileges. \u00a0 \u00a0at <anonymous> (main.js:33)\r\n\u00a0\r\nEvery function that sets something does not work in a beforeEvent.",
      "customfield_11100": 0.0,
      "customfield_11300": null,
      "customfield_11500": null,
      "customfield_12503": null,
      "customfield_12700": "[Briefly describe the bug here]\r\n\r\n*Steps to Reproduce:*\r\n# [Step 1]\r\n# [Step 2]\r\n# [Step 3]\r\n\r\n*Observed Results:*\r\n[Describe what happens]\r\n\r\n*Expected Results:*\r\n[Describe what should happen]\r\n\r\n*Screenshots/Videos attached:* [please attach an image or short video]\r\n\r\n*Notes:*",
      "customfield_12502": null,
      "customfield_12504": null,
      "attachment": [],
      "summary": "Cannot call functions in a beforeEvent",
      "creator": "JIRAUSER736157",
      "reporter": "JIRAUSER736157",
      "customfield_10002": null,
      "customfield_12501": null,
      "customfield_12500": null,
      "customfield_11601": null,
      "customfield_11600": "0|i2g1v3:",
      "environment": null,
      "customfield_11801": null,
      "customfield_11800": null,
      "customfield_11602": null,
      "customfield_11802": null,
      "comment": {
         "comments": [
            {
               "self": "https://bugs.mojang.com/rest/api/2/issue/549097/comment/1330120",
               "id": "1330120",
               "author": "weszaj_waw",
               "body": "Is this only happening on a Dedicated Server, Featured Server, realms, multiplayer or singleplayer? What platform/device are you using?\r\nThis ticket will automatically reopen when you reply.",
               "updateAuthor": "weszaj_waw",
               "created": "2024-06-11T12:39:46.481+0300",
               "updated": "2024-06-11T12:39:46.481+0300"
            },
            {
               "self": "https://bugs.mojang.com/rest/api/2/issue/549097/comment/1330229",
               "id": "1330229",
               "author": "JIRAUSER615561",
               "body": "It's by design for now that in a before event you can't run essentially any \"update functions\" in a before event, because the rest of the Minecraft infra is in an un-ideal state to be able to process those changes.\u00a0 The main thing is to wrap them in a system.run (which will typically run a half-tick later) in a before event, and you should ensure you \"re-fetch\" things like entity objects inside of that functions.. Definitely feel that this is somewhat painful..",
               "updateAuthor": "JIRAUSER615561",
               "created": "2024-06-11T21:55:09.717+0300",
               "updated": "2024-06-11T21:55:09.717+0300"
            }
         ],
         "maxResults": 2,
         "total": 2,
         "startAt": 0
      },
      "votes": {
         "self": "https://bugs.mojang.com/rest/api/2/issue/BDS-18964/votes",
         "votes": 1,
         "hasVoted": false
      }
   },
   "changelog": {
      "startAt": 0,
      "maxResults": 6,
      "total": 6,
      "histories": [
         {
            "id": "2923396",
            "author": "JIRAUSER736157",
            "created": "2024-01-14T06:57:20.406+0200",
            "items": [
               {
                  "field": "description",
                  "fieldtype": "jira",
                  "from": null,
                  "fromString": "Mojang please fix this, it is limiting us developers and causing immeasurable headaches. I'm tired of having to come up with dumb workarounds that bloats my code, wrapping my code in a system.run() that doesn't work half the time, and giving up on some projects because I'm unable to call some functions in a beforeEvent.\u00a0\r\n\r\n\u00a0\r\n\r\nTested JS Code:\r\nworld.beforeEvents.playerLeave.subscribe((\\{ player }) => {\r\n// teleporting a player back to spawn when they leave\r\n\u00a0 \u00a0 player.teleport(new Vector(0, 0, 0))\r\n})\r\n\u00a0\r\nExpected Result: Player is teleported to 0, 0, 0 before they leave the realm.\r\nActual Result: [Scripting][error]-ReferenceError: Native function [Entity::teleport] does not have required privileges. \u00a0 \u00a0at <anonymous> (main.js:33)\r\n\u00a0\r\nEvery function that sets something does not work in a beforeEvent.",
                  "to": null,
                  "toString": "Mojang please fix this, it is limiting us developers and causing immeasurable headaches. I'm tired of having to come up with dumb workarounds that bloats my code, wrapping my code in a system.run() that doesn't work half the time, and giving up on some projects because I'm unable to call some functions in a beforeEvent.\u00a0\r\n\r\n\u00a0\r\n\r\nTested JS Code:\r\nworld.beforeEvents.playerLeave.subscribe((\\{ player }) =>\r\n\r\n{ // teleporting a player back to spawn when they leave \u00a0 \u00a0 player.teleport(new Vector(0, 0, 0)) }\r\n\r\n)\r\n\r\n\u00a0\r\n\r\nAffects @minecraft/server version 1.3.0-beta and up\r\n\u00a0\r\nExpected Result: Player is teleported to 0, 0, 0 before they leave the realm.\r\nActual Result: [Scripting][error]-ReferenceError: Native function [Entity::teleport] does not have required privileges. \u00a0 \u00a0at <anonymous> (main.js:33)\r\n\u00a0\r\nEvery function that sets something does not work in a beforeEvent."
               }
            ]
         },
         {
            "id": "2923397",
            "author": "JIRAUSER736157",
            "created": "2024-01-14T06:57:45.649+0200",
            "items": [
               {
                  "field": "Attachment",
                  "fieldtype": "jira",
                  "from": "559281",
                  "fromString": "image-2024-01-13-23-34-21-009.png",
                  "to": null,
                  "toString": null
               }
            ]
         },
         {
            "id": "2923859",
            "author": "umija5895",
            "created": "2024-01-15T15:57:31.483+0200",
            "items": [
               {
                  "field": "Key",
                  "fieldtype": "jira",
                  "from": null,
                  "fromString": "MCPE-178179",
                  "to": null,
                  "toString": "BDS-18964"
               },
               {
                  "field": "Platform",
                  "fieldtype": "custom",
                  "from": "11503",
                  "fromString": "Multiple",
                  "to": null,
                  "toString": ""
               },
               {
                  "field": "Version",
                  "fieldtype": "jira",
                  "from": null,
                  "fromString": null,
                  "to": "21831",
                  "toString": "1.20.51"
               },
               {
                  "field": "Version",
                  "fieldtype": "jira",
                  "from": "21832",
                  "fromString": "1.20.51 Hotfix",
                  "to": null,
                  "toString": null
               },
               {
                  "field": "Workflow",
                  "fieldtype": "jira",
                  "from": "722002",
                  "fromString": "MCPE Workflow",
                  "to": "722046",
                  "toString": "Global Mojang Workflow"
               },
               {
                  "field": "project",
                  "fieldtype": "jira",
                  "from": "10200",
                  "fromString": "Minecraft (Bedrock codebase)",
                  "to": "11700",
                  "toString": "Bedrock Dedicated Server"
               }
            ]
         },
         {
            "id": "3013664",
            "author": "weszaj_waw",
            "created": "2024-06-11T12:39:46.486+0300",
            "items": [
               {
                  "field": "resolution",
                  "fieldtype": "jira",
                  "from": null,
                  "fromString": null,
                  "to": "10001",
                  "toString": "Awaiting Response"
               },
               {
                  "field": "status",
                  "fieldtype": "jira",
                  "from": "1",
                  "fromString": "Open",
                  "to": "5",
                  "toString": "Resolved"
               }
            ]
         },
         {
            "id": "3014042",
            "author": "arisabot",
            "created": "2024-06-11T21:55:14.000+0300",
            "items": [
               {
                  "field": "resolution",
                  "fieldtype": "jira",
                  "from": "10001",
                  "fromString": "Awaiting Response",
                  "to": null,
                  "toString": null
               },
               {
                  "field": "status",
                  "fieldtype": "jira",
                  "from": "5",
                  "fromString": "Resolved",
                  "to": "4",
                  "toString": "Reopened"
               }
            ]
         },
         {
            "id": "3014169",
            "author": "weszaj_waw",
            "created": "2024-06-12T09:47:10.911+0300",
            "items": [
               {
                  "field": "resolution",
                  "fieldtype": "jira",
                  "from": null,
                  "fromString": null,
                  "to": "10001",
                  "toString": "Awaiting Response"
               },
               {
                  "field": "status",
                  "fieldtype": "jira",
                  "from": "4",
                  "fromString": "Reopened",
                  "to": "5",
                  "toString": "Resolved"
               }
            ]
         }
      ]
   }
}