Mojira Archive
BDS-18672

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

@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');

Comments4

Could this get swapped to bedrock edition instead of bds some how didn’t see it. Think something messed up as when I first copied it, it was MCPE-174596 which points towards BDS-18672 which is what it is currently.

Hi

This occur only on Bedrock Dedicated Server or it can be reproduced on local worlds/Realms?

This ticket will automatically reopen when you reply.

This also happens in 1.20.31, on local worlds. But this time you can get the player's armor, not entities such as zombies

Cleaning up old tickets: This ticket had been set to 'Awaiting Response', but has not received a response from the reporter (~3 months+) so is being closed as Incomplete. If you feel this is still a valid issue then please comment, or create a new ticket following the Issue Guidelines which includes steps to reproduce the problem.

Quick Links:
📓 Issue Guidelines – 💬 Mojang Support – 📧 Suggestions – 📖 Minecraft Wiki

History7

mrpatches123

Changed description:

@minecraft/server 1.6.0-beta

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

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

0

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

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

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

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

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

0

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

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

mrpatches123

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

mrpatches123

Changed summary:

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

[Mod] Umija5895M

Key

Platform

project

Added affects versions: 1.20.15 Hotfix

Removed affects versions: 1.20.15 Hotfix

Maciej Piornik
[MCQA] Kinga Izdebska
[MCQA] Kinga Izdebska

Resolution: UnresolvedIncomplete

Incomplete
mrpatches123
0
2
Unconfirmed
1.20.15 Hotfix