Skip to content

Instantly share code, notes, and snippets.

@yonta
Last active March 31, 2024 17:35
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save yonta/ce7c7e17a78777655cc5d61f60092216 to your computer and use it in GitHub Desktop.
Save yonta/ce7c7e17a78777655cc5d61f60092216 to your computer and use it in GitHub Desktop.
Spawn Rules of Minecraft in Bedrock Edition

Spawn cycle

Bedrock Edition

Natural spawning in Bedrock Edition shares only a few similarities to natural spawning in Java Edition. In Bedrock Edition, there are two main types of natural spawns: pack spawns and structure mob spawns. Structure mob spawns are mobs spawned as part of a structure, such as nether fortresses, witch huts, etc. Pack spawns account for all other types of natural spawns, including mobs that spawn individually (i.e. not in a pack of 2 or more). Both types of natural spawns follow the same rules for spawn conditions and the mob cap.

Mob spawning is evaluated for every chunk within a 6 chunk cylindrical radius of the player that is ticked; if the simulation distance is smaller than 6 chunks, then only chunks within the simulation distance will be able to spawn mobs. There is a 1 in 200 chance of the mob spawning algorithm attempting to run per chunk, per-tick.

Mob Cap

There are two main mob caps that affect spawning: a global mob cap and a mob density cap. The global mob cap for natural spawns is set at 200 regardless of difficulty. The global mob cap only affects natural mob spawning, and does not affect mobs spawned through breeding, spawn eggs, the /summon command, monster spawners or any other type of mob spawning. Only mobs that are within ticking areas (both those around players and those set manually using the /tickingarea command) count towards the global mob cap; mobs not ticked do not count towards the global mob cap. Mobs can also have their own individual cap listed below:

  • Individual Mob Caps

Mob Surface Cap Cave Cap Ghast 0 2 Creeper 5 Unlimited Other Unlimited Unlimited

Alongside the global mob cap is a mob density cap. The mob density cap limits how many mobs of each type and category can spawn within a 9x9 square region surrounding each chunk eligible for spawning. Mobs in chunks outside a ticking area count towards the mob density count. The density cap is split up into two distinct categories: a cap for surface mobs, and a cap for cave mobs. Cave mobs do not count towards the surface mob cap, and surface mobs do not count towards the cave mob cap.

There are four categories of mobs: ambient, animal, monster, and water. The mob density cap for each category and location of mob in each dimension is as follow:

  • Mob Density Caps

Category Location Overworld Nether The End Ambient Surface 0 0 0 Cave 2 0 0 Animal Surface 4 0 0 Cave 0 0 0 Monster Surface 8 0 10 Cave 8 16 8 Water Surface 4 0 0 Cave 0 0 0

Spawn Conditions

The following rules apply to all mobs:

  1. Can only spawn 24 blocks spherical radius or further from the player.
  2. Cannot spawn if the block below them is air.
  3. Cannot spawn if that mob would collide with an existing mob.
  4. Cannot spawn on slabs or carpet.
  5. Some additional rules apply to specific categories of mobs.
  • For water mobs:
    1. Cannot spawn outside of liquid.
  • For monsters:
    1. Cannot spawn if the light level is greater than 7.
  • For non-water mobs:
    1. Cannot spawn on bedrock or invisible bedrock.
    2. Cannot spawn touching any liquid.

Pack Spawning

Pack spawning happens in two stages: first attempt to spawn surface mobs, then attempt to spawn cave mobs. Before spawning, the mob density cap is calculated based on the 9x9 square area surrounding the current chunk. Spawning begins by picking a random X and Z location within the chunk currently being evaluated. The Y coordinate is determined by starting at the world height and searching downwards for the next solid block with a non-solid block above it. The first such block that is found is considered to be the surface, and the algorithm will attempt to spawn a surface mob pack. The algorithm then continues to search downwards for the next solid block with a non-solid block above it. When a block meeting the criteria is found, the algorithm attempts to spawn a cave mob pack at that block location. Cave spawn attempts continue until the Y coordinate reaches the world bottom, and do not stop even if a cave pack was spawned.

