Table of Contents

Class EntityPlayer

Namespace
Vintagestory.API.Common
Assembly
VintagestoryAPI.dll
public class EntityPlayer : EntityHumanoid
Inheritance
EntityPlayer
Inherited Members

Constructors

EntityPlayer()

public EntityPlayer()

Fields

BlockSelection

The block or blocks currently selected by the player

public BlockSelection BlockSelection

Field Value

BlockSelection

BodyYawLimits

public Vec2f BodyYawLimits

Field Value

Vec2f

CameraPos

The camera position of the player's view. Set only by the game client.

public Vec3d CameraPos

Field Value

Vec3d

DeathReason

The reason the player died (if the player did die). Set only by the game server.

public DamageSource DeathReason

Field Value

DamageSource

EntitySelection

The entity or entities selected by the player

public EntitySelection EntitySelection

Field Value

EntitySelection

HeadYawLimits

public Vec2f HeadYawLimits

Field Value

Vec2f

OnCanSpawnNearby

Called whenever the game wants to spawn new creatures around the player. Called only by the game server.

public CanSpawnNearbyDelegate OnCanSpawnNearby

Field Value

CanSpawnNearbyDelegate

PrevFrameCanStandUp

public bool PrevFrameCanStandUp

Field Value

bool

PreviousBlockSelection

The block position previously selected by the player

public BlockPos PreviousBlockSelection

Field Value

BlockPos

WalkPitch

The pitch the player currently wants to move to. Only relevant while swimming. Value set by the PlayerPhysics system. Set by the game client and server.

public float WalkPitch

Field Value

float

WalkYaw

The yaw the player currently wants to walk towards to. Value set by the PlayerPhysics system. Set by the game client and server.

public float WalkYaw

Field Value

float

entityListForPartitioning

Used to assist if this EntityPlayer needs to be repartitioned

public List<Entity> entityListForPartitioning

Field Value

List<Entity>

selfClimateCond

public ClimateCondition selfClimateCond

Field Value

ClimateCondition

selfNowShadowPass

public bool selfNowShadowPass

Field Value

bool

sidewaysSwivelAngle

public float sidewaysSwivelAngle

Field Value

float

talkTypeByAnimation

protected static Dictionary<string, EnumTalkType> talkTypeByAnimation

Field Value

Dictionary<string, EnumTalkType>

talkUtil

public EntityTalkUtil talkUtil

Field Value

EntityTalkUtil

walkSpeed

This is not walkspeed per se, it is the walkspeed modifier as a result of armor and other gear. It corresponds to Stats.GetBlended("walkspeed") and gets updated every tick

public float walkSpeed

Field Value

float

Properties

AlwaysActive

Whether this entity should always stay in Active model, regardless on how far away other player are

public override bool AlwaysActive { get; }

Property Value

bool

AnimManager

Server simulated animations. Only takes care of stopping animations once they're done Set and Called by the Entities ServerSystem

public override IAnimationManager AnimManager { get; set; }

Property Value

IAnimationManager

BodyYaw

The yaw of the agents body

public override float BodyYaw { get; set; }

Property Value

float

GearInventory

The players wearables. Available on the client and the server.

public override IInventory GearInventory { get; }

Property Value

IInventory

IsInteractable

Should return true when this entity should be interactable by a player or other entities

public override bool IsInteractable { get; }

Property Value

bool

LadderFixDelta

A small offset used to prevent players from clipping through the blocks above ladders: relevant if the entity's collision box is sometimes adjusted by the game code

public override double LadderFixDelta { get; }

Property Value

double

LastReviveTotalHours

public double LastReviveTotalHours { get; set; }

Property Value

double

LeftHandItemSlot

The playres left hand contents. Available on the client and the server.

public override ItemSlot LeftHandItemSlot { get; }

Property Value

ItemSlot

LightHsv

If set, the entity will emit dynamic light

public override byte[] LightHsv { get; }

Property Value

byte[]

OtherAnimManager

public IAnimationManager OtherAnimManager { get; }

Property Value

IAnimationManager

Player

The base player attached to this EntityPlayer.

public IPlayer Player { get; }

Property Value

IPlayer

PlayerUID

The player's internal Universal ID. Available on the client and the server.

public string PlayerUID { get; }

Property Value

string

RightHandItemSlot

The players right hand contents. Available on the client and the server.

public override ItemSlot RightHandItemSlot { get; }

Property Value

ItemSlot

ShouldDespawn

Whether or not the entity should despawn.

public override bool ShouldDespawn { get; }

Property Value

bool

StoreWithChunk

Players and whatever the player rides on will be stored seperatly

public override bool StoreWithChunk { get; }

Property Value

bool

TpAnimManager

public IAnimationManager TpAnimManager { get; }

Property Value

IAnimationManager

Methods

CanSpawnNearby(EntityProperties, Vec3d, RuntimeSpawnConditions)

public virtual bool CanSpawnNearby(EntityProperties type, Vec3d spawnPosition, RuntimeSpawnConditions sc)

Parameters

type EntityProperties
spawnPosition Vec3d
sc RuntimeSpawnConditions

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

GetInfoText()

gets the info text for the entity.

public override string GetInfoText()

Returns

string

GetInsideLegsBlockSoundSource(BlockPos)

public virtual Block GetInsideLegsBlockSoundSource(BlockPos tmpPos)

Parameters

tmpPos BlockPos

Returns

Block

GetInsideTorsoBlockSoundSource(BlockPos)

public virtual Block GetInsideTorsoBlockSoundSource(BlockPos tmpPos)

Parameters

tmpPos BlockPos

Returns

Block

GetName()

Gets the name for this entity

public override string GetName()

Returns

string

GetNearestBlockSoundSource(BlockPos, double, int, bool)

Returns null if there is no nearby sound source

public Block GetNearestBlockSoundSource(BlockPos tmpPos, double yOffset, int blockLayer, bool usecollisionboxes)

Parameters

tmpPos BlockPos

Might get intentionally modified if the nearest sound source the player is intersecting with is in an adjacent block

yOffset double
blockLayer int
usecollisionboxes bool

Returns

Block

GetWalkSpeedMultiplier(double)

Gets the walk speed multiplier.

public override double GetWalkSpeedMultiplier(double groundDragFactor = 0.3)

Parameters

groundDragFactor double

The amount of drag provided by the current ground. (Default: 0.3)

Returns

double

HandleSeraphHandAnimations(float)

public void HandleSeraphHandAnimations(float dt)

Parameters

dt float

Ignite()

public override void Ignite()

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

OnAsyncParticleTick(float, IAsyncParticleManager)

public override void OnAsyncParticleTick(float dt, IAsyncParticleManager manager)

Parameters

dt float
manager IAsyncParticleManager

OnCollideWithLiquid()

Called when the entity got in touch with a liquid

public override void OnCollideWithLiquid()

OnFallToGround(double)

Called when the entity collided vertically

public override void OnFallToGround(double motionY)

Parameters

motionY double

OnGameTick(float)

Called every 1/75 second

public override void OnGameTick(float dt)

Parameters

dt float

OnHurt(DamageSource, float)

Called when the entity got hurt. On the client side, dmgSource is null

public override void OnHurt(DamageSource damageSource, float damage)

Parameters

damageSource DamageSource
damage float

OnReceivedClientPacket(IServerPlayer, int, byte[])

Called when on the client side something called capi.Network.SendEntityPacket()

public override void OnReceivedClientPacket(IServerPlayer player, int packetid, byte[] data)

Parameters

player IServerPlayer
packetid int
data byte[]

OnReceivedServerPacket(int, byte[])

Called when on the server side something called sapi.Network.SendEntityPacket() Packetid = 1 is used for teleporting Packetid = 2 is used for BehaviorHarvestable

