Skip to content

ItemEntity

Inherits from: Entity

Represents a physical item entity in the world, which can be picked up by players or other entities. It includes information about the dropped item, its age, and its original owner.

Fields

item: Item — Read/Write

A copy of the item represented by this item entity.

itemAge: number — Read-Only

The number of game ticks since this item entity was created in the world.

owner: Entity — Read-Only

A reference to the entity that spawned or owns this item entity.

Methods

new(item: Item, nbt?: table) → itemEntity: ItemEntity

Creates a new ItemEntity from a copy of the given item at the spell's current position.

The original item is not modified. If nbt is provided, its keys are merged into the item entity's NBT representation.

Example

local stick = ItemEntity:new(Item:new("stick"))
stick.pos = spell.owner.pos + spell.owner.lookVec * 5

Example: With custom NBT

local sword = ItemEntity:new(Item:new("diamond_sword"), {
  Glowing = 1
})

Parameters

  • item: Item — The item that this item entity should represent.
  • nbt?: table — NBT data to merge into the item entity's representation.

Returns

  • itemEntity: ItemEntity — A new instance representing the dropped item.