Surface and cave pack spawn attempts then go through the following steps to figure out what mob to spawn and how many:

  1. Picks a random mob.
    • If the current spawn location is in a liquid, pick a random water mob.
    • If the light level is greater than 7, there is no other blocks above the current location, and the current location is a grass block, pick a random animal mob.
    • Otherwise, spawn a monster mob.
  2. Picks a random number of mobs to spawn in the pack. Each mob can have its own min and max pack size, and the pack size can depend on difficulty.
  3. Make sure the spawn location has suitable spawn conditions.
  4. Limit the number of mobs spawning based on the global mob cap. If the mob count is already at or exceeds the mob cap, no mobs will spawn.
  5. For each mob to spawn, check that spawning it would not exceed the mob density cap.
    • If would spawning the mob would not exceed the mob density cap, then the probability the mob will spawn is can be calculated using the formula: (mob density cap - current mob density count) / mob density cap
  6. Finally, attempt to spawn the mob in the world
    • Spawning the mob can fail; for example, if spawning it would cause it to spawn inside of a block or part of a wall.

Other types of spawning

  • Cows, chickens, pigs, sheep, mooshrooms, villagers, ocelots, wolves, horses, donkeys, and rabbits can breed. All of these require a player to breed them except for villagers.
  • A thrown egg has a 1 in 8 chance of spawning a chicken, and an additional 1 in 32 chance of spawning 4 chickens from a single egg, so there is a total of 1 in 256 chance for a single thrown egg to spawn 4 chickens.
  • A snow golem, iron golem, or wither can be made to spawn if a player builds the proper structure out of blocks. Iron golems can also spawn in sufficiently populous villages. See their respective pages for full details.
  • A monster egg will spawn a silverfish if broken, or if a nearby silverfish is attacked. Zombies can spawn in large groups in villages at midnight ignoring most of the usual restrictions, forming a siege. It could even happen in mushroom biomes or if /gamerule doMobSpawning is false. The game will make 10 attempts to spawn a zombie within a 17x7x17 area centered on a block within the village's cylindrical radius, at the same Y level as the village center.
  • Zombie pigmen can spawn from nether portals in the Overworld. Lighting and player proximity don't prevent this.
  • Endermites can spawn randomly when a player uses an ender pearl.
  • Killing medium and large slimes and magma cubes will spawn more of them, but in a smaller size.
  • When a pig gets struck by lightning, it is replaced by a newly spawned zombie pigman.
  • When a villager gets struck by lightning, it is replaced by a newly spawned witch.
  • If a creeper gets struck by lightning, it becomes charged.
  • A monster spawner causes mobs to spawn constantly in the area around it. Spawners may naturally generate spawning zombies, skeletons, spiders, cave spiders, silverfish, or blazes, but may be made to spawn other mobs using commands or spawn eggs. Mobs have the same spawning conditions they would have from a natural spawn, except hostile mobs may spawn without a block below them.
  • In Creative, the player can use spawn eggs to spawn most mobs. When mobs are spawned this way, all normal spawning requirements, such as light level and block type, are ignored.
  • Any entity can be spawned using the /summon command.

Despawning

Bedrock Edition

Entity despawning in Bedrock Edition is evaluated per-chunk, per-tick. There is a 1 in 50 chance for each chunk to attempt to despawn an entity per-tick. When despawning, a random entity in the chunk is chosen, and only despawned under the following conditions:

  • The entity is more than 54 blocks circular radius away from a player.
  • The light level is lower than 8.
    • For monsters, light level must be greater than 8, and if it is a surface mob, it must be day time.
  • The entity is too old.
  • The entity does not have persistence.

Persistence

In Bedrock Edition, entities with persistence do not despawn naturally. Persistence is applied to entities in the following situations:

  • Interacted with by a player.
  • Was ridden by the player.
  • Named with a name tag.
  • Tempted with food.
  • Breed or born as a result of breeding.
  • Was tamed.
  • Tried to attack a player.
  • Was attacked by the player.
  • Touched the player.
  • Spawned via a monster spawner.
  • Spawned via a spawn egg.
  • A mob spawned using the /summon command.
  • Zombie Villager which was cured.
  • Skeleton or Skeleton Horse which spawned as part of a skeleton trap.
  • Shulker which spawned as part of an End City.
  • Witch which spawned as part of a Witch Hut.
  • Villager or Zombie Villager spawned as part of an Igloo.
  • Zombie Villager which spawned as part of a Zombie Village.
  • Vindicator which spawned as part of a Woodland Mansion.

