AxolotlAttackablesSensor .java

net.minecraft.world.entity.ai.sensing.AxolotlAttackablesSensor (class): members: TARGET_DETECTION_DISTANCE, isMatchingEntity, getMemoryToSet, requires.

net.minecraft.world.entity.ai.sensingclass43 linescommonextends NearestVisibleLivingEntitySensor1.4 KB

API Surface (3)

boolean isMatchingEntity(final ServerLevel level, final LivingEntity body, final LivingEntity mob)
MemoryModuleType<LivingEntity> getMemoryToSet()
Set<MemoryModuleType<?>> requires()

Fields & Constants (1)

TARGET_DETECTION_DISTANCE

Code Graph: Dependencies (6)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

AxolotlAttackablesSensor.java43 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.ai.sensing;
2
3
import com.google.common.collect.Sets;
4
import java.util.Set;
5
import net.minecraft.server.level.ServerLevel;
6
import net.minecraft.tags.EntityTypeTags;
7
import net.minecraft.world.entity.LivingEntity;
8
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
9
10
public class AxolotlAttackablesSensor extends NearestVisibleLivingEntitySensor {
11
	public static final float TARGET_DETECTION_DISTANCE = 8.0F;
12
13
	@Override
14
	protected boolean isMatchingEntity(final ServerLevel level, final LivingEntity body, final LivingEntity mob) {
15
		return this.isClose(body, mob)
16
			&& mob.isInWater()
17
			&& (this.isHostileTarget(mob) || this.isHuntTarget(body, mob))
18
			&& Sensor.isEntityAttackable(level, body, mob);
19
	}
20
21
	private boolean isHuntTarget(final LivingEntity body, final LivingEntity mob) {
22
		return !body.getBrain().hasMemoryValue(MemoryModuleType.HAS_HUNTING_COOLDOWN) && mob.is(EntityTypeTags.AXOLOTL_HUNT_TARGETS);
23
	}
24
25
	private boolean isHostileTarget(final LivingEntity mob) {
26
		return mob.is(EntityTypeTags.AXOLOTL_ALWAYS_HOSTILES);
27
	}
28
29
	private boolean isClose(final LivingEntity body, final LivingEntity mob) {
30
		return mob.distanceToSqr(body) <= 64.0;
31
	}
32
33
	@Override
34
	protected MemoryModuleType<LivingEntity> getMemoryToSet() {
35
		return MemoryModuleType.NEAREST_ATTACKABLE;
36
	}
37
38
	@Override
39
	public Set<MemoryModuleType<?>> requires() {
40
		return Sets.union(super.requires(), Set.of(MemoryModuleType.HAS_HUNTING_COOLDOWN));
41
	}
42
}
43

Decompiled Minecraft 26.3 source of AxolotlAttackablesSensor (net/minecraft/world/entity/ai/sensing/AxolotlAttackablesSensor.java) with Mojang official mappings, stored verbatim on the site.