Tutorials/Creating custom entity add-ons

From Minecraft Wiki
Jump to: navigation, search


Iron Pickaxe.png
This page is a work in progress.
Please help in the creation of this article by expanding or improving this page.
Cleanup.svg
This article may need cleanup to improve its quality, possibly to comply with the style guide. Discuss
Please help us clean up this page if you can.
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. Another tutorial will be created for it, so stay tuned.

Behavior Pack[edit]

Entities[edit]

Here A.I task of custom entities be used. Located at Behavior Pack/entities/

Create behavior similar to vanila entites, but for custom entity, not changing vanila one. First make sure to defined identifier for your custom entity (prefix can be anything), then if you want your entity has 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 table used If you want your entity to have equipment or drop loot upon death, or 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
        }
      ]
    } 

Component of loot table.json in Bedrock Edition add-ons similar to loot table.json in Java Edition with some difference.

Trading[edit]

This one is optional. Trading used if your custom entity can be traded with. Example of adding ability for trading with 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 table are stored as json files, you can create one similar to vanila trades prior village & pillage which use old trading system or after village & pillage which use economic trade(like wandering trader trades).

Spawn Rules[edit]

Spawn rules used to make your custom entity spawn naturally through specific biomes. This doesn't needed if your entity spawn using commands only, or spawned only from other entites 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
-water_animal
-monster

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 Block this entity can only 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.0 This is the minimum light level value that allows the mob to spawn
Decimal max 15.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 player and mobs 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 Allow current entity to spawn as other entity
minecraft:biome_filter This component allows the players to specify which biomes the mob spawns in.


Resource Pack[edit]

Entity[edit]

Define everything custom entity needed in resource pack such as identifier(must match with behavior pack, including prefix),materials, models, textures, animations, animation controllers, render controllers, spawn_egg color. 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": {
        "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]

Define specific animation to be used at certain state, such as blaze flame particle when charging to shoot fireballs.

Animation[edit]

Animation used for entity. Custom entity can also use vanila animation instead of custom one. If there no animation used, entity will look like move in static pose.

Models[edit]

Models is geometry used for entity. See also Tutorials/Changing Minecraft entity models

Texts[edit]

Usually used for spawn egg and entity names by modifying language.lang file located in Resource Pack/texts/apply_to_language_used_in_setting. if leave blank then entity will use 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 textures given, entities will have magenta-black checkerboard texture all over models.

Render Controllers[edit]

Define how custom entites rendered, such as using multiple textures or models, visible model part, different skins per variants. Your custom entity can also use vanila render controller instead of creating new one. If render controller not defined, custom entity will be invisible.

Sounds[edit]

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