Table of Contents

Class EntityItem

Namespace
Vintagestory.API.Common
Assembly
VintagestoryAPI.dll
public class EntityItem : Entity
Inheritance
EntityItem
Inherited Members

Constructors

EntityItem()

public EntityItem()

Fields

Slot

public EntityItemSlot Slot

Field Value

EntityItemSlot

itemSpawnedMilliseconds

public long itemSpawnedMilliseconds

Field Value

long

Properties

ByPlayerUid

The UID of the player that dropped this itemstack.

public string ByPlayerUid { get; set; }

Property Value

string

IsInteractable

Whether or not the EntityItem is interactable.

public override bool IsInteractable { get; }

Property Value

bool

Itemstack

The itemstack attached to this Item Entity.

public ItemStack Itemstack { get; set; }

Property Value

ItemStack

LightHsv

Get the HSV colors for the lighting.

public override byte[] LightHsv { get; }

Property Value

byte[]

MaterialDensity

Returns the material density of the item.

public override float MaterialDensity { get; }

Property Value

float

SwimmingOffsetY

Used for passive physics simulation, together with the MaterialDensity to check how deep in the water the entity should float

public override double SwimmingOffsetY { get; }

Property Value

double

Methods

CanCollect(Entity)

Should return true if this item can be picked up as an itemstack

public override bool CanCollect(Entity byEntity)

Parameters

byEntity Entity

Returns

bool

Die(EnumDespawnReason, DamageSource)

Makes the entity despawn. Entities only drop something on EnumDespawnReason.Death

public override void Die(EnumDespawnReason reason = EnumDespawnReason.Death, DamageSource damageSourceForDeath = null)

Parameters

reason EnumDespawnReason
damageSourceForDeath DamageSource

FromBytes(BinaryReader, bool)

Loads the entity from a stored byte array from the SaveGame

public override void FromBytes(BinaryReader reader, bool forClient)

Parameters

reader BinaryReader
forClient bool

FromItemstack(ItemStack, Vec3d, Vec3d, IWorldAccessor)

Builds and spawns an EntityItem from a provided ItemStack.

public static EntityItem FromItemstack(ItemStack itemstack, Vec3d position, Vec3d velocity, IWorldAccessor world)

Parameters

itemstack ItemStack

The contents of the EntityItem

position Vec3d

The position of the EntityItem

velocity Vec3d

The velocity of the EntityItem

world IWorldAccessor

The world the EntityItems preside in.

Returns

EntityItem

A freshly baked EntityItem to introduce to the world.

Initialize(EntityProperties, ICoreAPI, long)

Called when this entity got created or loaded

public override void Initialize(EntityProperties properties, ICoreAPI api, long chunkindex3d)

Parameters

properties EntityProperties
api ICoreAPI
chunkindex3d long

OnCollected(Entity)

Called by BehaviorCollectEntities of nearby entities. Should return the itemstack that should be collected. If the item stack was fully picked up, BehaviorCollectEntities will kill this entity

public override ItemStack OnCollected(Entity byEntity)

Parameters

byEntity Entity

Returns

ItemStack

OnCollideWithLiquid()

Called when the entity got in touch with a liquid

public override void OnCollideWithLiquid()

OnEntityDespawn(EntityDespawnData)

Called when the entity despawns

public override void OnEntityDespawn(EntityDespawnData despawn)

Parameters

despawn EntityDespawnData

OnGameTick(float)

Called every 1/75 second

public override void OnGameTick(float dt)

Parameters

dt float

OnReceivedServerAnimations(int[], int, float[])

public override void OnReceivedServerAnimations(int[] activeAnimations, int activeAnimationsCount, float[] activeAnimationSpeeds)

Parameters

activeAnimations int[]
activeAnimationsCount int
activeAnimationSpeeds float[]

ReceiveDamage(DamageSource, float)

Called when the entity should be receiving damage from given source

public override bool ReceiveDamage(DamageSource damageSource, float damage)

Parameters

damageSource DamageSource
damage float

Returns

bool

True if the entity actually received damage

ShouldReceiveDamage(DamageSource, float)

Should return true if the entity can get damaged by given damageSource. Is called by ReceiveDamage.

public override bool ShouldReceiveDamage(DamageSource damageSource, float damage)

Parameters

damageSource DamageSource
damage float

Returns

bool

StartAnimation(string)

Starts the animation for the entity.

public override void StartAnimation(string code)

Parameters

code string

StopAnimation(string)

stops the animation for the entity.

public override void StopAnimation(string code)

Parameters

code string

UpdateDebugAttributes()

Updates the DebugAttributes tree

public override void UpdateDebugAttributes()