The following entities always have persistence:

  • Ender Dragon
  • Wither Boss
  • Elder Guardian
  • Guardian
  • Iron Golem
  • Snow Golem
  • Villager
  • Armor Stand

オリジナル

スポーンサイクル

Bedrock版

Bedrock版での 自然スポーン、Java版での自然スポーンと似ています。 Bedrock版には、2種類の自然スポーンがあります。 パックスポーンとストラクチャモンスタースポーンです。 ストラクチャモンスタースポーンとは、ネザー要塞、ウィッチの家などの建築物の一部としてモンスターを生成することです。 [todo]パックスポーンは、個々に生成されるモンスターを含む(2パック以上ではない?)、他のすべてのタイプの自然スポーンを行います。 この2つの自然スポーンは、スポーン条件とモンスター上限という同じルールに従います。

モンスターのスポーンは、プレーヤを中心とした半径6チャンクの円柱内の各チャンクで評価されます。 シミュレーション距離が6チャンクよりも小さい場合、シミュレーション距離内のチャンクだけでモンスター生成が行われます。 1ティック毎に各チャンクでモンスター生成アルゴリズムが行われる確率は1/200です。

モンスターキャップ

スポーンに影響するモンスターの上限(モンスターキャップ)は2種類あります。 グローバルキャップと密度キャップです。 自然スポーンによる世界のモンスターキャップは、難易度によらず200に設定されています。 世界のモンスターキャップ、自然スポーンにのみ影響し、繁殖・スポーンエッグ・/summonコマンド・スポナーなどのスポーンには影響しません。 ティックエリア(プレイヤーの周りのエリアと、/tickingareaコマンドで設定されたエリアの両方)内のモンスターだけが、グローバルキャップにカウントされます。 ティックされないモンスターは、グローバルキャップにカウントされません。 一部のモンスターにはさらに以下のような独自の上限もあります。

  • 個々のモンスター上限
モンスター 表層の上限 洞窟の上限
ガスト 0 2
クリーパー 5 無制限
その他 無制限 無制限

グローバルキャップの次は密度キャップです。 [todo]モンスターの密度キャップは、各チャンクを取り囲む9x9の四角の領域内で(?)、モンスターがスポーンできる数をモンスターのタイプとカテゴリで制限します。 ティックエリア外のチャンクにいるモンスターも密度キャップにカウントにされます。 密度キャップは表層と洞窟の2つのカテゴリに分かれています。 洞窟のモンスターは表層の上限にカウントされず、表層のモンスターは洞窟の上限にカウントされません。

モンスターには、アンビエント、動物、モンスター、水の4つのカテゴリがあります。 各カテゴリの密度キャップは以下のとおりです。

  • 密度キャップ
カテゴリー ロケーション オーバーワールド ネザー エンド
アンビエント 表層 0 0 0
洞窟 2 0 0
動物 表層 4 0 0
洞窟 0 0 0
モンスター 表層 8 0 10
洞窟 8 16 8
表層 4 0 0
洞窟 0 0 0

スポーン条件

以下のルールがすべてのモンスターに適用されます。

  1. プレイヤーを中心とした半径24ブロックの球状の外側のみスポーンできます。
  2. 足元のブロックが空気であればスポーンできません。
  3. 既にいるモンスター衝突する場合は、スポーンできません。
  4. ハーフブロックやカーペットにはスポーンできません。
  5. いくつかの追加ルールが以下のように適用されます。
  • 水中モンスターの場合
    1. 水の外にスポーンできません。
  • モンスターの場合:
    1. 明るさ7より大きいとスポーンできません。
  • 水モンスター以外の場合
    1. 岩盤や見えない岩盤にスポーンできません。
    2. 水に触れる位置にスポーンできません。

パックスポーン

