Class EntityPlayer
- Namespace
- Vintagestory.API.Common
- Assembly
- VintagestoryAPI.dll
public class EntityPlayer : EntityHumanoid, IPettable
- Inheritance
-
EntityPlayer
- Implements
- Inherited Members
- Extension Methods
Constructors
EntityPlayer()
public EntityPlayer()
Fields
BlockSelection
The block or blocks currently selected by the player
public BlockSelection BlockSelection
Field Value
BodyYawLimits
public AngleConstraint BodyYawLimits
Field Value
CameraPos
The camera position of the player's view. Set only by the game client.
public Vec3d CameraPos
Field Value
CameraPosOffset
An offset which can be applied to the camera position to achieve certain special effects or special features, for example Timeswitch feature. Set only by the game client.
public Vec3d CameraPosOffset
Field Value
DeathReason
The reason the player died (if the player did die). Set only by the game server.
public DamageSource DeathReason
Field Value
EntitySelection
The entity or entities selected by the player
public EntitySelection EntitySelection
Field Value
HeadYawLimits
public AngleConstraint HeadYawLimits
Field Value
OnCanSpawnNearby
Called whenever the game wants to spawn new creatures around the player. Called only by the game server.
public CanSpawnNearbyDelegate OnCanSpawnNearby
Field Value
PrevFrameCanStandUp
public bool PrevFrameCanStandUp
Field Value
PreviousBlockSelection
The block position previously selected by the player
public BlockPos PreviousBlockSelection
Field Value
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
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
entityListForPartitioning
Used to assist if this EntityPlayer needs to be repartitioned
public List<Entity> entityListForPartitioning
Field Value
selfClimateCond
public ClimateCondition selfClimateCond
Field Value
selfNowShadowPass
public bool selfNowShadowPass
Field Value
talkTypeByAnimation
protected static Dictionary<string, EnumTalkType> talkTypeByAnimation
Field Value
talkUtil
public EntityTalkUtil talkUtil
Field Value
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
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
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
BodyYaw
The yaw of the agents body
public override float BodyYaw { get; set; }
Property Value
HeadBobbingAmplitude
public float HeadBobbingAmplitude { get; set; }
Property Value
IsInteractable
Should return true when this entity should be interactable by a player or other entities
public override bool IsInteractable { get; }
Property Value
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
LastReviveTotalHours
public double LastReviveTotalHours { get; set; }
Property Value
LeftHandItemSlot
The playres left hand contents. Available on the client and the server.
public override ItemSlot LeftHandItemSlot { get; }
Property Value
LightHsv
If set, the entity will emit dynamic light
public override byte[] LightHsv { get; }
Property Value
- byte[]
OtherAnimManager
public IAnimationManager OtherAnimManager { get; }
Property Value
Player
The base player attached to this EntityPlayer.
public IPlayer Player { get; }
Property Value
PlayerUID
The player's internal Universal ID. Available on the client and the server.
public string PlayerUID { get; }
Property Value
RightHandItemSlot
The players right hand contents. Available on the client and the server.
public override ItemSlot RightHandItemSlot { get; }
Property Value
ShouldDespawn
Whether or not the entity should despawn.
public override bool ShouldDespawn { get; }
Property Value
StoreWithChunk
Players and whatever the player rides on will be stored seperatly
public override bool StoreWithChunk { get; }
Property Value
TpAnimManager
public IAnimationManager TpAnimManager { get; }
Property Value
Methods
CanPet(Entity)
public bool CanPet(Entity byEntity)
Parameters
byEntity
Entity
Returns
CanSpawnNearby(EntityProperties, Vec3d, RuntimeSpawnConditions)
public virtual bool CanSpawnNearby(EntityProperties type, Vec3d spawnPosition, RuntimeSpawnConditions sc)
Parameters
type
EntityPropertiesspawnPosition
Vec3dsc
RuntimeSpawnConditions
Returns
ChangeDimension(int)
public void ChangeDimension(int dim)
Parameters
dim
int
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
EnumDespawnReasondamageSourceForDeath
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
BinaryReaderforClient
bool
GetInfoText()
gets the info text for the entity.
public override string GetInfoText()
Returns
GetInsideLegsBlockSoundSource(BlockPos)
public virtual Block GetInsideLegsBlockSoundSource(BlockPos tmpPos)
Parameters
tmpPos
BlockPos
Returns
GetInsideTorsoBlockSoundSource(BlockPos)
public virtual Block GetInsideTorsoBlockSoundSource(BlockPos tmpPos)
Parameters
tmpPos
BlockPos
Returns
GetName()
Gets the name for this entity
public override string GetName()
Returns
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
BlockPosMight get intentionally modified if the nearest sound source the player is intersecting with is in an adjacent block
yOffset
doubleblockLayer
intusecollisionboxes
bool
Returns
GetWalkSpeedMultiplier(double)
Gets the walk speed multiplier.
public override double GetWalkSpeedMultiplier(double groundDragFactor = 0.3)
Parameters
groundDragFactor
doubleThe amount of drag provided by the current ground. (Default: 0.3)
Returns
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
EntityPropertiesapi
ICoreAPIchunkindex3d
long
OnAsyncParticleTick(float, IAsyncParticleManager)
public override void OnAsyncParticleTick(float dt, IAsyncParticleManager manager)
Parameters
dt
floatmanager
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
DamageSourcedamage
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
IServerPlayerpacketid
intdata
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
OnSelfBeforeRender(float)
public void OnSelfBeforeRender(float dt)
Parameters
dt
float
OnTesselated()
public override void OnTesselated()
OnTesselation(ref Shape, string)
Called by EntityShapeRenderer.cs before tesselating the entity shape
public override void OnTesselation(ref Shape entityShape, string shapePathForLogging)
Parameters
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
PlayInsideSound(IPlayer)
public virtual bool PlayInsideSound(IPlayer player)
Parameters
player
IPlayer
Returns
PlayStepSound(IPlayer, bool)
public virtual void PlayStepSound(IPlayer player, bool playingInsideSound)
Parameters
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
DamageSourcedamage
float
Returns
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
TryGiveItemStack(ItemStack)
Called when something tries to given an itemstack to this entity
public override bool TryGiveItemStack(ItemStack itemstack)
Parameters
itemstack
ItemStack
Returns
TryMount(IMountableSeat)
Attempts to mount this entity on a target.
public override bool TryMount(IMountableSeat onmount)
Parameters
onmount
IMountableSeatThe 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
boolcancelReason
EnumItemUseCancelReasonThe 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
OnInventorySlotthe event to fire while walking the inventory.
canPlayEdgeSitAnim()
protected bool canPlayEdgeSitAnim()
Returns
getSoundSourceBlockAt(Cuboidd, BlockSelection, int, bool)
protected Block getSoundSourceBlockAt(Cuboidd entityBox, BlockSelection blockSel, int blockLayer, bool usecollisionboxes)
Parameters
entityBox
CuboiddblockSel
BlockSelectionblockLayer
intusecollisionboxes
bool
Returns
onAnimControls(AnimationMetaData, bool, bool)
protected override bool onAnimControls(AnimationMetaData anim, bool wasActive, bool nowActive)
Parameters
anim
AnimationMetaDatawasActive
boolnowActive
bool
Returns
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
OnImpact
Called when the player falls onto the ground. Called by the game client and server.
public event Action<double> OnImpact