Tutorials/Creating custom entity add-ons

From Minecraft Wiki
Jump to: navigation, search


Iron Pickaxe JE3 BE2.png
This article is a work in progress.
Please help in the creation of this article by expanding or improving it.
The talk page may contain suggestions.
Information icon.svg
This feature is exclusive to Bedrock Edition.

This tutorial is a guide to creating a custom entity add-on for Bedrock Edition. This is not a guide to creating a behavior pack. See Tutorials/Creating behavior packs for a guide on creating behavior packs.

Behavior Pack[edit]

Entities[edit]

Defines the behavior of the custom entity. Located at Behavior Pack/entities/

You want to create a behavior similar to vanilla entities, but for custom entity, not changing vanilla one.

First, make sure to define the identifier for your custom entity (prefix can be anything), then if you want your entity to have a spawn egg in creative inventory, set "is_spawnable" to true. Set "is_summonable" to false to make it not summonable using /summon commands. For more information about entity component add-ons see: Bedrock Edition entity components documentation

Loot tables[edit]

Loot tables are used if you want your entity to have equipment or drop loot upon death, or to drop items upon interaction. Example of how drowned have loot table for drops and natural equipment:

//Drops
"minecraft:loot": {
  "table": "loot_tables/entities/drowned.json"
}

//Natural equipment
"minecraft:equipment": {
  "table": "loot_tables/entities/drowned_ranged_equipment.json",
    "slot_drop_chance": [
      {
        "slot": "slot.weapon.offhand",
          "drop_chance": 1.0
        }
      ]
    } 

The components of loot table.json in Bedrock Edition add-ons are similar to loot table.json in Java Edition with some slight differences.

Trading[edit]

This one is optional. Trading is used if your custom entity can be traded with. Here's an example of adding the ability for trading with a custom entity:

"minecraft:trade_table": {
  "display_name": "entity.custom:the_trader.name",
  "table": "trading/the_trader_trades.json",
  "new_screen": false
},

"minecraft:behavior.trade_with_player": {
  "priority": 1
},
      "minecraft:behavior.look_at_trading_player": {
  "priority": 2
}

Trade tables are stored as json files and you can create one similar to vanilla trades prior village & pillage which use the old trading system or after village & pillage which uses a economic trade(like wandering trader trades).

Spawn Rules[edit]

Spawn rules are used to make your custom entity spawn naturally in specific biomes. This isn't needed if your entity is spawned using commands only, or spawned from other entities only, such as being ridden or summoned by other mobs.

description
  • identifier:

Identifier of the entity(must match from entities)

  • population_control:

There are 3 pools that entities can be assigned to :
-animal
-lava_animal
-water

Components
Name Description
minecraft:spawns_on_surface This component allows the mob to spawn on the ground.
minecraft:spawns_underground This component allows the mob to spawn underground.
minecraft:spawns_underwater This component allows the mob to spawn underwater.
minecraft:spawns_on_block_filter Blocks this entity can spawn on.
minecraft:world_age_filter min: minimum time of world for entity to start spawning.
minecraft:brightness_filter This component allows players to set the light level range that causes the mob to spawn.
Parameters
Type Name Default Value Description
Decimal min 0.100 This is the minimum light level value that allows the mob to spawn
Decimal max 0.0 This is the maximum light level value that allows the mob to spawn
Boolean adjust_for_weather false This determines if weather can affect the light level conditions that cause the mob to spawn (e.g. Allowing hostile mobs to spawn during the day when it rains.)
minecraft:distance_filter Distance between the player and the custom entity are allowed to spawn.
Parameters
Type Name Default Value Description
Decimal min minimum distance
Decimal max maximum distance
minecraft:density_limit Density of mobs spawning.
Parameters
Type Name Default Value Description
Int surface surface density
Int underground underground density
minecraft:weight This component allows players to give a priority to how often that mob should spawn.
Parameters
Type Name Default Value Description
Decimal default 0.0 This is the priority of the mob spawning
minecraft:difficulty_filter This component allows players determine what mobs spawn when certain difficulty levels are set.
Parameters
Type Name Default Value Description
String min This is the minimum difficulty level that a mob spawns
String max This is the maximum difficulty level that a mob spawns
minecraft:herd This component allows players to determine the herd size of entities.
Parameters
Type Name Default Value Description
Decimal min_size This is the minimum number of mobs that spawn in a herd
Decimal max_size This is the maximum number of mobs that spawn in a herd
String event This is an event that can be triggered from spawning
Decimal event_skip_count This is the number of mobs spawned before the specified event is triggered
minecraft:permute_type Allows the current entity to spawn as another entity.
minecraft:biome_filter This component allows the players to specify which biomes the mob spawns in.

Resource Pack[edit]

Entity[edit]

Defines everything the custom entity needs in the resource pack, such as an identifier(must match with behavior pack, including prefix), materials, models, textures, animations, animation controllers, render controllers, and the spawn_egg color(Optional). Usually named entity_name.entity.json but entity_name.json may also work. Example:

