Uploaded image for project: 'Minecraft (Bedrock codebase)'
  1. Minecraft (Bedrock codebase)
  2. MCPE-166919

Beta API - Error when Spawning Entity and using the ScoreboardIdentity.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Awaiting Response
    • None
    • 1.19.60
    • Unconfirmed
    • Windows

      Description:

      in the Beta API, minecraft/server API version 1.1.0-beta, spawning an entity using the class Dimension's 'spawnEntity' function, and using the newly created entity's 'scoreboard' property to set a scoreboard entry results in an undefined value error.

      Code:
      import * as mc from '@minecraft/server'; //importing the minecraft api

      let entity = mc.world.getDimension("overworld").spawnEntity("minecraft:pig", new mc.Location(0,0,0));// creating entity
      entity.nameTag = "hello world"; //setting nametag
      entity.scoreboard.setScore(mc.world.scoreboard.getObjective("gameMenu"), 12); //setting score of entity in the "gameMenu" scoreboard (DOES NOT WORK)
      Error Message: 
      [Scripting][error]-Plugin [Dev BP - 1.0.1] - [mainFile.js] ran with error: [TypeError: cannot read property 'setScore' of undefined    at <anonymous> (mainFile.js:5)
       
      Steps:
      1. put the datapack file attached into the development behavior pack folder within minecraft.
      2. create and open a world with said behavior pack.
      3. create a scoreboard with the same id (possible command: /scoreboard objectives add gameMenu dummy gameMenu)
      4.  run the command '/reload'
      5. check and look inside the Content Log History; it shows the above error message.
       

            stamparkour stamparkour
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: