Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
Extends
If added onto the entity, this indicates that the entity represents a free-floating item in the world. Lets you retrieve the actual item stack contents via the itemStack property.
Properties
itemStack
read-only itemStack: ItemStack;
Item stack represented by this entity in the world.
Type: ItemStack
Notes:
- This property can throw errors when used.
Constants
componentId
static read-only componentId = "minecraft:item";
Type: string
Examples
testThatEntityIsFeatherItem.ts
import { EntityItemComponent, EntityComponentTypes, DimensionLocation } from '@minecraft/server';
function testThatEntityIsFeatherItem(
log: (message: string, status?: number) => void,
targetLocation: DimensionLocation
) {
const items = targetLocation.dimension.getEntities({
location: targetLocation,
maxDistance: 20,
});
for (const item of items) {
const itemComp = item.getComponent(EntityComponentTypes.Item) as EntityItemComponent;
if (itemComp) {
if (itemComp.itemStack.typeId.endsWith('feather')) {
log('Success! Found a feather', 1);
}
}
}
}
(preview) Work with this sample on the MCTools.dev code sandbox.