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

[Scripting] EntityEquippableComponent and its methods: setEquipment, getEquipmentSlot and getEquipment are broken

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Incomplete
    • None
    • 1.20.15 Hotfix
    • None
    • Unconfirmed

      @minecraft/server 1.6.0-beta

      import { EntityEquippableComponent, EquipmentSlot, system, world } from '@minecraft/server';
      system.runInterval(() => {
          world.getAllPlayers().forEach(player => {
              /**
               * @type {EntityEquippableComponent}
               */
              const equippable = player.getComponent('minecraft:equippable');
              const slot = equippable.getEquipmentSlot(EquipmentSlot.Offhand);
              console.warn(slot?.typeId ?? 'null');
          });
      });

      Expected Results:
      logs the type of the item in my offhand.

      Observed Results:
      throws 
      TypeError: Unexpected type passed to function argument [0].    at <anonymous> (index4.js:32)
      at forEach (native)
      at <anonymous> (index4.js:34)
      does the same for getEquipment  and setEquipment and for "Offhand" or any of the others it throws a native conversion type error.

      //line 34
      const slot = equippable.getEquipmentSlot(EquipmentSlot.Offhand);
      

      also entity.getComponent("equippable"); might not work on entities.

      import { EntityEquippableComponent, EquipmentSlot, system, world } from '@minecraft/server';
      world.getDimension(MinecraftDimensionTypes.overworld).getEntities().forEach(entity => {
              if (entity.typeId !== 'minecraft:skeleton') return;
              console.warn(entity.typeId);
              /**
               * @type {EntityEquippableComponent}
               */
              const equippable = entity.getComponent('minecraft:equippable');
              const slot = equippable.getEquipmentSlot(EquipmentSlot.Mainhand);
              console.warn(slot?.typeId ?? 'null');
          });
      });
      
      

      For a skeleton:
      Expected Results:
      logs 'minecraft:bow'.

      Observed Results:
      throws
      TypeError: cannot read property 'getEquipmentSlot' of undefined at <anonymous> (index4.js:42)
      at forEach (native)
      at <anonymous> (index4.js:44)

      //line 42
      const equippable = entity.getComponent('minecraft:equippable');
      

            Unassigned Unassigned
            mrpatches123 mrpatches123
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: