Wiki 9Minecraft Wiki 9Minecraft

Making Custom Entities Sleep

Give your custom mobs day-night schedules, bed-seeking AI, or ground-napping behaviors.

4Sections
3Code examples
3Known errors

Sleeping adds life to passive and neutral mobs by tying their behavior and animations to the world's time of day or nearby environment. In Minecraft Bedrock, you can build two distinct styles of sleeping: villager-style bed claiming using the native sleep goal, or fox-style ground napping using environment sensors, schedules, and custom entity properties.

Two Approaches to Mob Sleep

Before writing JSON, decide whether your mob needs an actual bed block. Vanilla villagers and tamed cats use dedicated AI goals that search for a bed, pathfind to it, and lock the entity into a lying state on top of the block. This approach is quick to set up with built-in goals, though it requires beds to be present in the world.

Wild animals like foxes or ambient creatures rarely look for beds. Instead, they curl up directly on the ground when night falls or when they find shade. Because Bedrock does not have a single one-size-fits-all ground-sleep component, you build this behavior yourself by swapping component groups when the time of day changes, stripping away movement goals, and triggering a sleeping animation in the resource pack.

Bed-Seeking Sleep (Villager Style)

To make an entity sleep in a standard bed, your entity must first know how to claim a bed as a point of interest. You pair a dweller component with the `minecraft:behavior.sleep` AI goal. The dweller setup lets the mob join a village roster and claim a bed, while the behavior goal handles walking to the pillow and laying down.

You also want to control when the mob wants to sleep. While you can add the sleep goal directly to the base components, pairing it with `minecraft:scheduler` lets you activate a sleeping component group specifically during nighttime hours, or when the mob is not panicking.

FieldWhat it doesNotes
goal_radiusDistance in blocks within which the mob considers itself at the bed.Keep between 1.0 and 2.0 so the mob does not get stuck on bed corners.
sleep_collider_heightResizes the entity collision box height while asleep.Prevents the mob from suffocating in low ceilings above the bed.
sleep_collider_widthResizes the entity collision box width while asleep.Usually set smaller than the standing width.
sleep_y_offsetVertical offset applied to the entity's position while on the bed.Adjusts how high the model rests on top of the mattress.
timeout_cooldownTime in seconds to wait before trying again if the bed cannot be reached.Helps reduce lag when a player walls off a bed.
BP/entities/custom_villager.json
{
  "format_version": "1.20.80",
  "minecraft:entity": {
    "description": {
      "identifier": "wiki:custom_villager",
      "is_spawnable": true,
      "is_summonable": true
    },
    "component_groups": {
      "wiki:sleep_schedule": {
        "minecraft:behavior.sleep": {
          "priority": 3,
          "goal_radius": 1.5,
          "speed_multiplier": 1.0,
          "sleep_collider_height": 0.3,
          "sleep_collider_width": 0.3,
          "sleep_y_offset": 0.6,
          "timeout_cooldown": 8.0
        }
      },
      "wiki:work_schedule": {
        "minecraft:behavior.random_stroll": {
          "priority": 6,
          "speed_multiplier": 0.8
        }
      }
    },
    "components": {
      "minecraft:type_family": {
        "family": [ "villager", "mob" ]
      },
      "minecraft:collision_box": {
        "width": 0.6,
        "height": 1.9
      },
      "minecraft:movement": {
        "value": 0.35
      },
      "minecraft:navigation.walk": {
        "can_path_over_water": true,
        "can_pass_doors": true,
        "can_open_doors": true
      },
      "minecraft:movement.basic": {},
      "minecraft:annotation.open_door": {},
      "minecraft:dweller": {
        "dwelling_type": "village",
        "dweller_role": "inhabitant",
        "preferred_profession": "none",
        "update_interval_base": 60,
        "update_interval_variant": 40,
        "can_find_poi": true,
        "can_migrate": true,
        "first_founding_reward": 5
      },
      "minecraft:scheduler": {
        "min_delay_secs": 0,
        "max_delay_secs": 10,
        "scheduled_events": [
          {
            "filters": {
              "all_of": [
                { "test": "hourly_clock_time", "operator": ">=", "value": 12000 },
                { "test": "hourly_clock_time", "operator": "<", "value": 24000 }
              ]
            },
            "event": "wiki:start_sleeping"
          },
          {
            "filters": {
              "all_of": [
                { "test": "hourly_clock_time", "operator": ">=", "value": 0 },
                { "test": "hourly_clock_time", "operator": "<", "value": 12000 }
              ]
            },
            "event": "wiki:wake_up"
          }
        ]
      }
    },
    "events": {
      "wiki:start_sleeping": {
        "add": { "component_groups": [ "wiki:sleep_schedule" ] },
        "remove": { "component_groups": [ "wiki:work_schedule" ] }
      },
      "wiki:wake_up": {
        "add": { "component_groups": [ "wiki:work_schedule" ] },
        "remove": { "component_groups": [ "wiki:sleep_schedule" ] }
      }
    }
  }
}

Ground Napping with Entity Properties

When you want a mob to curl up anywhere on the ground without needing a bed block, avoid `minecraft:behavior.sleep`. Instead, declare a boolean entity property in your description block and toggle it using events. While the mob is in its sleeping component group, remove its wandering and look-around AI goals so it stays completely still.

You also need a reliable way to wake the mob up if a threat approaches or if a player hits it. A `minecraft:damage_sensor` listening for any damage and an `minecraft:environment_sensor` checking for nearby players or daytime hours will ensure the mob does not stay frozen while being attacked.

BP/entities/forest_critter.json
{
  "format_version": "1.20.80",
  "minecraft:entity": {
    "description": {
      "identifier": "wiki:forest_critter",
      "is_spawnable": true,
      "is_summonable": true,
      "properties": {
        "wiki:is_sleeping": {
          "type": "bool",
          "default": false,
          "client_sync": true
        }
      }
    },
    "component_groups": {
      "wiki:awake": {
        "minecraft:behavior.random_stroll": {
          "priority": 5,
          "speed_multiplier": 1.0
        },
        "minecraft:behavior.look_at_player": {
          "priority": 6,
          "look_distance": 6.0
        },
        "minecraft:environment_sensor": {
          "triggers": [
            {
              "filters": {
                "all_of": [
                  { "test": "is_daytime", "value": false },
                  { "test": "is_moving", "value": false }
                ]
              },
              "event": "wiki:go_to_sleep"
            }
          ]
        }
      },
      "wiki:asleep": {
        "minecraft:collision_box": {
          "width": 0.5,
          "height": 0.3
        },
        "minecraft:environment_sensor": {
          "triggers": [
            {
              "filters": {
                "any_of": [
                  { "test": "is_daytime", "value": true },
                  { "test": "in_water", "value": true }
                ]
              },
              "event": "wiki:wake_up"
            }
          ]
        }
      }
    },
    "components": {
      "minecraft:health": { "value": 10, "max": 10 },
      "minecraft:movement": { "value": 0.25 },
      "minecraft:navigation.walk": { "avoid_water": true },
      "minecraft:movement.basic": {},
      "minecraft:jump.static": {},
      "minecraft:damage_sensor": {
        "triggers": [
          {
            "on_damage": {
              "filters": {
                "test": "bool_property",
                "domain": "wiki:is_sleeping",
                "value": true
              },
              "event": "wiki:wake_up"
            }
          }
        ]
      }
    },
    "events": {
      "minecraft:entity_spawned": {
        "add": { "component_groups": [ "wiki:awake" ] }
      },
      "wiki:go_to_sleep": {
        "remove": { "component_groups": [ "wiki:awake" ] },
        "add": { "component_groups": [ "wiki:asleep" ] },
        "set_property": {
          "wiki:is_sleeping": true
        }
      },
      "wiki:wake_up": {
        "remove": { "component_groups": [ "wiki:asleep" ] },
        "add": { "component_groups": [ "wiki:awake" ] },
        "set_property": {
          "wiki:is_sleeping": false
        }
      }
    }
  }
}

Driving Sleep Animations on the Client

Once your behavior pack sets up sleep states, the resource pack needs to play the corresponding posture. For a mob using `minecraft:behavior.sleep` on a bed, the built-in Molang query `query.is_sleeping` automatically returns `1.0` while the entity is laying on the bed.

For ground-napping mobs using custom entity properties, `query.is_sleeping` will remain `0.0` because the internal sleep goal is not running. Instead, check your synced property using `query.property('wiki:is_sleeping')` inside your animation controller. You can combine both queries with a logical OR operator so the animation controller works with either behavior method.

RP/animation_controllers/forest_critter.animation_controllers.json
{
  "format_version": "1.10.0",
  "animation_controllers": {
    "controller.animation.forest_critter.sleep": {
      "initial_state": "awake",
      "states": {
        "awake": {
          "animations": [ "idle" ],
          "transitions": [
            {
              "sleeping": "query.is_sleeping || query.property('wiki:is_sleeping')"
            }
          ]
        },
        "sleeping": {
          "animations": [ "sleep_pose" ],
          "transitions": [
            {
              "awake": "!query.is_sleeping && !query.property('wiki:is_sleeping')"
            }
          ]
        }
      }
    }
  }
}

Which versions this applies to

Applies to Bedrock Edition 1.20.80 and newer. Entity properties (`properties` inside `description` and `query.property`) are fully stable and require no experimental toggles.

When it does not work

What you seeWhyThe fix
Mob has `minecraft:behavior.sleep` active at night, but just stands next to the bed and never gets in.The entity lacks `minecraft:dweller` with `"dwelling_type": "village"` and `"can_find_poi": true`, so it has no way to claim the bed as a valid target.Add the `minecraft:dweller` component to the entity's base components so it can register the bed point of interest.
Content Log shows `[Animation][error]-query.property: property 'wiki:is_sleeping' not found on entity` and the sleeping animation never plays.The entity property was defined in the behavior pack without `"client_sync": true`, so the resource pack cannot read its state.Add `"client_sync": true` to the property definition inside your behavior pack entity's `description.properties` block.
Ground-napping mob curls into its sleep animation, but continues sliding around the terrain.Movement AI goals like `minecraft:behavior.random_stroll` or `minecraft:behavior.tempt` are located in the permanent `components` block instead of the `wiki:awake` component group.Move all pathfinding and look-at AI behaviors into your awake component group so they are cleanly stripped when the sleep event fires.

Reference, straight from the game files

Read out of the game itself, so the ids match the version you are building for.