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

GameTest API error when trying to get the projectile from "projectileHit" or any other projectile related event.

XMLWordPrintable

    • Unconfirmed
    • Windows

      I frequently use the GameTest API for my addons, before the 1.20 update everything worked well but now the "projectileHit" after-event is giving me some issues. I am able to use all the properties of the event except the "projectile" one, in order to get the respective entity. If I try to access any property of the entity, such as "typeId", it will throw the error:
      "[Scripting][error]-Error: Failed to get property 'typeId' at <anonymous> (main.js:4)".

      My addon uses this event and I can't launch it if this doesn't work.

      Steps to Reproduce:

      • Step 1: create a simple addon that uses the "minecraft/server" module.
      • Step 2: create a script that contains the following code:
        import { world } from "@minecraft/server";
        
        world.afterEvents.projectileHit.subscribe(event => {
            const a = event.projectile.typeId;
        });
        
      • Step 3: add the addon to a world, enable the experiment "Beta APIs" and throw any projectile to a mob.

      Observed Results:
      The script throws the error "[Scripting][error]-Error: Failed to get property 'typeId' at <anonymous> (main.js:4)", therefore you can't get the projectile that triggered the event.

      Expected Results:
      The provided code should set the "a" variable to the typeId of the projectile, for example, "minecraft:arrow".

      Screenshots/Videos:
      https://i.imgur.com/GgCKdBy.mp4

      Notes:
      This issue also seems to affect other events where you can access a projectile. I tried debugging the code with VS Code but when I expand the projectile property in the "Variables" section it just keeps loading and doesn't show anything.

            MisledPaul58 Paul Castillo Delgado
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: