StaticgetThis function can't be called in early-execution mode.
import { ItemTypes, Player, system } from "@minecraft/server";
// Run `/scriptevent example:getappletype` in chat to inspect the apple item type.
system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
if (id !== "example:getappletype" || !(sourceEntity instanceof Player)) return;
const itemType = ItemTypes.get("minecraft:apple");
if (!itemType) return;
sourceEntity.sendMessage(`Found item type: ${itemType.id}`);
});
StaticgetThis function can't be called in early-execution mode.
import { ItemTypes, Player, system } from "@minecraft/server";
// Run `/scriptevent example:listitemtypes` in chat to list registered item type IDs.
system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
if (id !== "example:listitemtypes" || !(sourceEntity instanceof Player)) return;
const itemIds = ItemTypes.getAll().map((itemType) => itemType.id);
sourceEntity.sendMessage(`Item types (${itemIds.length}): ${itemIds.slice(0, 10).join(", ")}`);
});
Returns the set of item types registered within Minecraft.
Source