{
  "format_version": "1.8.0",
  "minecraft:client_entity": {
    "description": {
      "identifier": "custom:the_trader",
      "min_engine_version": "1.8.0",
      "materials": {
        "default": "entity_alphatest"
      },
      "textures": {
        "default": "textures/entity/steve"
      },
      "geometry": {
        "default": "geometry.zombie.v1.8"
      },
      "spawn_egg": {
        "texture": "spawn_egg",
        "texture_index": 1
      },
      "scripts": {
        "pre_animation": [
          "variable.tcos0 = (Math.cos(query.modified_distance_moved * 38.17) * query.modified_move_speed / variable.gliding_speed_value) * 57.3;"
        ]
      },
      "animations": {water
        "humanoid_big_head": "animation.humanoid.big_head",
        "look_at_target_default": "animation.humanoid.look_at_target.default",
        "look_at_target_gliding": "animation.humanoid.look_at_target.gliding",
        "look_at_target_swimming": "animation.humanoid.look_at_target.swimming",
        "move": "animation.humanoid.move",
        "riding.arms": "animation.humanoid.riding.arms",
        "riding.legs": "animation.humanoid.riding.legs",
        "holding": "animation.humanoid.holding",
        "brandish_spear": "animation.humanoid.brandish_spear",
        "charging": "animation.humanoid.charging",
        "attack.rotations": "animation.humanoid.attack.rotations",
        "sneaking": "animation.humanoid.sneaking",
        "bob": "animation.humanoid.bob",
        "damage_nearby_mobs": "animation.humanoid.damage_nearby_mobs",
        "bow_and_arrow": "animation.humanoid.bow_and_arrow",
        "swimming": "animation.humanoid.swimming",
        "use_item_progress": "animation.humanoid.use_item_progress",
        "zombie_attack_bare_hand": "animation.zombie.attack_bare_hand",
        "zombie_swimming": "animation.zombie.swimming"
      },
      "animation_controllers": [
        { "humanoid_baby_big_head": "controller.animation.humanoid.baby_big_head" },
        { "look_at_target": "controller.animation.humanoid.look_at_target" },
        { "move": "controller.animation.humanoid.move" },
        { "riding": "controller.animation.humanoid.riding" },
        { "holding": "controller.animation.humanoid.holding" },
        { "brandish_spear": "controller.animation.humanoid.brandish_spear" },
        { "charging": "controller.animation.humanoid.charging" },
        { "attack": "controller.animation.humanoid.attack" },
        { "sneaking": "controller.animation.humanoid.sneaking" },
        { "bob": "controller.animation.humanoid.bob" },
        { "damage_nearby_mobs": "controller.animation.humanoid.damage_nearby_mobs" },
        { "bow_and_arrow": "controller.animation.humanoid.bow_and_arrow" },
        { "swimming": "controller.animation.humanoid.swimming" },
        { "use_item_progress": "controller.animation.humanoid.use_item_progress" },
        { "zombie_attack_bare_hand": "controller.animation.zombie.attack_bare_hand" },
        { "zombie_swimming": "controller.animation.zombie.swimming" }
      ],
      "render_controllers": [ "controller.render.skeleton" ],
      "enable_attachables": true
    }
  }
}
 

If spawn egg not defined, egg will use blank black textures.

Animation Controllers[edit]

Defines specific animations to be used at a certain state, such as blaze flame particles when charging to shoot fireballs.

Animation[edit]

Animations used for the custom entity. The custom entity can also use vanilla animations instead of custom one. If there are no animation listed, the custom entity will move in a static pose.

Models[edit]

The geometry used for the custom entity. See also Tutorials/Changing Minecraft entity models

Texts[edit]

Usually used for the spawn egg and the custom entity name by modifying language.lang file located in Resource Pack/texts/apply_to_language_used_in_setting. If no name is given, it will default to a placeholder name. Example of texts usage in custom entities:

## Entity Name
entity.custom:the_trader.name=The Trader
## Spawn Egg Name
item.spawn_egg.entity.custom:the_trader.name=This is §1The §eTrader§r Spawn Egg

Textures[edit]

Textures used for custom entity, usually at Resource Pack/textures/entities/. If no texture is given, entities will have magenta-black checkerboard texture instead.

Render Controllers[edit]

Define how the custom entity is rendered, such as using multiple textures or models, visible model parts, and different skins per variants. Your custom entity can also use vanilla render controllers instead of creating a new one. If a render controller is not defined, custom entity will float into the air. 27.61.201.164how do I use vanilla render controller?

Sounds[edit]

Custom sound can be used for custom entities, but can also use vanilla one with modified pitch. Entity sound can be added in sounds.json located in Resource Pack/sounds.json. If no sounds are given, the custom entity will use player hurt sounds.

[[Category:Tutorials]