Minecraft:Mob AI: Difference between revisions
More actions
Sync: updated from Minecraft |
Sync: updated from Minecraft |
||
| (12 intermediate revisions by the same user not shown) | |||
| Line 2: | Line 2: | ||
{{WIP}} | {{WIP}} | ||
This article describes the various components of a mob's AI that control | This article describes the various components of a mob's AI that control its behavior. | ||
== Brain == | == Brain == | ||
| Line 8: | Line 8: | ||
=== Sensor === | === Sensor === | ||
Sensors are used to detect if a mob with a brain can perform certain tasks. Examples of sensors include | Sensors are used to detect if a mob with a brain can perform certain tasks. Examples of sensors include a sensor to detect if an armadillo should be scared, a sensor to detect the nearest player, and a sensor to detect if a mob is in water. | ||
By default, sensors run, by default, once every {{Convert|20|game ticks|second}}, although individual sensor classes can have a different scan rate. When a sensor runs, it updates its targeting conditions to match the mob's current {{attr|follow_range}} attribute before performing its [[#Targeting condition|targeting condition]]. The first execution of each sensor is delayed by a random number of ticks, preventing multiple sensors from running simultaneously; the random number is an integer between 0 (inclusive) and the scam rate (exclusive). | |||
{|class= "wikitable collapsible" | {|class= "wikitable collapsible" | ||
|+List of | |+List of Sensors {{in|JE}} | ||
! Sensor | ! Sensor | ||
!Class | !Class | ||
| Line 18: | Line 20: | ||
|dummy | |dummy | ||
|DummySensor | |DummySensor | ||
|'' | |''default sensor type'' | ||
|- | |- | ||
|nearest_items | |nearest_items | ||
| Line 30: | Line 32: | ||
}} | }} | ||
|- | |- | ||
| | |mobs | ||
|NearestLivingEntitySensor | |NearestLivingEntitySensor | ||
|{{Flatlist| | |{{Flatlist| | ||
| Line 144: | Line 146: | ||
|- | |- | ||
|nearest_adult_any_type | |nearest_adult_any_type | ||
| | |AdultSensorAnyType | ||
|{{EntityLink|Happy Ghast}} | |{{EntityLink|Happy Ghast}} | ||
|- | |- | ||
| Line 193: | Line 195: | ||
|} | |} | ||
====Sensor parameters==== | |||
Some sensor classes have parameters, namely '''MobSensor''' and '''TemptingSensor'''. The list of parameters is below: | |||
{|class= "wikitable collapsible collapsed" | |||
|+ MobSensor parameters | |||
! Sensor | |||
! scanRate | |||
! mobTest | |||
! readyTest | |||
! toSet | |||
! memoryTimeToLive | |||
|- | |||
|armadillo_scare_detected | |||
|5 | |||
| Armadillo.isScaredBy({{mono|livingEntity}}): | |||
* If the {{mono|livingEntity}}'s hitbox does not intersect the armadillo's hitbox at 2 on the Y-axis and 7 on the X-Z axes, it returns false. | |||
* If the {{mono|livingEntity}} is in the tag {{tag link|entity type|unded}}, it returns true. | |||
* If the {{mono|livingEntity}} was the last entity to damage the armadillo, it returns true. | |||
* If the {{mono|livingEntity}} is a player who is not in [[Minecraft:Spectator]] mode, is running, or in a vehicle, it returns true. | |||
* Otherwise, it returns false. | |||
| Armadillo.canStayRolledUp(): | |||
Return true only if none of the following occurs to the armadillo: | |||
* Is panicking (have the memory {{cd|is_panicking}}) | |||
* Is in liquid (fluid in the tag {{tag link|fluid|water}} or {{tag link|fluid|lava}}) | |||
* Is [[Minecraft:leashed]] | |||
* Is in a vehicle | |||
* Is vehicle | |||
| {{cd|danger_detected_recently}} | |||
| 80 | |||
|- | |||
|} | |||
{|class= "wikitable collapsible collapsed" | |||
|+ TemptingSensor parameters | |||
{|class= "wikitable collapsible" | ! Sensor | ||
! | ! temptations | ||
|- | |- | ||
| | |food_temptations | ||
| | | For each mob and item stack, test if the item is food for the mob. For mobs with these sensors, it means the item is tagged: | ||
| | * {{EntityLink|Armadillo}} — Tag {{Tag link|item|armadillo_food}} | ||
* {{EntityLink|Axolotl}} — Tag {{Tag link|item|axolotl_food}} | |||
* {{EntityLink|Camel}} — Tag {{Tag link|item|camel_food}} | |||
* {{EntityLink|Goat}} — Tag {{Tag link|item|goat_food}} | |||
* {{EntityLink|Happy Ghast}} — Tag {{Tag link|item|happy_ghast_food}} | |||
* {{EntityLink|Sniffer}} — Tag {{Tag link|item|sniffer_food}} | |||
|- | |- | ||
| | |frog_temptations | ||
| | | | ||
Check if the item is [[Minecraft:frog]] food (it's on the tag {{Tag link|item|frog_food}}), regardless of the mob. | |||
|- | |- | ||
| | |nautilus_temptations | ||
|{{ | | | ||
Check if the item is [[Minecraft:nautilus]] food (it's on the tag {{Tag link|item|nautilus_food}}), regardless of the mob. | |||
|} | |||
Technically, all sensor classes have the scanRate parameter, which defines how many ticks the sensor runs. However, most vanilla sensors use the class's default scanRate value (20 by default, but this can change in certain classes; see [[#Sensor classes|below]]). The only sensor that sets its scanRate is {{cd|armadillo_scare_detected}}. | |||
==== Targeting condition ==== | |||
Many sensors need to filter entities based on certain tests. The test conditions can change depending on the sensor's objective. | |||
Each targeting condition has the tags {{nbt|bool|isCombat}}, {{nbt|bool|checkLineOfSight}}, {{nbt|bool|testInvisible}}, {{nbt|double|range}} and '''selector''' which are used to perform the test. The '''selector''' consists of a predicate that depends on the target, but it can be null. | |||
For sensor targeting conditions, except '''TemptingSensor''', the {{nbt|double|range}} is initially defined as {{cd|16.0}}, but it is updated to the value of the attribute {{attr|follow_range}} before the sensor's doTick, '''selector''' is null, {{nbt|bool|isCombat}} is true when testing an attack target, {{nbt|bool|testInvisible}} is false when the target is in the targeter's {{cd|attack_target}} memory, and {{nbt|bool|checkLineOfSight}} is true. | |||
The test value is a boolean value that depends on the target and the targeter (and can be null), both [[Minecraft:living entity]] such that: | |||
* | * If target and targeter are the same entity, it returns false. | ||
* | * If the target is not alive or is a player in [[Minecraft:Spectator]] mode, returns false. | ||
* | * If the '''selector''' is not null, and the target is valid in the '''selector''' test, return false. | ||
* Multiplying by {{cd|0.8}} if | * If the targeter is null, {{nbt|bool|isCombat}} is true, and target is invulnerable, or the difficulty is [[Minecraft:peaceful]], it returns false. The following points assume that targeter is not null. | ||
* Multiplying by {{cd|0.07}} if | * If {{nbt|bool|isCombat}} is true, the targeter can not attack the target or the targeter is allied to the target, return true. See below for more details. | ||
* Multiplying by {{cd|0.175p}} if | * If {{nbt|double|range}} > 0 and the [[Minecraft:euclidean distance]] from targeter to target is greater than {{cd|max('''range''' × ''modifier, 2.0'')}}, it returns false. | ||
* Multiplying by {{cd|0.5}} if | ** If {{nbt|bool|testInvisible}} is false, the modifier is 1.0; else the modifier starts with {{cd|1.0}} (double) and is cumulative: | ||
*** Multiplying by {{cd|0.8}} if target is a [[Minecraft:sneaking]] player, | |||
*** Multiplying by {{cd|0.07}} if target is [[Minecraft:invisible]] and without equipament in {{tooltip|humanoid armor slot|head, chest, legs or feet slot}}, | |||
*** Multiplying by {{cd|0.175p}} if target is invisible and has {{cd|p≥1}} equipaments in humanoid armor slot, | |||
*** Multiplying by {{cd|0.5}} if target is using the corresponding mob [[Minecraft:head]] in the {{cd|head}} slot (for [[Minecraft:skeleton]], [[Minecraft:zombie]], [[Minecraft:piglin]], [[Minecraft:piglin brute]], and [[Minecraft:creeper]]) | |||
| | **** This depends on the component {{DCL|mob_visibility}}, more specifically, for each target's equipment slot ''s'' there is an item with the component {{DCL|equippable.slot}} equal to ''s'', and the targeter is contained in {{cd|mob_visibility.targeting_entity_types}}, the modifier is multiplied by {{cd|mob_visibility.visibility}}.{{Upcoming|Java 26.3}} | ||
*** The modifier is limited by {{cd|10.0}}.{{Upcoming|Java 26.3}} | |||
* If {{nbt|bool|checkLineOfSight}} is true, the targeter is a mob, and it is not possible to draw a straight line from the targeter's eye to the target without intersecting a block [[Minecraft:collision box]], return false. | |||
* Otherwise, it returns true. | |||
{{A|can attack}} | |||
The table below shows when the conditions of a living entity (the targeter) can not attack another (the target). At least one condition must be satisfied for it not to attack. | |||
{|class= "wikitable collapsible" | |||
|+ Can not attack | |||
! Targeter | |||
! Can not attack if... | |||
|- | |- | ||
| | | {{EnvLink|id=Mob|Living entity}} (except ender dragon and warden) | ||
| | |||
* The target is a player and the difficulty is peaceful. | |||
* The target is invulnerable. | |||
* | * The target is not alive. | ||
* | |||
* | |||
|- | |- | ||
| | | {{EnvLink|id=Mob|Mobs}} (except ender dragon and warden) | ||
| | |||
* The target is a [[Minecraft:ghast]]. | |||
|- | |- | ||
| | | | ||
{{EntityLink|id=wolf|link=Taming|Tamable Animal}} | |||
| | | | ||
* The target owns the {{Tooltip|animal|targeter}}. | |||
|- | |- | ||
| | | {{EntityLink|Dolphin}} | ||
| | | | ||
* The {{Tooltip|dolphin|targeter}} is baby. | |||
|- | |||
| | |||
{{EntityLink|Iron Golem}} | |||
| | | | ||
* The {{Tooltip|iron golem|targeter}} was created by a player ({{nbt|bool|PlayerCreated}} is true) and the target is a player. | |||
* The target is a [[Minecraft:creeper]]. | |||
|- | |- | ||
| | | | ||
{{EntityLink|Ender Dragon}} | |||
| | | | ||
* The target is invulnerable. | |||
* The target is not alive. | |||
|- | |- | ||
| | | | ||
{{EntityLink|Breeze}} | |||
| | |||
* The target is '''not''' a player or iron golem. | |||
|- | |- | ||
| | | | ||
{{EntityLink|Illager}} | |||
| | | | ||
* The target is a [[Minecraft:baby villager]]. | |||
|- | |- | ||
| | | {{EntityLink|Warden}} | ||
| | |||
| | | | ||
* The {{Tooltip|warden|targeter}} can not target the target: {{a|warden can target}} | |||
{{Collapse|content= | |||
<!--:* The target is a living entity | |||
:* The target is not in the same level--> | |||
:* The target is a player in spectator or creative mode. | |||
:* The {{Tooltip|warden|targeter}} is allied to the target. | |||
:* The target is a [[Minecraft:armor stand]]. | |||
:* The target is a warden. | |||
:* The target is dead or dying. | |||
:* The target is not within the [[Minecraft:world border]]. | |||
}} | |||
|} | |||
An entity A is an ally of an entity B if A = B, if A considers B as an ally, or if B considers A as an ally. The table below shows when one entity considers another as an ally: | |||
{|class= "wikitable collapsible collapsed" | |||
|+ Is allied | |||
! Targeter | |||
! Considers as ally if... | |||
|- | |- | ||
| | | | ||
{{EnvLink|Entity}} | |||
| | | | ||
The targeter and the target have a [[Minecraft:team]], and it is the same team. | |||
|- | |- | ||
| | | | ||
{{EntityLink|id=wolf|link=Taming|Tamable Animal}} | |||
| | | | ||
The {{Tooltip|animal|targeter}} is tame, and the owner is the target or considers the target as an ally. | |||
|- | |- | ||
| | | | ||
{{EntityLink|Allay}} | |||
| | | | ||
The target is the {{Tooltip|allay|targeter}} linked player (has the [[Minecraft:UUID]] in memory {{cd|liked_player}}). | |||
|- | |- | ||
| | | | ||
{{EntityLink|Illager}} | |||
| | | | ||
The target entity type is in the tag {{Tag link|entity_type|illager_friends}} and the target and the targeter don't have a team. | |||
|- | |- | ||
| | |{{EntityLink|Evoker}} | ||
| | | | ||
The target is a [[Minecraft:vex]] and the target root owner{{fn|group=ally|The root owner of an entity, if it exists, is the first non-ownable entity in a chain of owners of owners ... of owners of the entity. For example, if the entity owner is not an ownable entity, it would be the root owner.}} is the {{Tooltip|evoker|targeter}} or considers the {{Tooltip|evoker|targeter}} as ally. | |||
|} | |||
{{Reflist|group=ally}} | |||
====Sensor classes==== | |||
Sensors classes are responsible for detecting a specific type of information and storing the results in one or more memory modules in a mob's brain. In the game's code, these classes are part of the package {{cd|net.minecraft.world.entity.ai.sensing}} | |||
{| class="wikitable collapsible" | |||
!Class!! Memory requires!!Do tick | |||
|- | |||
|DummySensor | |||
|''None'' | |||
|''Performs no actions'' | |||
|- | |||
|AdultSensor | |||
|rowspan="2" |{{cd|nearest_visible_adult}} and {{cd|visible_mobs}} | |||
|Searches the {{cd|visible_mobs}} memory for the nearest visible [[Minecraft:living entity]] of the same [[Minecraft:entity type]] as the mob that is not a [[Minecraft:baby]]. Stores the result in the {{cd|nearest_visible_adult}} memory. | |||
If no matching adult is found, {{cd|nearest_visible_adult}} is set to empty. | |||
|- | |||
|AdultSensorAnyType | |||
| | | | ||
{{Hatnote|Extends '''AdultSensor'''}} | |||
When setting the nearest visible adult, it tests whether the entity is in the tag {{tag link|entity type|followable_friendly_mobs}}, rather than whether it's in the same entity type as the mob. | |||
|- | |||
|AxolotlAttackablesSensor | |||
|{{cd|nearest_attackabled|visible_mobs|d=and|has_hunting_cooldown}} | |||
|{{Hatnote|Extends '''{{Slink||NearestVisibleLivingEntitySensor}}'''}} | |||
Searches the {{cd|visible_mobs}} memory for the closest [[Minecraft:living entity]] that: | |||
* is within 8 blocks ([[Minecraft:euclidean distance]]), | |||
* is in water ({{Tag link|fluid|water}} fluid tag), | |||
* is in {{Tag link|entity type|axolotl_always_hostiles}} or is in {{Tag link|entity type|axolotl_hunt_targets}} and the [[Minecraft:axolot]] is hungry (has memory {{cd|has_hunting_cooldown}}), | |||
* is attackable.{{fn|name=attackable|group=sensor|Targeting condition with {{nbt|bool|isCombat}} and {{nbt|bool|checkLineOfSight}} {{cd|true}}, and {{nbt|bool|testInvisible}} {{cd|flase}} {{Tooltip|iff|if and only if}} the entity is not in memory {{cd|attack_target}}.}} | |||
Stores the closest matching entity in the {{cd|nearest_attackable}} memory. | |||
|- | |||
|BreezeAttackEntitySensor | |||
|{{cd|mobs}}, {{cd|visible_mobs|d=and|nearest_attackable}} | |||
|{{Hatnote|Extends '''{{Slink||NearestLivingEntitySensor}}'''}} | |||
Updates the {{cd|mobs}} and {{cd|visible_mobs}} memories (by the super method). It then searches the {{cd|mobs}} memory for the attackable entity{{fn|name=attackable|group=sensor}} that is not a player in [[Minecraft:Creative]] mode or [[Minecraft:Spectator]] mode. | |||
Stores the first matching entity in the {{cd|nearest_attackable}} memory. If no matching entity is found, it removes the {{cd|nearest_attackable}} memory. | |||
|- | |- | ||
|FrogAttackablesSensor | |FrogAttackablesSensor | ||
| | |{{cd|nearest_attackable}}, {{cd|visible_mobs|d=and|unreachable_tongue_targets}} | ||
| | |{{Hatnote|Extends '''{{Slink||NearestVisibleLivingEntitySensor}}'''}} | ||
Searches the {{cd|visible_mobs}} memory for entity that: | |||
* is within 10 blocks ([[Minecraft:euclidean distance]]), | |||
* can be eaten by a [[Minecraft:frog]] (is in {{Tag link|entity type|frog_food}} and is not a [[Minecraft:slime]], [[Minecraft:magma cube]], or [[Minecraft:sulfur cube]] with size different that 1), | |||
* is attackable,{{fn|name=attackable|group=sensor}} | |||
* is not listed in the {{cd|unreachable_tongue_targets}} memory. | |||
Stores the closest matching entity in the {{cd|nearest_attackable}} memory. | |||
|- | |||
|GolemSensor | |||
|{{cd|mobs}} and {{cd|golem_detected_recently}} | |||
|Searches the {{cd|mobs}} memory for an [[Minecraft:iron golem]]. If one is found, it sets the {{cd|golem_detected_recently}} memory to <code>true</code> with an expiration time of {{convert|599|gt|s}}. | |||
'''scanRate''': This sensor runs every {{convert|200|gt|s}} by default. It only checks whether at least one iron golem is present. | |||
|- | |||
|HoglinSpecificSensor | |||
|{{cd|visible_mobs}}, {{cd|nearest_repellent}}, {{cd|nearest_visible_adult_piglin}}, {{cd|nearest_visible_adult_hoglins}}, {{cd|visible_adult_piglin_count|d=and|visible_adult_hoglin_count}} | |||
|Searches the {{cd|visible_mobs}} memory for visible adult [[Minecraft:piglin]]s and [[Minecraft:hoglin]]s. | |||
Stores the nearest visible adult [[Minecraft:piglin]] in the {{cd|nearest_visible_adult_piglin}} memory and stores visible adult [[Minecraft:hoglin]]s in the {{cd|nearest_visible_adult_hoglins}} memory. It also stores the number of visible adult piglins and hoglins in the {{cd|visible_adult_piglin_count}} and {{cd|visible_adult_hoglin_count}} memories. | |||
Searches for the nearest hoglin repellent block within 8 blocks horizontally and 4 blocks vertically, and stores its position in the {{cd|nearest_repellent}} memory. | |||
|- | |||
|HurtBySensor | |||
|{{cd|hurt_by}} and {{cd|hurt_by_entity}} | |||
|Checks the mob's last <code>damageSource</code>. | |||
* If the mob has a last damage source, stores it in the {{cd|hurt_by}} memory. | |||
* If the damage source was caused by a [[Minecraft:living entity]], stores that entity in the {{cd|hurt_by_entity}} memory. | |||
* If the mob has no last damage source, removes the {{cd|hurt_by}} memory. | |||
* If the entity stored in {{cd|hurt_by_entity}} is no longer alive or is no longer in the same [[Minecraft:world]], removes the {{cd|hurt_by_entity}} memory. | |||
|- | |- | ||
|IsInWaterSensor | |IsInWaterSensor | ||
|{{cd|is_in_water}} | |{{cd|is_in_water}} | ||
| | |Checks whether the mob is in [[Minecraft:water]]. If it is, it sets the {{cd|is_in_water}} memory. Otherwise, it removes the {{cd|is_in_water}} memory. | ||
|- | |- | ||
| | |MobSensor | ||
|{{cd|mobs}} | |||
| | | | ||
{{hatnote|This sensor uses [[#Sensor parameters|parameters]].}} | |||
If the sensor's readiness condition ('''readyTest''') is met, it searches the {{cd|mobs}} memory for a [[Minecraft:living entity]] matching the sensor's predicate ('''mobTest'''). If a matching entity is found, it sets the sensor's memory ('''memoryTimeToLive''') to <code>true</code> with an expiration time determined by the sensor ('''toSet'''). | |||
If the readiness condition ('''readyTest''') is not met, it removes the sensor's memory ('''memoryTimeToLive'''). | |||
|- | |||
|NearestBedSensor | |||
|{{cd|nearest_bed}} | |||
|If the mob is a [[Minecraft:baby]]: | |||
* Searches for [[Minecraft:Point of Interest|POIs]] of type <code>home</code> ([[Minecraft:bed]]) within 48 blocks of the mob. The sensor uses a cache to avoid repeatedly checking the same POIs and attempts to add up to 5 new beds to the cache during each scan. | |||
* The sensor attempts to create a [[Minecraft:Mob AI#Pathfinding|path]] to the found beds. If a path is found and can reach its target, and the target is a valid POI, it stores the target's position in the mob's {{cd|nearest_bed}} memory. | |||
* If no reachable bed is found and fewer than 5 POIs were checked, it removes expired entries from the cache.{{fn|group=sensor|name=bedcache| A POI is considered expired depending on whether the current {{cd|lastUpdate}} exceeds the {{cd|lastUpdate}} from when the POI was added to the cache by more than 40. The {{cd|lastUpdate}} is an auxiliary variable defined as {{tooltip|Gametime|the total number of game ticks that have elapsed in the world}} + {{Tooltip|random.nextInt(20)|0 ≤ int < 20}}, at the beginning of the doTick.}} | |||
|- | |||
|NearestItemSensor | |||
|{{cd|nearest_visible_wanted_item}} | |||
|Find the {{Tooltip|nearest|with a bounding box}} item that: | |||
* Is within a bounding box extending 32 blocks horizontally and 16 blocks vertically from the mob. | |||
* Is within 32 blocks of the mob. | |||
* The mob wants to pick up.{{fn|group=sensor|name=dm|It depends on the mob, defined independently of the sensor.}} | |||
* Is in the mob's line of sight.{{fn|group=sensor|name=los|It is possible to draw a straight line from the mob's eye to the target without intersecting a block [[Minecraft:collision box]].}} | |||
The nearest matching item is stored in the {{cd|nearest_visible_wanted_item}} memory. If no matching item is found, the memory is set to empty. | |||
|- | |||
|NearestLivingEntitySensor | |||
|{{cd|mobs}} and {{cd|visible_mobs}} | |||
|{{A|NearestLivingEntitySensor}} | |||
Lists all other [[Minecraft:living entities]] that are alive and within a [[Minecraft:w:Cuboid|cuboid]] generated by the mob's [[Minecraft:Hitbox#Entity hitboxes|hitbox]] expanded by its {{attr|follow_range}} in all directions. Sorts the entities by [[Minecraft:Euclidean distance]] from the mob and stores the list in the {{cd|mobs}} memory. | |||
In {{cd|visible_mobs}}, stores{{fn|group=sensor|Technically, in memory {{cd|visible_mobs}}, a list equal to that of {{cd|mob}} is saved, along with a binary list of the same size indicating whether the entity passes the test.}} the entities from {{cd|mobs}} filtering entities using the mob's targeting conditions{{fn|name=targeting|group=sensor}} | |||
|- | |||
|NearestVisibleLivingEntitySensor | |||
|{{cd|visible_mobs}} and a memory defined by the subclass | |||
|{{A|NearestVisibleLivingEntitySensor}} Searches the {{cd|visible_mobs}} memory for the closest [[Minecraft:living entity]] that matches the conditions defined by the subclass. | |||
The matching entity is stored in the memory defined by the subclass. If no matching entity is found, the memory is set to empty. | |||
|- | |||
|PiglinBruteSpecificSensor | |||
|{{cd|visible_mobs|nearest_visible_nemesis|nearby_adult_piglins|d=and}} | |||
|Searches the {{cd|visible_mobs}} memory for the nearest [[Minecraft:wither skeleton]] or [[Minecraft:wither]] and stores it in the {{cd|nearest_visible_nemesis}} memory. | |||
Stores nearby adult [[Minecraft:piglin]]s in the {{cd|nearby_adult_piglins}} memory. | |||
|- | |||
|PiglinSpecificSensor | |||
|{{cd|visible_mobs|mobs|nearest_visible_nemesis|nearest_targetable_player_not_wearing_gold|nearest_player_holding_wanted_item|nearest_visible_huntable_hoglin|nearest_visible_baby_hoglin|nearest_visible_adult_piglins|nearby_adult_piglins|visible_adult_piglin_count|visible_adult_hoglin_count|nearest_repellent|d=and}} | |||
|Searches the {{cd|visible_mobs}} memory and updates memories related to [[Minecraft:piglin]] behavior: | |||
* {{EntitySprite|wither skeleton}} Stores the nearest [[Minecraft:wither skeleton]] or [[Minecraft:wither]] as {{cd|nearest_visible_nemesis}}. | |||
* {{EntitySprite|Hoglin}} Stores the nearest adult huntable{{fn|group=sensor|A hoglin is huntable if the [[Minecraft:Entity_format#Mob-specific_data|nbt tag]] {{nbt|bool|CannotBeHunted}} is false. By default it is false.}} [[Minecraft:hoglin]] as {{cd|nearest_visible_huntable_hoglin}} | |||
** {{EntitySprite|Baby Hoglin}} Stores the nearest [[Minecraft:baby]] hoglin as {{cd|nearest_visible_baby_hoglin}}. | |||
* {{EntitySprite|Player}} Stores the nearest player that is not wearing an item in the tag {{Tag link|item|piglin_safe_armor}} and [[#can attack|can be attacked]] in {{cd|nearest_targetable_player_not_wearing_gold}}. | |||
** {{ItemSprite|gold ingot}} Stores the nearest non-[[Minecraft:Spectator]] player holding a iten in the tag {{Tag link|item|piglin_loved}} in {{cd|nearest_player_holding_wanted_item}}. | |||
* {{EntitySprite|Zombified Piglin}} Stores the nearest [[Minecraft:zombified piglin]] or [[Minecraft:zoglin]] in {{cd|nearest_visible_zombified}}. | |||
* {{EntitySprite|Piglin}} Stores [[Minecraft:piglin brute]]s and adult [[Minecraft:piglin]]s in {{cd|nearest_visible_adult_piglins}} | |||
* {{nbt|int}} Stores the number of adult piglins and adult hoglins in {{cd|visible_adult_piglin_count}} and {{cd|visible_adult_hoglin_count}}, respectively. | |||
Searches the {{cd|mobs}} memory and stores adult [[Minecraft:piglin]]s and [[Minecraft:piglin brute]]s in {{cd|nearby_adult_piglins}}. | |||
Searches for the nearest{{fn|group=sensor|Used [[Minecraft:manhattan distance]]. If two blocks are equidistant, prioritize the one with the smaller X coordinate. If they are on the same X coordinate, prioritize the one with the smaller Y coordinate. If they are on the same Y coordinate, prioritize the one with the '''larger''' Z coordinate. In other words, it is the {{w|lexicographical order}} of {{cd|(d,X,Y,-Z)}}, with {{cd|d}} the manhattan distance.}} block in the tag {{Tag link|block|pigling repellents}} in a box with 17 × 9 × 17 blocks centered on the piglins' position, and stores its position in {{cd|nearest_repellent}}. Not [[Minecraft:Block_states#lit|lit]] [[Minecraft:soul campfire]]s are not considered repellents. | |||
|- | |||
|PlayerSensor | |||
|{{cd|nearest_players}}, {{cd|nearest_visible_player}}, {{cd|nearest_visible_attackable_player}} and {{cd|nearest_visible_attackable_players}} | |||
|List all non-[[Minecraft:Spectator]] players that are within a [[Minecraft:Euclidean distance]] of the mob's {{attr|follow_range}}. Sorts the players by distance from the mob and stores the list in {{cd|nearest_players}}. | |||
From this list, it creates {{cd|nearest_visible_player}} by filtering players using the mob's targeting conditions{{fn|name=targeting|group=sensor|Targeting condition with {{nbt|bool|isCombat}} {{cd|false}}, {{nbt|bool|checkLineOfSight}} {{cd|true}}, and {{nbt|bool|testInvisible}} {{cd|flase}} {{Tooltip|iff|if and only if}} the entity is not in memory {{cd|attack_target}}|Targeting condition with {{nbt|bool|isCombat}} and {{nbt|bool|checkLineOfSight}} {{cd|true}}, and {{nbt|bool|testInvisible}} {{cd|flase}} {{Tooltip|iff|if and only if}} the entity is not in memory {{cd|attack_target}}}}. If the resulting list is not empty, stores the first player in {{cd|nearest_visible_player}}. | |||
Creates {{cd|nearest_visible_attackable_players}} by filtering {{cd|nearest_visible_player}}'s list using the mob's attack targeting conditions{{fn|name=attackable|group=sensor}}. If the resulting list is not empty, the first player is stored in {{cd|nearest_visible_attackable_player}}. | |||
|- | |||
|SecondaryPoiSensor | |||
|{{cd|secondary_job_site}} | |||
|Scans all blocks within a {{Tooltip|9 × 5 × 9|4 blocks horizontally and 2 blocks vertically}} area centered on a villager. If a block matches one of the villager profession's secondary [[Minecraft:Point of Interest#List of points of interest|job site]] blocks, it stores its [[Minecraft:Coordinates|global position]] in the {{cd|secondary_job_site}} memory. It stores all matching blocks. | |||
If no matching blocks are found, it removes the {{cd|secondary_job_site}} memory. | |||
'''scanRate''': This sensor runs every {{Convert|40|gt|s}} instead of the default 20. | |||
|- | |||
|TemptingSensor | |||
|{{cd|tempting_player}} | |||
| | | | ||
{{hatnote|This sensor uses [[#Sensor parameters|parameters]].}} | |||
Searches for the [[Minecraft:player]] that: | |||
* Is not on [[Minecraft:Spectator]] mode, | |||
* Is in range {{attr|tempt_range}},{{fn|group=sensor|Targeting condition, with this {{nbt|double|range}}, {{nbt|bool|testInvisible}} {{cd|true}}, and {{nbt|bool|checkLineOfSight}} and {{nbt|bool|isCombat}} {{cd|false}}.}} | |||
* Holding a tempting item for the mob ('''temptations'''.test(mob, item)) in mainhand or offhand, | |||
* Is not [[Minecraft:passenger]] of the mob. | |||
If a matching player is found, it stores the nearest (by [[Minecraft:euclidean distance]]) player in the {{cd|tempting_player}} memory. Otherwise, it removes the {{cd|tempting_player}} memory. | |||
|- | |||
|VillagerBabiesSensor | |||
|{{cd|visible_villager_babies}} | |||
|Finds all [[Minecraft:Villager|villagers]] that are [[Minecraft:Baby|babies]] from the mob's {{cd|visible_mobs}} memory and stores them as a list in the {{cd|visible_villager_babies}} memory. | |||
If no visible baby villagers are found, stores an empty list. | |||
|- | |- | ||
| | |VillagerHostilesSensor | ||
| | |{{cd|nearest_hostile}} and {{cd|visible_mobs}} | ||
| | | | ||
{{Hatnote|Extends '''{{Slink||NearestVisibleLivingEntitySensor}}'''}} | |||
Searches the {{cd|visible_mobs}} memory for the nearest [[Minecraft:living entity]] matching one of the following hostile entity types and stores it in the {{cd|nearest_hostile}} memory: | |||
* {{EntityLink|Drowned}} — within 8 blocks | |||
* {{EntityLink|Evoker}} — within 12 blocks | |||
* {{EntityLink|Husk}} — within 8 blocks | |||
* {{EntityLink|Illusioner}} — within 12 blocks | |||
* {{EntityLink|Pillager}} — within 15 blocks | |||
* {{EntityLink|Ravager}} — within 12 blocks | |||
* {{EntityLink|Vex}} — within 8 blocks | |||
* {{EntityLink|Vindicator}} — within 10 blocks | |||
* {{EntityLink|Zoglin}} — within 10 blocks | |||
* {{EntityLink|Zombie}} — within 8 blocks | |||
* {{EntityLink|Zombie Villager}} — within 8 blocks | |||
If no matching hostile entity is found, {{cd|nearest_hostile}} is set to empty. | |||
|- | |||
|WardenEntitySensor | |||
|{{cd|mobs}}, {{cd|visible_mobs|d=and|nearest_attackable}} | |||
|{{Hatnote|Extends '''{{Slink||NearestLivingEntitySensor}}'''}} | |||
Updates the {{cd|mobs}} and {{cd|visible_mobs}} memories (by the super method). It then searches the {{cd|mobs}} memory for the {{Tooltip|closest|first in the memory}} targetable [[Minecraft:player]]. If none is found, it searches for the {{Tooltip|closest|first in the memory}} targetable non-player [[Minecraft:living entity]]. In both cases, only entities that the [[#warden can target|warden can target]] are considered. | |||
Stores the first matching entity in the {{cd|nearest_attackable}} memory. If no matching entity is found, it removes the {{cd|nearest_attackable}} memory. | |||
|} | |} | ||
{{ | {{Reflist|group=sensor}} | ||
=== Task === | === Task === | ||
Tasks are activities that mobs with brain AI systems can perform. Sensors are used to determine if a task can be performed, and tasks may use information stored in memories. Examples of tasks include a villager walking to its jobsite, a piglin admiring an item, or a warden emerging. Tasks have priorities, so tasks with a higher priority will | Tasks are activities that mobs with brain AI systems can perform. Sensors are used to determine if a task can be performed, and tasks may use information stored in memories. Examples of tasks include a villager walking to its jobsite, a piglin admiring an item, or a warden emerging. Tasks have priorities, so tasks with a higher priority will overrun tasks with lower priority; for example, if a zombie is wandering and it sees a player, it will switch tasks to attacking. | ||
=== Memory === | === Memory === | ||
Memories are used to store data | Memories are used to store data and are used when mobs perform tasks. Examples of memories include a list of all visible mobs in range, the location of a villager's jobsite block, and any cooldowns the mob may have. | ||
== Control == | == Control == | ||
| Line 325: | Line 589: | ||
{{main|#Pathfinding on land}} | {{main|#Pathfinding on land}} | ||
Mob movement on land varies depending on whether it's hostile or passive. Hostile mobs will try to approach and attack the player when within their detection range, while most passive mobs will attempt to run away when attacked. Some mobs will also try to [[Minecraft:Mob infighting|attack]] or [[Minecraft:Mob fleeing|run away]] from certain blocks or mobs. | |||
=== Swimming === | === Swimming === | ||
{{main|#Pathfinding in water}} | {{main|#Pathfinding in water}} | ||
Mob swimming works the same way as walking, but in water. While most mobs will just float on water or sink, some can properly swim like [[Minecraft:fish]], [[Minecraft:drowned]], [[Minecraft:dolphin]]s, [[Minecraft:turtle]]s, [[Minecraft:guardian]]s, and [[Minecraft:elder guardian]]s. | |||
=== Flying === | === Flying === | ||
{{main|#Pathfinding in air}} | {{main|#Pathfinding in air}} | ||
Mob flying works the same way as walking, but in the air. Most mobs will just fall when suspended in air, with a few exceptions. Mobs with [[Minecraft:Slow Falling]], [[Minecraft:levitation]], and the [[Minecraft:chicken]] don't fly normally but can float in mid-air. [[Minecraft::Category:Flying mobs]] contains a list of all mobs that can pathfind in air. | |||
== Goals == | == Goals == | ||
Goals are a simple AI system used primarily by mobs already existed before the brain AI. However, there are recent mobs that use both AIs simultaneously, for example, the [[Minecraft:happy ghast]]. | Goals are a simple AI system used primarily by mobs that already existed before the brain AI. However, there are recent mobs that use both AIs simultaneously, for example, the [[Minecraft:happy ghast]]. | ||
Goals can range from wandering around, opening doors, attacking another mob, and more. Each type of mob that uses goals has its own defined list of goals, and each goal has a priority. Mobs attempt to perform the lowest priority goal they can, and may switch goals if there is an opportunity to pursue a lower priority goal. For example, if a zombie is targeting and chasing a villager (priority of 3) and a player comes within the detection range of the zombie, the zombie may target and chase the player (priority of 2) instead. | Goals can range from wandering around, opening doors, attacking another mob, and more. Each type of mob that uses goals has its own defined list of goals, and each goal has a priority. Mobs attempt to perform the lowest priority goal they can, and may switch goals if there is an opportunity to pursue a lower priority goal. For example, if a zombie is targeting and chasing a villager (priority of 3) and a player comes within the detection range of the zombie, the zombie may target and chase the player (priority of 2) instead. | ||
| Line 351: | Line 615: | ||
|Active Target | |Active Target | ||
|Select an entity to target for chasing and attacking | |Select an entity to target for chasing and attacking | ||
| | |||
|- | |- | ||
|Ambient Stand | |Ambient Stand | ||
|Untamed horse bucks when player tries to ride it | |Untamed horse bucks when player tries to ride it | ||
| | |||
|- | |- | ||
|Attack | |Attack | ||
|Attack target | |Attack target | ||
| | |||
|- | |- | ||
|Attack with Owner | |Attack with Owner | ||
|Tamed animal attacks a target mob attacked by owner | |Tamed animal attacks a target mob attacked by owner | ||
| | |||
|- | |- | ||
|Avoid | |Avoid Entity | ||
| | |Mob runs away from another mob that it is afraid of (e.g. skeletons running from wolves) | ||
| | |||
|- | |- | ||
|Bow Attack | |Bow Attack | ||
|Attack target with bow | |Attack target with bow | ||
| | |||
|- | |- | ||
|Breathe Air | |Breathe Air | ||
|Mob that can drown tries to move out of water | |Mob that can drown tries to move out of water | ||
| | |||
|- | |||
|Cat Lie on Bed | |||
|Tamed cat lies down on bed | |||
| | |||
|- | |- | ||
|Cat Sit on Block | |Cat Sit on Block | ||
| Line 376: | Line 651: | ||
|Chase after boat ridden by player | |Chase after boat ridden by player | ||
|''Unused'' | |''Unused'' | ||
|- | |- | ||
|Crossbow Attack | |Crossbow Attack | ||
|Attack target with crossbow | |Attack target with crossbow | ||
| | |||
|- | |- | ||
|Destroy Egg | |Destroy Egg | ||
|Destroy turtle eggs | |Destroy turtle eggs | ||
| | |||
|- | |- | ||
|Disableable Follow Target | |Disableable Follow Target | ||
| Line 392: | Line 666: | ||
|Dive Jump | |Dive Jump | ||
|Mob jumps up and dives down | |Mob jumps up and dives down | ||
| | |||
|- | |- | ||
|Dolphin Jump | |Dolphin Jump | ||
|Dolphin jumps out of water | |Dolphin jumps out of water | ||
| | |||
|- | |- | ||
|Door Interact | |Door Interact | ||
|Mob tries to open a door | |Mob tries to open a door | ||
| | |||
|- | |- | ||
|Eat Grass | |Eat Grass | ||
|Mob grazes on grass | |Mob grazes on grass | ||
| | |||
|- | |- | ||
| | |Flee Sun | ||
| | |Move out of direct line-of-sight with sky during day | ||
| | |||
|- | |- | ||
| | |Float | ||
|Mob | |Mob floats in water | ||
| | | | ||
|- | |- | ||
|Follow | |Follow Flock Leader | ||
|Fish tries to follow the leader of a school of fish | |Fish tries to follow the leader of a school of fish | ||
| | |||
|- | |- | ||
|Follow Mob | |Follow Mob | ||
|Mob follows another mob | |Mob follows another mob | ||
| | |||
|- | |- | ||
|Follow Owner | |Follow Owner | ||
|Tamed mob follows owner | |Tamed mob follows owner | ||
| | |||
|- | |- | ||
|Follow Parent | |Follow Parent | ||
|Baby mob follows its parent | |Baby mob follows its parent | ||
| | | | ||
|- | |- | ||
|Go to Walk Target | |Go to Walk Target | ||
|Mob walks to a target | |Mob walks to a target | ||
| | |||
|- | |- | ||
|Hold in Hands | |Hold in Hands | ||
|Mob holds an item in its main hand | |Mob holds an item in its main hand | ||
| | |||
|- | |- | ||
|Horse Bond with Player | |Horse Bond with Player | ||
|Horse attempts to bond with player attempting to tame it | |Horse attempts to bond with player attempting to tame it | ||
| | |||
|- | |- | ||
|Iron Golem Look | |Iron Golem Look | ||
|Iron golem looks at a villager | |Iron golem looks at a villager | ||
| | |||
|- | |- | ||
|Iron Golem Wander Around | |Iron Golem Wander Around | ||
|Iron golem wanders around village | |Iron golem wanders around village | ||
|uses points of interest | |uses points of interest | ||
|- | |||
|Llama Follow Caravan | |||
| Llama follows other llamas to form a caravan | Llamas form and follow a caravan | |||
| | |||
|- | |||
|Leap At Target | |||
|Mob jumps towards target | |||
|cats, foxes, ocelots, spiders | |||
|- | |- | ||
|Long Door Interact | |Long Door Interact | ||
|Open a door, then close it after a delay | |Open a door, then close it after a delay | ||
| | |||
|- | |||
|Look At Entity | |||
|Mob looks at another mob | |||
| | |||
|- | |- | ||
|Look | |Look At Player | ||
|Mob | |Mob looks at player | ||
| | |||
|- | |- | ||
|Look At | |Look At Trading Player | ||
|Villager or wandering trader looks at player while trading | |Villager or wandering trader looks at player while trading | ||
| | | | ||
|- | |- | ||
|Melee Attack | |Melee Attack | ||
|Mob paths to target and attacks | |Mob paths to target and attacks | ||
| | |||
|- | |- | ||
|Move Into Water | |Move Into Water | ||
|Mob paths to water | |Mob paths to water | ||
| | |||
|- | |- | ||
|Move Through Village | |Move Through Village | ||
|Mob moves between points of interest in a village | |Mob moves between points of interest in a village | ||
| | |||
|- | |- | ||
|Move To Raid Center | |Move To Raid Center | ||
|Raiders move toward village after spawning | |Raiders move toward village after spawning | ||
| | |||
|- | |- | ||
|Move To Target Position | |Move To Target Position | ||
|Mob paths to a specific block | |Mob paths to a specific block | ||
| | |||
|- | |- | ||
| | |Panic | ||
|Mob | |Mob panics and runs away when damaged | ||
| | | | ||
|- | |- | ||
|Powder Snow Jump | |Powder Snow Jump | ||
| Line 482: | Line 778: | ||
|Prioritized Goal | |Prioritized Goal | ||
|Used to override the default priority of a goal | |Used to override the default priority of a goal | ||
| | |||
|- | |- | ||
|Projectile Attack | |Projectile Attack | ||
| Line 489: | Line 786: | ||
|Raid Goal | |Raid Goal | ||
|Raiders target villagers | |Raiders target villagers | ||
|- | |||
|Random Look Around | |||
|Mob looks around in random directions | |||
| | |||
|- | |||
|Random Stroll | |||
|Move to a nearby random position | |||
| | |||
|- | |- | ||
|Revenge | |Revenge | ||
|Target entity that attacked the mob | |Target entity that attacked the mob | ||
| | |||
|- | |||
|Run Around Like Crazy | |||
|Untamed horse runs around randomly when ridden by a player | |||
| | |||
|- | |||
|Spear Use | |||
|Mob attacks target with spear | |||
| | |||
|- | |||
|Swell | |||
|Creeper attempts to explode near its target | |||
| | |||
|- | |||
|Tempt | |||
|Mob follows player holding breeding item | |||
| | |||
|- | |- | ||
| | |Water Avoiding Random Stroll | ||
|Move to a nearby random position | |Move to a nearby random position, while actively avoiding water | ||
| | |||
|- | |- | ||
|Wander Around Far | |Wander Around Far | ||
|Move to a random position, sometimes farther away than Wander Around goal | |Move to a random position, sometimes farther away than Wander Around goal | ||
| | |||
|- | |- | ||
|Zombie Attack | |Zombie Attack | ||
|Attack goal for zombies and zombie variants | |Attack goal for zombies and zombie variants | ||
| | |||
|} | |} | ||
| Line 532: | Line 857: | ||
== Pathfinding == | == Pathfinding == | ||
Pathfinding is the system used by [[Minecraft:Mob|mobs]] to navigate through the world. Mobs that use pathfinding calculate routes through the environment and follow these routes using their navigation system. Different mobs use different types of navigation depending on their movement abilities, such as [[Minecraft:walking]], [[Minecraft:swimming]], or [[Minecraft:flying]]. | |||
The default navigation type for mobs is ground path navigation, although individual mobs can replace it with a different navigation implementation. | |||
Pathfinding is controlled by a mob's AI. Goals and behaviors can request movement to a location or entity, causing the mob's navigation system to calculate and follow a path. The navigation system is updated every [[Minecraft:tick]] while the mob's AI is active. | |||
A mob is considered to be pathfinding when its navigation system has an active path. The path ends when the mob reaches its destination, the path becomes invalid, or the navigation is stopped. | |||
=== Navigation === | |||
The navigation system controls how [[Minecraft:Mob|mobs]] follow paths after they have been calculated. | |||
A navigation system stores the mob's current path, [[Minecraft:Attribute#Movement Speed|movement speed]], and destination. During each AI update, the navigation system checks the current path, advances through nodes that have been reached, and sends movement instructions to the mob's movement controls. | |||
Navigation can be stopped manually, which clears the mob's current path. A mob is considered to be navigating when it has an active path that has not been completed. | |||
Different mobs use different navigation systems depending on their movement type. Ground mobs generally use ground navigation, while [[Minecraft:aquatic]] and [[Minecraft::Category:Flying mobs|flying mobs]] use specialized navigation systems. | |||
Navigation systems can also perform checks while moving, such as: | |||
* When a mob becomes stuck. | |||
* Recalculating paths when needed. | |||
* Whether a mob can move directly between two points. | |||
* Adjusting paths around certain blocks. | |||
=== Path following === | |||
After a path is created, mobs follow the path by moving from node to node. A node represents a position that the mob must reach while traveling. | |||
A mob advances to the next node when it is close enough to its current node. Some paths allow mobs to skip nodes when moving directly toward a later point would be safe. | |||
While following a path, mobs can become stuck if they fail to make sufficient progress. The navigation system checks movement over time and stops the path if the mob cannot continue. | |||
=== Pathfinding penalties === | === Pathfinding penalties === | ||
[[File:Zombified piglin pathing 1.png|thumb|[[Zombified piglin]] starts pathfinding to a [[Minecraft:turtle egg]]]] | [[File:Zombified piglin pathing 1.png|thumb|[[Zombified piglin]] starts pathfinding to a [[Minecraft:turtle egg]]]] | ||
| Line 706: | Line 1,062: | ||
|} | |} | ||
{{Expand section}} | |||
=== Pathfinding on land === | === Pathfinding on land === | ||
* All entities | * All entities move based on random targets that are generated every tick with a priority toward their entity-specific goals. | ||
* These targets can be located anywhere in 3D space within the entity range and are only | * These targets can be located anywhere in 3D space within the entity range and are only generated when wandering or when they have no goals. | ||
* For every target a path is generated; with the entity preferring the path with the lowest score regarding the Pathfinding penalties. | * For every target, a path is generated; with the entity preferring the path with the lowest score regarding the Pathfinding penalties. | ||
* If an entity cannot take any paths with a low enough score, or any paths without a score of -1 the entity will not move until one is found. | * If an entity cannot take any paths with a low enough score, or any paths without a score of -1, the entity will not move until one is found. | ||
* If an entity's target is located inside a block (including water), the target is moved to the nearest air block above it. | * If an entity's target is located inside a block (including water), the target is moved to the nearest air block above it. | ||
This means, | This means every entity, when wandering, will always prefer to pathfind to a block with the most blocks below it within range. | ||
Due to the higher chance that a target will be generated within the blocks below it and moved up to the nearest air block above before generating a path. | Due to the higher chance that a target will be generated within the blocks below it and moved up to the nearest air block above before generating a path. | ||
| Line 720: | Line 1,077: | ||
=== Pathfinding in water === | === Pathfinding in water === | ||
* Pathfinding in water is roughly the same as land | * Pathfinding in water is roughly the same as land; however, most entities, excluding fish and drowned, will bounce on the surface, preferring land due to the Pathfinding penalties of water. | ||
=== Pathfinding in air === | === Pathfinding in air === | ||
* Pathfinding in air is roughly the same as land | * Pathfinding in air is roughly the same as land; however, few entities can pathfind to air. | ||
== See also == | == See also == | ||
Latest revision as of 11:10, 26 July 2026
This article describes the various components of a mob's AI that control its behavior.
Brain
Some mobs use a complex AI system called a brain. A mob's brain stores memories (data), a list of tasks that can be performed, and a list of sensors used to determine which tasks it can perform.
Sensor
Sensors are used to detect if a mob with a brain can perform certain tasks. Examples of sensors include a sensor to detect if an armadillo should be scared, a sensor to detect the nearest player, and a sensor to detect if a mob is in water.
By default, sensors run, by default, once every Template:Convert, although individual sensor classes can have a different scan rate. When a sensor runs, it updates its targeting conditions to match the mob's current Template:Attr attribute before performing its targeting condition. The first execution of each sensor is delayed by a random number of ticks, preventing multiple sensors from running simultaneously; the random number is an integer between 0 (inclusive) and the scam rate (exclusive).
| Sensor | Class | Uses |
|---|---|---|
| dummy | DummySensor | default sensor type |
| nearest_items | NearestItemSensor | Template:Flatlist |
| mobs | NearestLivingEntitySensor | Template:Flatlist |
| nearest_players | PlayerSensor | Template:Flatlist |
| nearest_bed | NearestBedSensor | Template:EntityLink |
| hurt_by | HurtBySensor | Template:Flatlist |
| villager_hostiles | VillagerHostilesSensor | Template:EntityLink |
| villager_babies | VillagerBabiesSensor | Template:EntityLink |
| secondary_pois | SecondaryPoiSensor | Template:EntityLink |
| golem_detected | GolemSensor | Template:EntityLink |
| armadillo_scare_detected | MobSensor | Template:EntityLink |
| piglin_specific_sensor | PiglinSpecificSensor | Template:EntityLink |
| piglin_brute_specific_sensor | PiglinBruteSpecificSensorregister | Template:EntityLink |
| hoglin_specific_sensor | HoglinSpecificSensor | Template:EntityLink |
| nearest_adult | AdultSensor | Template:Flatlist |
| nearest_adult_any_type | AdultSensorAnyType | Template:EntityLink |
| axolotl_attackables | AxolotlAttackablesSensor | Template:EntityLink |
| food_temptations | TemptingSensor | Template:Flatlist |
| frog_temptations | TemptingSensor | Template:Flatlist |
| nautilus_temptations | TemptingSensor | Template:Flatlist |
| frog_attackables | FrogAttackablesSensor | Template:EntityLink |
| is_in_water | IsInWaterSensor | Template:EntityLink |
| warden_entity_sensor | WardenEntitySensor | Template:EntityLink |
| breeze_attack_entity_sensor | BreezeAttackEntitySensor | Template:EntityLink |
Sensor parameters
Some sensor classes have parameters, namely MobSensor and TemptingSensor. The list of parameters is below:
| Sensor | scanRate | mobTest | readyTest | toSet | memoryTimeToLive |
|---|---|---|---|---|---|
| armadillo_scare_detected | 5 | Armadillo.isScaredBy(Template:Mono):
|
Armadillo.canStayRolledUp():
Return true only if none of the following occurs to the armadillo:
|
Template:Cd | 80 |
| Sensor | temptations |
|---|---|
| food_temptations | For each mob and item stack, test if the item is food for the mob. For mobs with these sensors, it means the item is tagged: |
| frog_temptations |
Check if the item is Minecraft:frog food (it's on the tag Template:Tag link), regardless of the mob. |
| nautilus_temptations |
Check if the item is Minecraft:nautilus food (it's on the tag Template:Tag link), regardless of the mob. |
Technically, all sensor classes have the scanRate parameter, which defines how many ticks the sensor runs. However, most vanilla sensors use the class's default scanRate value (20 by default, but this can change in certain classes; see below). The only sensor that sets its scanRate is Template:Cd.
Targeting condition
Many sensors need to filter entities based on certain tests. The test conditions can change depending on the sensor's objective.
Each targeting condition has the tags Template:Nbt, Template:Nbt, Template:Nbt, Template:Nbt and selector which are used to perform the test. The selector consists of a predicate that depends on the target, but it can be null.
For sensor targeting conditions, except TemptingSensor, the Template:Nbt is initially defined as Template:Cd, but it is updated to the value of the attribute Template:Attr before the sensor's doTick, selector is null, Template:Nbt is true when testing an attack target, Template:Nbt is false when the target is in the targeter's Template:Cd memory, and Template:Nbt is true.
The test value is a boolean value that depends on the target and the targeter (and can be null), both Minecraft:living entity such that:
- If target and targeter are the same entity, it returns false.
- If the target is not alive or is a player in Minecraft:Spectator mode, returns false.
- If the selector is not null, and the target is valid in the selector test, return false.
- If the targeter is null, Template:Nbt is true, and target is invulnerable, or the difficulty is Minecraft:peaceful, it returns false. The following points assume that targeter is not null.
- If Template:Nbt is true, the targeter can not attack the target or the targeter is allied to the target, return true. See below for more details.
- If Template:Nbt > 0 and the Minecraft:euclidean distance from targeter to target is greater than Template:Cd, it returns false.
- If Template:Nbt is false, the modifier is 1.0; else the modifier starts with Template:Cd (double) and is cumulative:
- Multiplying by Template:Cd if target is a Minecraft:sneaking player,
- Multiplying by Template:Cd if target is Minecraft:invisible and without equipament in Template:Tooltip,
- Multiplying by Template:Cd if target is invisible and has Template:Cd equipaments in humanoid armor slot,
- Multiplying by Template:Cd if target is using the corresponding mob Minecraft:head in the Template:Cd slot (for Minecraft:skeleton, Minecraft:zombie, Minecraft:piglin, Minecraft:piglin brute, and Minecraft:creeper)
- This depends on the component Template:DCL, more specifically, for each target's equipment slot s there is an item with the component Template:DCL equal to s, and the targeter is contained in Template:Cd, the modifier is multiplied by Template:Cd.Template:Upcoming
- The modifier is limited by Template:Cd.Template:Upcoming
- If Template:Nbt is false, the modifier is 1.0; else the modifier starts with Template:Cd (double) and is cumulative:
- If Template:Nbt is true, the targeter is a mob, and it is not possible to draw a straight line from the targeter's eye to the target without intersecting a block Minecraft:collision box, return false.
- Otherwise, it returns true.
Template:A The table below shows when the conditions of a living entity (the targeter) can not attack another (the target). At least one condition must be satisfied for it not to attack.
| Targeter | Can not attack if... |
|---|---|
| Template:EnvLink (except ender dragon and warden) |
|
| Template:EnvLink (except ender dragon and warden) |
|
| |
| Template:EntityLink |
|
| |
| |
| |
| |
| Template:EntityLink |
|
An entity A is an ally of an entity B if A = B, if A considers B as an ally, or if B considers A as an ally. The table below shows when one entity considers another as an ally:
| Targeter | Considers as ally if... |
|---|---|
|
The targeter and the target have a Minecraft:team, and it is the same team. | |
|
The Template:Tooltip is tame, and the owner is the target or considers the target as an ally. | |
|
The target is the Template:Tooltip linked player (has the Minecraft:UUID in memory Template:Cd). | |
|
The target entity type is in the tag Template:Tag link and the target and the targeter don't have a team. | |
| Template:EntityLink |
The target is a Minecraft:vex and the target root ownerTemplate:Fn is the Template:Tooltip or considers the Template:Tooltip as ally. |
Sensor classes
Sensors classes are responsible for detecting a specific type of information and storing the results in one or more memory modules in a mob's brain. In the game's code, these classes are part of the package Template:Cd
| Class | Memory requires | Do tick |
|---|---|---|
| DummySensor | None | Performs no actions |
| AdultSensor | Template:Cd and Template:Cd | Searches the Template:Cd memory for the nearest visible Minecraft:living entity of the same Minecraft:entity type as the mob that is not a Minecraft:baby. Stores the result in the Template:Cd memory.
If no matching adult is found, Template:Cd is set to empty. |
| AdultSensorAnyType |
When setting the nearest visible adult, it tests whether the entity is in the tag Template:Tag link, rather than whether it's in the same entity type as the mob. | |
| AxolotlAttackablesSensor | Template:Cd | Template:Hatnote
Searches the Template:Cd memory for the closest Minecraft:living entity that:
Stores the closest matching entity in the Template:Cd memory. |
| BreezeAttackEntitySensor | Template:Cd, Template:Cd | Template:Hatnote
Updates the Template:Cd and Template:Cd memories (by the super method). It then searches the Template:Cd memory for the attackable entityTemplate:Fn that is not a player in Minecraft:Creative mode or Minecraft:Spectator mode. Stores the first matching entity in the Template:Cd memory. If no matching entity is found, it removes the Template:Cd memory. |
| FrogAttackablesSensor | Template:Cd, Template:Cd | Template:Hatnote
Searches the Template:Cd memory for entity that:
Stores the closest matching entity in the Template:Cd memory. |
| GolemSensor | Template:Cd and Template:Cd | Searches the Template:Cd memory for an Minecraft:iron golem. If one is found, it sets the Template:Cd memory to true with an expiration time of Template:Convert.
scanRate: This sensor runs every Template:Convert by default. It only checks whether at least one iron golem is present. |
| HoglinSpecificSensor | Template:Cd, Template:Cd, Template:Cd, Template:Cd, Template:Cd | Searches the Template:Cd memory for visible adult Minecraft:piglins and Minecraft:hoglins.
Stores the nearest visible adult Minecraft:piglin in the Template:Cd memory and stores visible adult Minecraft:hoglins in the Template:Cd memory. It also stores the number of visible adult piglins and hoglins in the Template:Cd and Template:Cd memories. Searches for the nearest hoglin repellent block within 8 blocks horizontally and 4 blocks vertically, and stores its position in the Template:Cd memory. |
| HurtBySensor | Template:Cd and Template:Cd | Checks the mob's last damageSource.
|
| IsInWaterSensor | Template:Cd | Checks whether the mob is in Minecraft:water. If it is, it sets the Template:Cd memory. Otherwise, it removes the Template:Cd memory. |
| MobSensor | Template:Cd |
If the sensor's readiness condition (readyTest) is met, it searches the Template:Cd memory for a Minecraft:living entity matching the sensor's predicate (mobTest). If a matching entity is found, it sets the sensor's memory (memoryTimeToLive) to |
| NearestBedSensor | Template:Cd | If the mob is a Minecraft:baby:
|
| NearestItemSensor | Template:Cd | Find the Template:Tooltip item that:
The nearest matching item is stored in the Template:Cd memory. If no matching item is found, the memory is set to empty. |
| NearestLivingEntitySensor | Template:Cd and Template:Cd | Template:A
Lists all other Minecraft:living entities that are alive and within a cuboid generated by the mob's hitbox expanded by its Template:Attr in all directions. Sorts the entities by Minecraft:Euclidean distance from the mob and stores the list in the Template:Cd memory. In Template:Cd, storesTemplate:Fn the entities from Template:Cd filtering entities using the mob's targeting conditionsTemplate:Fn |
| NearestVisibleLivingEntitySensor | Template:Cd and a memory defined by the subclass | Template:A Searches the Template:Cd memory for the closest Minecraft:living entity that matches the conditions defined by the subclass.
The matching entity is stored in the memory defined by the subclass. If no matching entity is found, the memory is set to empty. |
| PiglinBruteSpecificSensor | Template:Cd | Searches the Template:Cd memory for the nearest Minecraft:wither skeleton or Minecraft:wither and stores it in the Template:Cd memory.
Stores nearby adult Minecraft:piglins in the Template:Cd memory. |
| PiglinSpecificSensor | Template:Cd | Searches the Template:Cd memory and updates memories related to Minecraft:piglin behavior:
Searches the Template:Cd memory and stores adult Minecraft:piglins and Minecraft:piglin brutes in Template:Cd. Searches for the nearestTemplate:Fn block in the tag Template:Tag link in a box with 17 × 9 × 17 blocks centered on the piglins' position, and stores its position in Template:Cd. Not lit Minecraft:soul campfires are not considered repellents. |
| PlayerSensor | Template:Cd, Template:Cd, Template:Cd and Template:Cd | List all non-Minecraft:Spectator players that are within a Minecraft:Euclidean distance of the mob's Template:Attr. Sorts the players by distance from the mob and stores the list in Template:Cd.
From this list, it creates Template:Cd by filtering players using the mob's targeting conditionsTemplate:Fn. If the resulting list is not empty, stores the first player in Template:Cd. Creates Template:Cd by filtering Template:Cd's list using the mob's attack targeting conditionsTemplate:Fn. If the resulting list is not empty, the first player is stored in Template:Cd. |
| SecondaryPoiSensor | Template:Cd | Scans all blocks within a Template:Tooltip area centered on a villager. If a block matches one of the villager profession's secondary job site blocks, it stores its global position in the Template:Cd memory. It stores all matching blocks.
If no matching blocks are found, it removes the Template:Cd memory. scanRate: This sensor runs every Template:Convert instead of the default 20. |
| TemptingSensor | Template:Cd |
Searches for the Minecraft:player that:
If a matching player is found, it stores the nearest (by Minecraft:euclidean distance) player in the Template:Cd memory. Otherwise, it removes the Template:Cd memory. |
| VillagerBabiesSensor | Template:Cd | Finds all villagers that are babies from the mob's Template:Cd memory and stores them as a list in the Template:Cd memory.
If no visible baby villagers are found, stores an empty list. |
| VillagerHostilesSensor | Template:Cd and Template:Cd |
Template:Hatnote Searches the Template:Cd memory for the nearest Minecraft:living entity matching one of the following hostile entity types and stores it in the Template:Cd memory:
If no matching hostile entity is found, Template:Cd is set to empty. |
| WardenEntitySensor | Template:Cd, Template:Cd | Template:Hatnote
Updates the Template:Cd and Template:Cd memories (by the super method). It then searches the Template:Cd memory for the Template:Tooltip targetable Minecraft:player. If none is found, it searches for the Template:Tooltip targetable non-player Minecraft:living entity. In both cases, only entities that the warden can target are considered. Stores the first matching entity in the Template:Cd memory. If no matching entity is found, it removes the Template:Cd memory. |
Task
Tasks are activities that mobs with brain AI systems can perform. Sensors are used to determine if a task can be performed, and tasks may use information stored in memories. Examples of tasks include a villager walking to its jobsite, a piglin admiring an item, or a warden emerging. Tasks have priorities, so tasks with a higher priority will overrun tasks with lower priority; for example, if a zombie is wandering and it sees a player, it will switch tasks to attacking.
Memory
Memories are used to store data and are used when mobs perform tasks. Examples of memories include a list of all visible mobs in range, the location of a villager's jobsite block, and any cooldowns the mob may have.
Control
Walking
Mob movement on land varies depending on whether it's hostile or passive. Hostile mobs will try to approach and attack the player when within their detection range, while most passive mobs will attempt to run away when attacked. Some mobs will also try to attack or run away from certain blocks or mobs.
Swimming
Mob swimming works the same way as walking, but in water. While most mobs will just float on water or sink, some can properly swim like Minecraft:fish, Minecraft:drowned, Minecraft:dolphins, Minecraft:turtles, Minecraft:guardians, and Minecraft:elder guardians.
Flying
Mob flying works the same way as walking, but in the air. Most mobs will just fall when suspended in air, with a few exceptions. Mobs with Minecraft:Slow Falling, Minecraft:levitation, and the Minecraft:chicken don't fly normally but can float in mid-air. [[Minecraft::Category:Flying mobs]] contains a list of all mobs that can pathfind in air.
Goals
Goals are a simple AI system used primarily by mobs that already existed before the brain AI. However, there are recent mobs that use both AIs simultaneously, for example, the Minecraft:happy ghast.
Goals can range from wandering around, opening doors, attacking another mob, and more. Each type of mob that uses goals has its own defined list of goals, and each goal has a priority. Mobs attempt to perform the lowest priority goal they can, and may switch goals if there is an opportunity to pursue a lower priority goal. For example, if a zombie is targeting and chasing a villager (priority of 3) and a player comes within the detection range of the zombie, the zombie may target and chase the player (priority of 2) instead.
List of goals
List of goals that are used by many different mobs.
| Goal | Description | Notes |
|---|---|---|
| Active Target | Select an entity to target for chasing and attacking | |
| Ambient Stand | Untamed horse bucks when player tries to ride it | |
| Attack | Attack target | |
| Attack with Owner | Tamed animal attacks a target mob attacked by owner | |
| Avoid Entity | Mob runs away from another mob that it is afraid of (e.g. skeletons running from wolves) | |
| Bow Attack | Attack target with bow | |
| Breathe Air | Mob that can drown tries to move out of water | |
| Cat Lie on Bed | Tamed cat lies down on bed | |
| Cat Sit on Block | Cat sits on bed, chest, or furnace | |
| Chase Boat | Chase after boat ridden by player | Unused |
| Crossbow Attack | Attack target with crossbow | |
| Destroy Egg | Destroy turtle eggs | |
| Disableable Follow Target | Raid entity stops following target | Unused |
| Dive Jump | Mob jumps up and dives down | |
| Dolphin Jump | Dolphin jumps out of water | |
| Door Interact | Mob tries to open a door | |
| Eat Grass | Mob grazes on grass | |
| Flee Sun | Move out of direct line-of-sight with sky during day | |
| Float | Mob floats in water | |
| Follow Flock Leader | Fish tries to follow the leader of a school of fish | |
| Follow Mob | Mob follows another mob | |
| Follow Owner | Tamed mob follows owner | |
| Follow Parent | Baby mob follows its parent | |
| Go to Walk Target | Mob walks to a target | |
| Hold in Hands | Mob holds an item in its main hand | |
| Horse Bond with Player | Horse attempts to bond with player attempting to tame it | |
| Iron Golem Look | Iron golem looks at a villager | |
| Iron Golem Wander Around | Iron golem wanders around village | uses points of interest |
| Llama Follow Caravan | Llamas form and follow a caravan | |
| Leap At Target | Mob jumps towards target | cats, foxes, ocelots, spiders |
| Long Door Interact | Open a door, then close it after a delay | |
| Look At Entity | Mob looks at another mob | |
| Look At Player | Mob looks at player | |
| Look At Trading Player | Villager or wandering trader looks at player while trading | |
| Melee Attack | Mob paths to target and attacks | |
| Move Into Water | Mob paths to water | |
| Move Through Village | Mob moves between points of interest in a village | |
| Move To Raid Center | Raiders move toward village after spawning | |
| Move To Target Position | Mob paths to a specific block | |
| Panic | Mob panics and runs away when damaged | |
| Powder Snow Jump | Mob dives into powder snow | foxes |
| Prioritized Goal | Used to override the default priority of a goal | |
| Projectile Attack | Mob attacks target with a projectile | arrow, spit, trident, potion, snow ball, wither skull, not fireballs |
| Raid Goal | Raiders target villagers | |
| Random Look Around | Mob looks around in random directions | |
| Random Stroll | Move to a nearby random position | |
| Revenge | Target entity that attacked the mob | |
| Run Around Like Crazy | Untamed horse runs around randomly when ridden by a player | |
| Spear Use | Mob attacks target with spear | |
| Swell | Creeper attempts to explode near its target | |
| Tempt | Mob follows player holding breeding item | |
| Water Avoiding Random Stroll | Move to a nearby random position, while actively avoiding water | |
| Wander Around Far | Move to a random position, sometimes farther away than Wander Around goal | |
| Zombie Attack | Attack goal for zombies and zombie variants |
Lists of mob goals
Lists of goals and associated priorities for individual mobs.
| Goal | Priority | Notes |
|---|---|---|
| Revenge | 1 | Attack entity that damaged the zombie |
| Active Target - Player | 2 | Target the player |
| Zombie Attack | 2 | Attack current target |
| Active Target - Iron Golem | 3 | Target Iron Golem |
| Active Target - Merchant | 3 | Target Villager or Wandering Trader |
| Destroy Egg | 4 | Break turtle eggs |
| Active Target - Turtle | 5 | Target baby turtle |
| Wander Around Far | 7 | |
| Look Around | 8 | Looks away from Entities |
| Look at Entity | 8 | Looks at nearest Entities |
Pathfinding
Pathfinding is the system used by mobs to navigate through the world. Mobs that use pathfinding calculate routes through the environment and follow these routes using their navigation system. Different mobs use different types of navigation depending on their movement abilities, such as Minecraft:walking, Minecraft:swimming, or Minecraft:flying.
The default navigation type for mobs is ground path navigation, although individual mobs can replace it with a different navigation implementation.
Pathfinding is controlled by a mob's AI. Goals and behaviors can request movement to a location or entity, causing the mob's navigation system to calculate and follow a path. The navigation system is updated every Minecraft:tick while the mob's AI is active.
A mob is considered to be pathfinding when its navigation system has an active path. The path ends when the mob reaches its destination, the path becomes invalid, or the navigation is stopped.
The navigation system controls how mobs follow paths after they have been calculated.
A navigation system stores the mob's current path, movement speed, and destination. During each AI update, the navigation system checks the current path, advances through nodes that have been reached, and sends movement instructions to the mob's movement controls.
Navigation can be stopped manually, which clears the mob's current path. A mob is considered to be navigating when it has an active path that has not been completed.
Different mobs use different navigation systems depending on their movement type. Ground mobs generally use ground navigation, while Minecraft:aquatic and [[Minecraft::Category:Flying mobs|flying mobs]] use specialized navigation systems.
Navigation systems can also perform checks while moving, such as:
- When a mob becomes stuck.
- Recalculating paths when needed.
- Whether a mob can move directly between two points.
- Adjusting paths around certain blocks.
Path following
After a path is created, mobs follow the path by moving from node to node. A node represents a position that the mob must reach while traveling.
A mob advances to the next node when it is close enough to its current node. Some paths allow mobs to skip nodes when moving directly toward a later point would be safe.
While following a path, mobs can become stuck if they fail to make sufficient progress. The navigation system checks movement over time and stops the path if the mob cannot continue.
Pathfinding penalties
When pathfinding to a target, mobs will sometimes avoid certain blocks (usually blocks that cause damage or slow the mob down). These blocks have a penalty associated with them. Generally, mobs try to path through blocks with the smallest penalty. There are some blocks that most mobs cannot path through; these all have a penalty of -1.
The following table is a list of all pathfinding penalties and their default values. Each type of pathfinding (land, water, air) uses its own subset of these penalties. Some mobs override these default values.
| Penalty type | Penalty | Description |
|---|---|---|
| blocked | -1 | can't pathfind through block (most full solid blocks) |
| powder snow | -1 | Template:BlockLink |
| fence | -1 | Template:BlockLink Template:BlockLink Template:BlockLink (closed) |
| lava | -1 | Template:BlockLink |
| unpassable rail | -1 | Template:BlockLink |
| damage - other | -1 | Template:BlockLink Template:BlockLink |
| closed wood door | -1 | Template:BlockLink |
| closed iron door | -1 | Template:BlockLink |
| open | 0 | Template:BlockLink Template:BlockLink Template:BlockLink |
| walkable | 0 | Template:BlockLink with pressure plate on top (under the mob) |
| walkable door | 0 | a door the mob can open |
| trapdoor | 0 | Template:BlockLink Template:BlockLink Template:BlockLink |
| danger - powder snow | 0 | neighboring block is Template:BlockLink |
| open door | 0 | open wood or iron door |
| cocoa | 0 | Template:BlockLink |
| damage - cautious | 0 | Template:BlockLink Template:BlockLink |
| danger - trapdoor | 0 | neighboring block is Template:BlockLink |
| breach water | 4 | there is an air block above a water block |
| water | 8 | Template:BlockLink |
| water border | 8 | neighboring block is Template:BlockLink |
| danger - fire | 8 | neighboring block is: Template:BlockLink Template:BlockLink Template:BlockLink Template:BlockLink Template:BlockLink |
| danger - other | 8 | neighboring block is: Template:BlockLink Template:BlockLink |
| honey | 8 | Template:BlockLink |
| damage - fire | 16 | Template:BlockLink Template:BlockLink Template:BlockLink Template:BlockLink Template:BlockLink |
- Mob pathfinding penalty overrides
The following mobs override the default pathfinding penalty for some blocks:
| Mob | Penalty Type | Penalty |
|---|---|---|
| Template:EntityLink | water | 0 |
| Template:EntityLink | damage - fire | -1 |
| water | -1 | |
| cocoa | -1 | |
| fence | -1 | |
| water border | 16 | |
| Template:EntityLink | water | 0 |
| Template:EntityLink | danger - other | 0 |
| damage - other | 0 | |
| Template:EntityLink | trapdoor | -1 |
| water | 4 | |
| Template:EntityLink | powder snow | -1 |
| danger - powder snow | -1 | |
| Template:EntityLink Template:EntityLink |
damage-fire | -1 |
| danger - fire | 16 | |
| Template:EntityLink | danger-fire | -1 |
| damage - fire | -1 | |
| cocoa | -1 | |
| Template:EntityLink | water | -1 |
| danger - powder snow | -1 | |
| damage - cautious | -1 | |
| Template:EntityLink | water | -1 |
| lava | 0 | |
| danger - fire | 0 | |
| damage - fire | 0 | |
| Template:EntityLink | close iron door | -1 |
| closed wood door | -1 | |
| open door | -1 | |
| water | 0 | |
| Template:EntityLink | powder snow | -1 |
| danger - powder snow | -1 | |
| Template:EntityLink Template:EntityLink |
damage - fire | -1 |
| danger - fire | 16 | |
| Template:EntityLink | water | -1 |
| danger - fire | 8 | |
| damage - fire | 8 | |
| lava | 8 | |
| Template:EntityLink | danger - trapdoor | -1 |
| damage - fire | -1 | |
| Template:EntityLink | water | 0 |
| Template:EntityLink | water | -1 |
| Template:EntityLink | water | 0 |
| Template:EntityLink | leaves | 0 |
| Template:EntityLink | unpassable rail | 0 |
| damage - fire | 0 | |
| danger - fire | 0 | |
| damage - other | 8 | |
| powder snow | 8 | |
| lava | 8 | |
| water creatures | water | 0 |
| Template:EntityLink | lava | 8 |
| Template:EntityLink | lava | 8 |
| animal | damage - fire | -1 |
| danger - fire |
Pathfinding on land
- All entities move based on random targets that are generated every tick with a priority toward their entity-specific goals.
- These targets can be located anywhere in 3D space within the entity range and are only generated when wandering or when they have no goals.
- For every target, a path is generated; with the entity preferring the path with the lowest score regarding the Pathfinding penalties.
- If an entity cannot take any paths with a low enough score, or any paths without a score of -1, the entity will not move until one is found.
- If an entity's target is located inside a block (including water), the target is moved to the nearest air block above it.
This means every entity, when wandering, will always prefer to pathfind to a block with the most blocks below it within range.
Due to the higher chance that a target will be generated within the blocks below it and moved up to the nearest air block above before generating a path.
Pathfinding in water
- Pathfinding in water is roughly the same as land; however, most entities, excluding fish and drowned, will bounce on the surface, preferring land due to the Pathfinding penalties of water.
Pathfinding in air
- Pathfinding in air is roughly the same as land; however, few entities can pathfind to air.
See also
Template:Navbox Java Edition technical
Minecraft:de:Künstliche Intelligenz Minecraft:ja:Mob AI Minecraft:pt:IA de criatura Minecraft:zh:生物AI