パックスポーンは2ステップで起こります。 最初に、表層のモンスターを生成してから、洞窟のモンスターを生成しようとします。 スポーンする前に、現在のチャンクを囲む9×9の四角の領域で、密度キャップが計算されます。 スポーンは、評価中のチャンク内のランダムなX座標とZ座標を選択することから始まります。 Y座標は、世界の高さから下方向に探索していき、固体ブロックの下にある非固体ブロックを見つけた位置になります。 この探索で見つけた最初のブロックが表層であるとみなされ、アルゴリズムは表層のモンスターを生成しようとします。 その後、固体ブロックの下にある非固体ブロックをさらに下方向に探索し続けます。 またブロックが見つかると、このブロックに洞窟のモンスターを生成しようとします。

表層と洞窟のモンスターの生成では、以下のステップを経て、どのモンスターがどのくらいスポーンするかが決まります。

  1. ランダムにモンスターを1つ選ぶ。
    • 現在のスポーン場所が水中の場合、ランダムに水中モンスターを選びます。
    • 明るさレベルが7より大きく、現在のスポーン場所の上に他のブロックがなく、かつ、現在のスポーン場所が草ブロックである場合、ランダムな動物を選びます。
    • それ以外の場合は、モンスターをスポーンさせます。
  2. パック内に出現させるモンスターの数をランダムに選ぶ。 各モンスターはそれぞれの最小および最大パックサイズを持っており、このパックサイズは難易度によって異なります。
  3. スポーン場所が前述のスポーン条件を満たすことを確認する。
  4. グローバルキャップでスポーンするモンスター数を制限する。 モンスター数がすでに上限に達している場合、モンスターはスポーンしません。
  5. 各モンスターのスポーンで、各モンスターの密度キャップを超えないことを確認する。
    • もしモンスターのスポーンが密度キャップを超えないならば、モンスターがスポーンする確率は次の公式で表されます。
(密度キャップ - 現在の該当モンスター数) / 密度キャップ
  1. 最後に、世界にモンスターをスポーンさせようとする。
    • スポーンは失敗する可能性があります。例えば、スポーンさせるとモンスターがブロックや壁に埋まる場合です。

デスポーン

Bedrock版

Bedrock版でのエンティティのデスポーンは、チャンク毎、ティック毎に行われます。 1ティック毎に、各チャンクで1エンティティをデスポーンする確率は、1/50です。 デスポーン時に、チャンク内のエンティティがランダムに選ばれ、次の条件を満たすときのみにデスポーンされます。

  • エンティティが、プレーヤーから半径54ブロックの円よりも外側にいる。
  • 明るさレベルが8より小さい。
    • モンスターの場合、光のレベルは8より大きい必要があり、表層のモンスターの場合は昼である必要があります。
  • エンティティが十分に古い。
  • エンティティに永続性がない。

永続性

Bedrock版では、永続性を持つエンティティは、自然にはデスポーンしません。 次のことが起こると、エンティティが永続性を持ちます。

  • プレーヤーとやりとりする。
  • プレーヤーが乗る。
  • タグで名前をつける。
  • 食べ物を与える。
  • 繁殖する、または、繁殖で生みだす。
  • 飼いならす。
  • プレーヤーを攻撃しようとする。
  • プレーヤーによって攻撃される。
  • プレーヤーに触れた。
  • モンスタースポーナーでスポーンした。
  • スポーンエッグでスポーンした。
  • /summonコマンドでスポーンした。
  • 治癒されたゾンビ村人。
  • スケルトントラップによってスポーンしたスケルトン、または、スケルトンホース。
  • エンドシティの一部としてスポーンしたシュルカー。
  • ウィッチハットの一部としてスポーンした魔女。
  • イグルーの一部としてスポーンした村人とゾンビ村人。
  • ゾンビ村の一部としてスポーンしたゾンビ村人。
  • 森の洋館の一部としてスポーンしたヴィンディケーター。

次のエンティティは常に永続性を持ちます。

  • エンダードラゴン
  • ウィザー
  • エルダーガーディアン
  • ガーディアン
  • アイアンゴーレム
  • スノーゴーレム
  • 村人
  • 鎧スタンド
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment