Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Mob AI: Difference between revisions

From SAS Gaming Wiki
SyncBot (talk | contribs)
Sync: updated from Minecraft
SyncBot (talk | contribs)
Sync: updated from Minecraft
Line 10: Line 10:
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.
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 detection logic. The first execution of each sensor is delayed by a random number of ticks, preventing multiple sensors from running simultaneously.
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"
Line 32: Line 32:
}}
}}
|-
|-
|nearest_living_entities
|mobs
|NearestLivingEntitySensor
|NearestLivingEntitySensor
|{{Flatlist|
|{{Flatlist|
Line 196: Line 196:


====Sensor parameters====
====Sensor parameters====
{{wip|section=1|TemptingSensor parameters}}


Some sensor classes have parameters, namely MobSensor and TemptingSensor. The list of parameters is below:
Some sensor classes have parameters, namely '''MobSensor''' and '''TemptingSensor'''. The list of parameters is below:


{|class= "wikitable collapsible collapsed"
{|class= "wikitable collapsible collapsed"
Line 245: Line 246:


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}}.
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, 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, and {{nbt|bool|testInvisible}} is false when the target is in the targeter's {{cd|attack_target}} memory. For some, attack target {{nbt|bool|checkLineOfSight}} is false.
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 target 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, {{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.
* If {{nbt|bool|isCombat}} is true, the targeter can not attack the target or the targeter is allied to the target, retrun true. See below for more details.
* 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.
** 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]], retrun false.
* Otherwise, it returns true.
The table below shows when the conditions of a living entity (the targeter) cannot attack another (the target). At least one condition must be satisfied for it not to attack.
{|class= "wikitable collapsible collapsed"
|+ Can not attack
! Targeter
! Can not attack if...
|-
| {{EnvLink|id=Mob|Living entity}} (except ender dragon and Warden)
|
* The target is player and the difficulty is peaceful.
* The target is invulnerable.
* The target in 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 in 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:
{{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 they are the same entity, 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 owns is the target or considers the target as 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 doesn'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====
====Sensor classes====
{{wip|section=1|Remove the information in the section above and specify the targeting condition (with {{t|fn}}).}}
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}}
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="wikitable collapsible"
Line 262: Line 386:
|AdultSensorAnyType
|AdultSensorAnyType
|
|
Extends '''AdultSensor'''
{{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.
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
|AxolotlAttackablesSensor
|{{cd|nearest_attackable}}, {{cd|nearest_visible_living_entities}}, and {{cd|has_hunting_cooldown}}
|{{cd|nearest_attackabled|visible_mobs|d=and|has_hunting_cooldown}}
|Extends '''NearestVisibleLivingEntitySensor'''  
|{{Hatnote|Extends '''{{Slink||NearestVisibleLivingEntitySensor}}'''}}
Searches the {{cd|nearest_visible_living_entities}} memory for the closest [[Minecraft:living entity]] that is within 8 blocks, in water, and is either a hostile target or a hunt target of an [[Minecraft:axolotl]]. The entity must also be attackable by the mob.
Searches the {{cd|visible_mobs}} memory for the closest [[Minecraft:living entity]] that is within 8 blocks, in water, and is either a hostile target or a hunt target of an [[Minecraft:axolotl]]. The entity must also be attackable by the mob.


Stores the closest matching entity in the {{cd|nearest_attackable}} memory.
Stores the closest matching entity in the {{cd|nearest_attackable}} memory.
|-
|-
|BreezeAttackEntitySensor
|BreezeAttackEntitySensor
|{{cd|nearest_living_entities}}, {{cd|nearest_visible_living_entities}}, and {{cd|nearest_attackable}}
|{{cd|mobs}}, {{cd|visible_mobs|d=and|nearest_attackable}}
|Extends '''NearestVisibleLivingEntitySensor'''
|{{Hatnote|Extends '''{{Slink||NearestLivingEntitySensor}}'''}}
Updates the {{cd|nearest_living_entities}} and {{cd|nearest_visible_living_entities}} memories. It then searches the {{cd|nearest_living_entities}} memory for the closest attackable [[Minecraft:living entity]] that is not a player in [[Minecraft:Creative]] mode or [[Minecraft:Spectator]] mode.
Updates the {{cd|mobs}} and {{cd|visible_mobs}} memories (by the super method). It then searches the {{cd|mobs}} memory for the closest attackable [[Minecraft:living entity]] 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.
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|nearest_visible_living_entities}}, and {{cd|unreachable_tongue_targets}}
|{{cd|nearest_attackable}}, {{cd|visible_mobs|d=and|unreachable_tongue_targets}}
|Extends '''NearestVisibleLivingEntitySensor'''  
|{{Hatnote|Extends '''{{Slink||NearestVisibleLivingEntitySensor}}'''}}
Searches the {{cd|nearest_visible_living_entities}} memory for the closest [[Minecraft:living entity]] that is within 10 blocks, can be eaten by a [[Minecraft:frog]], is attackable by the mob, and is not listed in the {{cd|unreachable_tongue_targets}} memory.
Searches the {{cd|visible_mobs}} memory for the closest [[Minecraft:living entity]] that is within 10 blocks, can be eaten by a [[Minecraft:frog]], is attackable by the mob, and is not listed in the {{cd|unreachable_tongue_targets}} memory.


Stores the closest matching entity in the {{cd|nearest_attackable}} memory.
Stores the closest matching entity in the {{cd|nearest_attackable}} memory.
Line 294: Line 418:
|-
|-
|HoglinSpecificSensor
|HoglinSpecificSensor
|{{cd|nearest_visible_living_entities}}, {{cd|nearest_repellent}}, {{cd|nearest_visible_adult_piglin}}, {{cd|nearest_visible_adult_hoglins}}, {{cd|visible_adult_piglin_count}}, and {{cd|visible_adult_hoglin_count}}
|{{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|nearest_visible_living_entities}} memory for visible adult [[Minecraft:piglin]]s and [[Minecraft:hoglin]]s.
|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.
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.
Line 316: Line 440:
|MobSensor
|MobSensor
|{{cd|mobs}}
|{{cd|mobs}}
|If the sensor's readiness condition is met, it searches the {{cd|mobs}} memory for a [[Minecraft:living entity]] matching the sensor's predicate. If a matching entity is found, it sets the sensor's memory to <code>true</code> with an expiration time determined by the sensor.
|
If the readiness condition is not met, it removes the sensor's memory.
{{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
|NearestBedSensor
Line 324: Line 451:
* 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.
* 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.
* 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|grup=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.netxtInt(20)|0 &le; int &lt; 20}}, at the beginning of the doTick.}}
* 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.netxtInt(20)|0 &le; int &lt; 20}}, at the beginning of the doTick.}}
|-
|-
|NearestItemSensor
|NearestItemSensor
Line 331: Line 458:
* Is within a bounding box extending 32 blocks horizontally and 16 blocks vertically from the mob.
* Is within a bounding box extending 32 blocks horizontally and 16 blocks vertically from the mob.
* Is within 32 blocks of the mob.
* Is within 32 blocks of the mob.
* The mob wants to pick up.{{fn|grup=sensor|name=dm|It depends on the mob, defined independently of the sensor.}}
* 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|grup=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]].}}
* 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.
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
|NearestLivingEntitySensor
|{{cd|mobs}} and {{cd|visible_mobs}}
|{{cd|mobs}} and {{cd|visible_mobs}}
|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.
|{{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 the entities from {{cd|mobs}} that:{{fn|rup=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.}}
In {{cd|visible_mobs}}, stores the entities from {{cd|mobs}} that:{{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.}}
* Are not a [[Minecraft:Spectator]] player or an invisible or marker [[Minecraft:armor stand]].
* Are not a [[Minecraft:Spectator]] player or an invisible or marker [[Minecraft:armor stand]].
* Are in the mob's line of sight.{{fn|grup=sensor|name=los}}
* Are in the mob's line of sight.{{fn|group=sensor|name=los}}
* Are within a range of {{cd|r}} blocks of the mob, where {{cd|r}} is the {{attr|follow_range}}.{{fn|grup=sensor|name=vp| For entities that are not in the mob's memory {{cd|attack_target}}, this range is multiplied by a modifier that indicates the visibility percentage of the entity. The modifier starts with 1 and is cumulative:
* Are within a range of {{cd|r}} blocks of the mob, where {{cd|r}} is the {{attr|follow_range}}.{{fn|group=sensor|name=vp| For entities that are not in the mob's memory {{cd|attack_target}}, this range is multiplied by a modifier that indicates the visibility percentage of the entity. The modifier starts with 1 and is cumulative:
* Multiplying by {{cd|0.8}} if it is a [[Minecraft:sneaking]] player,
* Multiplying by {{cd|0.8}} if it is a [[Minecraft:sneaking]] player,
* Multiplying by {{cd|0.07}} if it is [[Minecraft:invisible]] and without equipament in {{tooltip|humanoid armor slot|head, chest, legs or feet slot}},
* Multiplying by {{cd|0.07}} if it is [[Minecraft:invisible]] and without equipament in {{tooltip|humanoid armor slot|head, chest, legs or feet slot}},
Line 350: Line 478:
|-
|-
|NearestVisibleLivingEntitySensor
|NearestVisibleLivingEntitySensor
|{{cd|nearest_visible_living_entities}} and a memory defined by the subclass
|{{cd|visible_mobs}} and a memory defined by the subclass
|Searches the {{cd|nearest_visible_living_entities}} memory for the closest [[Minecraft:living entity]] that matches the conditions 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.
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
|PiglinBruteSpecificSensor
|{{cd|nearest_visible_living_entities}}, {{cd|nearest_visible_nemesis}}, and {{cd|nearby_adult_piglins}}
|{{cd|visible_mobs|nearest_visible_nemesis|nearby_adult_piglins|d=and}}
|Searches the {{cd|nearest_visible_living_entities}} memory for the nearest [[Minecraft:wither skeleton]] or [[Minecraft:wither]] and stores it in the {{cd|nearest_visible_nemesis}} memory.
|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.
Stores nearby adult [[Minecraft:piglin]]s in the {{cd|nearby_adult_piglins}} memory.
|-
|-
|PiglinSpecificSensor
|PiglinSpecificSensor
|{{cd|nearest_visible_living_entities|nearest_living_entities|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}}
|{{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|nearest_visible_living_entities}} memory and updates memories related to [[Minecraft:piglin]] behavior:
|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|wither skeleton}} Stores the nearest [[Minecraft:wither skeleton]] or [[Minecraft:wither]] as {{cd|nearest_visible_nemesis}}.  


* {{EntitySprite|Hoglin}} Stores the nearest adult huntable{{fn|grup=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|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|Baby Hoglin}} Stores the nearest [[Minecraft:baby]] hoglin as {{cd|nearest_visible_baby_hoglin}}.


Line 375: Line 503:
* {{EntitySprite|Zombified Piglin}} Stores the nearest [[Minecraft:zombified piglin]] or [[Minecraft:zoglin]] in {{cd|nearest_visible_zombified}}.
* {{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 piglins in {{cd|nearest_visible_adult_piglins}}  
* {{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.
* {{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|nearest_living_entities}} memory and stores adult piglins and [[Minecraft:piglin brute]]s in {{cd|nearby_adult_piglins}}.
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|grup=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 &times; 9 &times; 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,.
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 &times; 9 &times; 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
|PlayerSensor
Line 387: Line 515:
|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}}.
|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, which checks that the player is targetable, including being within follow range and in the mob's line of sight.{{fn|name=los}} If the resulting list is not empty, stores the first player in {{cd|nearest_visible_player}}.
From this list, it creates {{cd|nearest_visible_player}} by filtering players using the mob's targeting conditions, which checks that the player is targetable, including being within follow range and in the mob's line of sight.{{fn|group=sensor|name=los}} 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:
Creates {{cd|nearest_visible_attackable_players}} by filtering {{cd|nearest_visible_player}}'s list using the mob's attack targeting conditions:
Line 418: Line 546:
|VillagerHostilesSensor
|VillagerHostilesSensor
|{{cd|nearest_hostile}} and {{cd|visible_mobs}}
|{{cd|nearest_hostile}} and {{cd|visible_mobs}}
|Extends '''NearestVisibleLivingEntitySensor'''  
|
{{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:
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|Drowned}} — within 8 blocks
Line 435: Line 564:
|-
|-
|WardenEntitySensor
|WardenEntitySensor
|{{cd|nearest_living_entities}}, {{cd|nearest_visible_living_entities}}, and {{cd|nearest_attackable}}
|{{cd|mobs}}, {{cd|visible_mobs|d=and|nearest_attackable}}
|Extends '''NearestVisibleLivingEntitySensor'''  
|{{Hatnote|Extends '''{{Slink||NearestLivingEntitySensor}}'''}}
Updates the {{cd|nearest_living_entities}} and {{cd|nearest_visible_living_entities}} memories. It then searches the {{cd|nearest_living_entities}} memory for the closest targetable [[Minecraft:player]]. If none is found, it searches for the closest targetable non-player [[Minecraft:living entity]].
Updates the {{cd|mobs}} and {{cd|visible_mobs}} memories (by the super method). It then searches the {{cd|mobs}} memory for the closest targetable [[Minecraft:player]]. If none is found, it searches for the closest targetable non-player [[Minecraft:living entity]].


Stores the first matching entity in the {{cd|nearest_attackable}} memory. If no matching entity is found, it removes the {{cd|nearest_attackable}} memory.
Stores the first matching entity in the {{cd|nearest_attackable}} memory. If no matching entity is found, it removes the {{cd|nearest_attackable}} memory.
|}
|}
{{fnlist|grup=sen}}
{{Reflist|group=sensor}}


=== Task ===
=== Task ===

Revision as of 11:08, 25 July 2026

Template:For Template:WIP

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).

List of Sensors Template:In
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

Template:Wip

Some sensor classes have parameters, namely MobSensor and TemptingSensor. The list of parameters is below:

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, 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, and Template:Nbt is false when the target is in the targeter's Template:Cd memory. For some, attack target Template:Nbt is false.

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:

The table below shows when the conditions of a living entity (the targeter) cannot attack another (the target). At least one condition must be satisfied for it not to attack.

An entity A is an ally of an entity B if they are the same entity, 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:

Template:Reflist

Sensor classes

Template:Wip

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

Template:Hatnote

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 is within 8 blocks, in water, and is either a hostile target or a hunt target of an Minecraft:axolotl. The entity must also be attackable by the mob.

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 closest attackable Minecraft:living entity 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 the closest Minecraft:living entity that is within 10 blocks, can be eaten by a Minecraft:frog, is attackable by the mob, and is not listed in the Template:Cd memory.

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

Template:Hatnote

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 true 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 Template:Cd If the mob is a Minecraft:baby:
  • Searches for POIs of type home (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 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 Template:Cd memory.
  • If no reachable bed is found and fewer than 5 POIs were checked, it removes expired entries from the cache.Template:Fn
NearestItemSensor Template:Cd Find the Template:Tooltip 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.Template:Fn
  • Is in the mob's line of sight.Template:Fn

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, stores the entities from Template:Cd that:Template: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 conditions, which checks that the player is targetable, including being within follow range and in the mob's line of sight.Template: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 conditions:

If the resulting list is not empty, stores the first player 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 nearest non-Minecraft:Spectator Minecraft:player within the mob's Template:Cd that is holding a tempting item in either hand. The player does not need to be in the mob's line of sight and cannot be riding the mob.

If a matching player is found, it stores the nearest 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 closest targetable Minecraft:player. If none is found, it searches for the closest targetable non-player Minecraft:living entity.

Stores the first matching entity in the Template:Cd memory. If no matching entity is found, it removes the Template:Cd memory.

Template:Reflist

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 over run 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

Template:Main

Mobs movement on land varies 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

Template:Main

Mobs 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

Template:Main

Mobs flying works the same way as walking, but in 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 are able to float in mid-air. [[Minecraft::Category:Flying mobs]] contains a list of all mobs that can path find in air.

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 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.

Lists of mob goals

Lists of goals and associated priorities for individual mobs.

Zombie
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 penalties

File:Zombified piglin pathing 1.png
Zombified piglin starts pathfinding to a Minecraft:turtle egg
File:Zombified pigling pathing 2.png
Due to pathfinding penalties, the zombified piglin takes an indirect path to the turtle egg, pathing through wither roses and taking damage, instead of pathing through the lava or magma blocks, which do not damage the zombified piglin

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:

Template:Expand section

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

Navigation

Template:Navbox Java Edition technical

Minecraft:de:Künstliche Intelligenz Minecraft:ja:Mob AI Minecraft:pt:IA de criatura Minecraft:zh:生物AI