IEntity interface
public interface IEntity : IAttachmentHolder
In Obsidian.API.
Properties
short Air { get; set; }BoundingBox BoundingBox { get; }bool Burning { get; }ChatMessage CustomName { get; set; }bool CustomNameVisible { get; set; }Definition
EntityDefinition Definition { get; }The plugin entity type the entity is of, or null for a vanilla entity.
EntityDimension Dimension { get; }int EntityId { get; }bool FlyingWithElytra { get; set; }bool Glowing { get; }IGoalController GoalController { get; set; }float Health { get; set; }bool Invisible { get; }bool IsFireImmune { get; }VectorD LastPosition { get; set; }ILevel Level { get; }MovementFlags MovementFlags { get; }bool NoGravity { get; }Passengers
IReadOnlyList<IEntity> Passengers { get; }A read-only snapshot of the entities riding this one, in seat order; the first one steers a mount.
Pitch
float Pitch { get; set; }The entity's pitch in degrees: positive looks down. A player's is the exact value their client sent, wrapped and clamped to [-90, 90] as vanilla does.
Remarks
This was an Angle (256ths of a turn) before; it is the exact float now, as vanilla keeps it, so aimed uses see the direction the client sent. Angle still converts implicitly to and from float degrees, so assigning one keeps working.
Pose Pose { get; set; }VectorD Position { get; set; }bool Silent { get; }bool Sneaking { get; set; }bool Sprinting { get; set; }bool Summonable { get; }bool Swimming { get; set; }string TranslationKey { get; }Type
EntityType? Type { get; }The entity's vanilla type, or null for an entity of a plugin's type.
Guid Uuid { get; }Vehicle
IEntity Vehicle { get; }The entity this one rides, or null.
Yaw
float Yaw { get; set; }The entity's yaw in degrees: 0 faces south (+Z) and 90 west (-X). A player's is the exact value their client sent, wrapped to [-180, 180) as vanilla does.
Remarks
See IEntity.Pitch about the change from Angle.
Methods
ValueTask DamageAsync(IEntity source, float amount = 1f);GetAttributeValue(string)
float GetAttributeValue(string attributeResourceName);The attribute's value: its base with its modifiers applied, clamped to vanilla's range for it; 0 if the entity doesn't have the attribute.
GetData<T>(EntityDataField<T>)
T GetData<T>(EntityDataField<T> field);The value of one of the entity's synced data fields (see EntityProperties.DataFields).
IEnumerable<IEntity> GetEntitiesNear(float distance);GetLookDirection()
VectorF GetLookDirection();The unit vector the entity looks along, from its IEntity.Pitch and IEntity.Yaw: vanilla's getViewVector.
bool HasAttribute(string attributeResourceName);bool IsInRange(IEntity entity, float distance);ValueTask KillAsync(IEntity source);ValueTask KillAsync(IEntity source, ChatMessage message);ValueTask RemoveAsync();RemoveAttributeModifier(string, string)
bool RemoveAttributeModifier(string attribute, string id);Removes the attribute's modifier with the identifier.
Returns
Whether there was one.
SetAttributeModifier(string, string, double, AttributeOperation)
bool SetAttributeModifier(string attribute, string id, double amount, AttributeOperation operation);Adds a modifier to one of the entity's attributes, replacing its modifier with the same id, like vanilla's permanent modifiers: it is saved, and players tracking the entity are sent the change.
Parameters
attribute- The attribute, like
minecraft:movement_speed. id- The modifier's identifier, like
myplugin:charge. amount- What the modifier adds or multiplies by.
operation- How the amount applies, in vanilla's order: added to the base, then multiples of that sum added, then the result multiplied by one plus the amount.
Returns
Whether the entity has the attribute.
SetData<T>(EntityDataField<T>, T)
void SetData<T>(EntityDataField<T> field, T value);Sets one of the entity's synced data fields; players tracking the entity with a modded Obsidian client are sent the change on its next tick.
void SetHeadRotation(float headYaw);void SetRotation(float yaw, float pitch, MovementFlags movementFlags);SpawnEntity(Velocity?, int)
void SpawnEntity(Velocity? velocity = null, int additionalData = 0);Spawns the specified entity to player nearby in the world.
Parameters
velocity- The velocity the entity should spawn with
additionalData- Additional data for the entity. More info here: https://wiki.vg/Object_Data
StartRiding(IEntity)
bool StartRiding(IEntity vehicle);Mounts this entity on another, like vanilla's startRiding: any entity can ride any other in the same level that has a free seat, leaving its current vehicle first. A vehicle can't ride its own passenger.
Returns
Whether boarding succeeded, or was queued by an inventory hook.
Remarks
A player boards only a mob, and only while alive, not a spectator and not already riding. A plugin's mob carries as many passengers as its type has passenger attachments, at least one, and its first passenger steers it. From an inventory hook, boarding waits until its transaction releases the click locks; the seat and cycle checks run then.
StopRiding()
void StopRiding();Dismounts the entity from what it rides, if anything, after the transaction when called by an inventory hook.
ValueTask TeleportAsync(IEntity to);TeleportAsync(ILevel, VectorD, float?, float?)
ValueTask TeleportAsync(ILevel level, VectorD position, float? yaw = null, float? pitch = null);Moves this entity and its passengers to a level, preserving entity state and velocity. Null rotation components retain their current values. The destination is loaded before removal.
ValueTask TeleportAsync(IWorld world);ValueTask TeleportAsync(VectorD pos);ValueTask TickAsync();bool TryAddAttribute(string attributeResourceName, float value);bool TryUpdateAttribute(string attributeResourceName, float newValue);ValueTask UpdateAsync(float yaw, float pitch, MovementFlags movementFlags);ValueTask UpdateAsync(VectorD position, float yaw, float pitch, MovementFlags movementFlags);ValueTask UpdateAsync(VectorD position, MovementFlags movementFlags);void Write(INetStreamWriter writer);