Repository navigation
API ‐ Entity
All entity variants can be found here VanillaEntities except CustomEntity() but its usage is same.
Possible ActorProperties values can be found here bedrock-samples by looking at "properties" values. For example from bedrock-samples
"minecraft:entity": {
"description": {
"identifier": "minecraft:pig",
"spawn_category": "creature",
"is_spawnable": true,
"is_summonable": true,
"properties": {
"minecraft:climate_variant": {
"type": "enum",
"values": [ "temperate", "warm", "cold" ],
"default": "temperate",
"client_sync": true
}
}
},
We can create
ActorProperties.RegisterProperty("minecraft:pig", new ActorProperty(new string[] { "temperate", "warm", "cold" }, "minecraft:climate_variant"));
Entity spawn example.
public override void OnLoad()
{
ResourcePackManager.RegisterAnimation("idleAnimation", "controller.animation.humanoid.custom_controller", "animation.humanoid.custom.Rocky");
ActorProperties.RegisterProperty("minecraft:pig", new ActorProperty(new string[] { "temperate", "warm", "cold" }, "minecraft:climate_variant"));
}
var entity = new Spider();
entity.Position = Vector3(0, 0, 0);
entity.Skin = Skin.Create("Plugins/skin.png", "Plugins/geometry.json"); //Warning: This feature is exclusive for CustomEntity entities.
entity.NameTag = "Rocky";
entity.SpawnAnimation = "idleAnimation";
entity.Properties.UpdateEntry(0, 2); //this matched registered property at OnLoad(): 0 is index for climate_variant, 2 is property (in this case cold, according to registered property 0 - "temperate", 1 - "warm", 2 - "cold")
entity.Spawn(world);
Despawns entity.
entity.Despawn();
Move entity to specified location.
entity.MoveTo(new Vector3(10, -20, 15))
Update entities properties registered by ActorProperties.RegisterProperty. Read more about how to use properties in Entity tab.
Properties.UpdateEntry(0, 2);
Broadcast (long = (default -1)) or send to only one player (long - player.EntityID) entity animation registered by ResourcePackManager RegisterAnimation.
entity.PlayAnimation("CustomSpawnAnimation")
Enable (Bool - true) or disable (Bool - false) ActorFlags data for the entity.
entity.SetFlag(ActorFlags.ONFIRE, true);
Change entity display name that other players can see.
entity.SetNameTag($"Mod {player.username}")
Spawns entity in specified world.
entity.Spawn(world);