EntitySpawnEvent
Namespace Mc.Scripting.Events · Kind struct (ref)
public ref struct EntitySpawnEvent : IEventAn entity is about to be added to the world. Cancel to prevent it.
| Id | 30 |
| Key | mc:entity_spawn |
| Cancellable | yes |
| Fired by the engine | yes |
| Field | Type | Handlers may write | Description |
|---|---|---|---|
Entity |
Entity |
no (readonly) | The entity (already created). |
EntityType |
key.entity_type |
no (readonly) | The entity type key, e.g. minecraft:zombie. |
Position |
Vec3d |
no (readonly) | Where it appears. |
Reason |
enum:SpawnReason |
no (readonly) | Why it spawns. |
Set e.Cancelled = true in a handler to cancel it; lower-priority handlers are skipped unless they subscribed with receiveCancelled: true.
Constructors
Section titled “Constructors”| Member | Description |
|---|---|
EntitySpawnEvent(Entity entity, int entityType, Vec3d position, SpawnReason reason) |
Creates the event (for firing it from a plugin; native code builds its own). |
Constructor
Section titled “Constructor”public EntitySpawnEvent(Entity entity, int entityType, Vec3d position, SpawnReason reason)Creates the event (for firing it from a plugin; native code builds its own). Signature of API 1.0.
Parameters
| Name | Type | Description |
|---|---|---|
entity |
Entity |
|
entityType |
int |
|
position |
Vec3d |
|
reason |
SpawnReason |
Properties
Section titled “Properties”| Member | Description |
|---|---|
bool Cancelled { get; set; } |
Cancelling stops lower-priority handlers (unless they opt in) and the action itself. |
Entity Entity { get; } |
The entity (already created). |
string EntityType { get; } |
The entity type key, e.g. |
Vec3d Position { get; } |
Where it appears. |
SpawnReason Reason { get; } |
Why it spawns. |
static ushort CatalogueId { get; } |
Catalogue id (stable ABI). |
static bool IsCancellable { get; } |
Whether handlers can cancel the event. |
static string Key { get; } |
Registry key of the event. |
Cancelled
Section titled “Cancelled”public bool Cancelled { get; set; }Cancelling stops lower-priority handlers (unless they opt in) and the action itself.
Entity
Section titled “Entity”public Entity Entity { get; }The entity (already created).
EntityType
Section titled “EntityType”public string EntityType { get; }The entity type key, e.g. minecraft:zombie. (a registry key such as “minecraft:entity”; resolved on first access).
Position
Section titled “Position”public Vec3d Position { get; }Where it appears.
Reason
Section titled “Reason”public SpawnReason Reason { get; }Why it spawns.
CatalogueId
Section titled “CatalogueId”public static ushort CatalogueId { get; }Catalogue id (stable ABI).
IsCancellable
Section titled “IsCancellable”public static bool IsCancellable { get; }Whether handlers can cancel the event.
public static string Key { get; }Registry key of the event.
See also
Section titled “See also”Entity · IEvent · SpawnReason · Vec3d