#Is it possible to access the EntityEquippableComponent of a non-player entity?

1 messages · Page 1 of 1 (latest)

hollow citrus
#

Doing something like mob.getComponent(EntityEquippableComponent.componentId) doesn't seem to work when mob isn't a player, but the MS learn docs say that this component should exist for all entities. 🤔

copper ermine
#

show code

hollow citrus
#

This is still a bit of a test run that got blocked by an error, so there's not a whole lot going on. I've got this:

import {system, world, EntityEquippableComponent} from "@minecraft/server";

console.warn(`Player is holding ${owner.getComponent(EntityEquippableComponent.componentId).getEquipment("Mainhand").typeId}`);
console.warn(`Wolf has ${wolf.getComponent(EntityEquippableComponent.componentId).getEquipment("Head").typeId}` equipped);

I can confirm that owner and wolf are valid entities, set elsewhere in the script.

#

Running this results in this error, caught by a try/catch

#

Having said all of that, I'll see if I can get a more testable code sample. This script has a ton of irrelevant code, so I can't just put it all here lol

frozen jackal
#

They temporarily made it inaccessible to entities that are not a Player. Until further notice.

#

I believe in 1.20.20.

copper ermine
#
console.warn(wolf.getComponents().map(c=>c.typeId.substr(10)).join("\n"))
#

I usually just display the entity's stuff

hollow citrus
frozen jackal
#

That's the version where they implemented the change.

#

EntityEquipmentInventoryComponent is currently limited to Players only. However, we hope to reintroduce this component for mobs in a future update

copper ermine
#
console.warn(JSON.stringify(world.getDimension("overworld")
    .getEntities().reduce((o, e) => {
        o[e.typeId.replace('minecraft:', '')] = e
            .getComponents().map(c => c?.typeId.substring(10))
        return o
    }, {}), null, 3))
hollow citrus
hollow citrus
frozen jackal