public override void OnReceivedServerPacket(int packetid, byte[] data)

Parameters

packetid int
data byte[]

OnSelfBeforeRender(float)

public void OnSelfBeforeRender(float dt)

Parameters

dt float

OnTesselation(ref Shape, string)

Called by EntityShapeRenderer.cs before tesselating the entity shape

public override void OnTesselation(ref Shape entityShape, string shapePathForLogging)

Parameters

entityShape Shape
shapePathForLogging string

PlayEntitySound(string, IPlayer, bool, float)

Assumes that it is only called on the server

public override void PlayEntitySound(string type, IPlayer dualCallByPlayer = null, bool randomizePitch = true, float range = 24)

Parameters

type string
dualCallByPlayer IPlayer
randomizePitch bool
range float

PlayInsideSound(IPlayer)

public virtual bool PlayInsideSound(IPlayer player)

Parameters

player IPlayer

Returns

bool

PlayStepSound(IPlayer, bool)

public virtual void PlayStepSound(IPlayer player, bool playingInsideSound)

Parameters

player IPlayer
playingInsideSound bool

Revive()

Revives the entity and heals for 9999.

public override void Revive()

SetCurrentlyControlledPlayer()

Sets the current player.

public void SetCurrentlyControlledPlayer()

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

TeleportToDouble(double, double, double, Action)

Teleports the entity to given position. Actual teleport is delayed until target chunk is loaded.

public override void TeleportToDouble(double x, double y, double z, Action onTeleported = null)

Parameters

x double
y double
z double
onTeleported Action

TryGiveItemStack(ItemStack)

Called when something tries to given an itemstack to this entity

public override bool TryGiveItemStack(ItemStack itemstack)

Parameters

itemstack ItemStack

Returns

bool

TryMount(IMountable)

Attempts to mount the player on a target.

public override bool TryMount(IMountable onmount)

Parameters

onmount IMountable

The mount to mount

Returns

bool

Whether it was mounted or not.

TryStopHandAction(bool, EnumItemUseCancelReason)

Attempts to stop the hand action.

public override bool TryStopHandAction(bool forceStop, EnumItemUseCancelReason cancelReason = EnumItemUseCancelReason.ReleasedMouse)

Parameters

forceStop bool
cancelReason EnumItemUseCancelReason

The reason for stopping the action.

Returns

bool

Whether the stop was cancelled or not.

UpdateDebugAttributes()

Updates the DebugAttributes tree

public override void UpdateDebugAttributes()

UpdatePartitioning()

public void UpdatePartitioning()

WalkInventory(OnInventorySlot)

This walks the inventory for the entity agent.

public override void WalkInventory(OnInventorySlot handler)

Parameters

handler OnInventorySlot

the event to fire while walking the inventory.

canPlayEdgeSitAnim()

protected bool canPlayEdgeSitAnim()

Returns

bool

getSoundSourceBlockAt(Cuboidd, BlockPos, int, bool)

protected Block getSoundSourceBlockAt(Cuboidd entityBox, BlockPos tmpPos, int blockLayer, bool usecollisionboxes)

Parameters

entityBox Cuboidd
tmpPos BlockPos
blockLayer int
usecollisionboxes bool

Returns

Block

onAnimControls(AnimationMetaData, bool, bool)

protected override bool onAnimControls(AnimationMetaData anim, bool wasActive, bool nowActive)

Parameters

anim AnimationMetaData
wasActive bool
nowActive bool

Returns

bool

protectEyesFromWind(float)

protected void protectEyesFromWind(float dt)

Parameters

dt float

Events

OnFootStep

Set this to hook into the foot step sound creator thingy. Currently used by the armor system to create armor step sounds. Called by the game client and server.

public event Action OnFootStep

Event Type

Action

OnImpact

Called when the player falls onto the ground. Called by the game client and server.

public event Action<double> OnImpact

Event Type

Action<double>