FrogAttackablesSensor .java

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

net.minecraft.world.entity.ai.sensingclass36 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

FrogAttackablesSensor.java36 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.ArrayList;
5
import java.util.List;
6
import java.util.Set;
7
import java.util.UUID;
8
import net.minecraft.server.level.ServerLevel;
9
import net.minecraft.world.entity.LivingEntity;
10
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
11
import net.minecraft.world.entity.animal.frog.Frog;
12
13
public class FrogAttackablesSensor extends NearestVisibleLivingEntitySensor {
14
	public static final float TARGET_DETECTION_DISTANCE = 10.0F;
15
16
	@Override
17
	protected boolean isMatchingEntity(final ServerLevel level, final LivingEntity body, final LivingEntity mob) {
18
		return Sensor.isEntityAttackable(level, body, mob) && Frog.canEat(mob) && !this.isUnreachableAttackTarget(body, mob) ? mob.closerThan(body, 10.0) : false;
19
	}
20
21
	private boolean isUnreachableAttackTarget(final LivingEntity body, final LivingEntity mob) {
22
		List<UUID> unreachableAttackTargets = body.getBrain().getMemory(MemoryModuleType.UNREACHABLE_TONGUE_TARGETS).orElseGet(ArrayList::new);
23
		return unreachableAttackTargets.contains(mob.getUUID());
24
	}
25
26
	@Override
27
	protected MemoryModuleType<LivingEntity> getMemoryToSet() {
28
		return MemoryModuleType.NEAREST_ATTACKABLE;
29
	}
30
31
	@Override
32
	public Set<MemoryModuleType<?>> requires() {
33
		return Sets.union(super.requires(), Set.of(MemoryModuleType.UNREACHABLE_TONGUE_TARGETS));
34
	}
35
}
36

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