API Surface (2) void tick()
boolean hasLineOfSight(final Entity target)
Code Graph: Dependencies (4) Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.
Full Source
Sensing.java 47 lines · Minecraft 26.3 · verbatim Copy
1 package net.minecraft.world.entity.ai.sensing;
2
3 import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
4 import it.unimi.dsi.fastutil.ints.IntSet;
5 import net.minecraft.util.profiling.Profiler;
6 import net.minecraft.util.profiling.ProfilerFiller;
7 import net.minecraft.world.entity.Entity;
8 import net.minecraft.world.entity.Mob;
9
10 public class Sensing {
11 private final Mob mob;
12 private final IntSet seen = new IntOpenHashSet();
13 private final IntSet unseen = new IntOpenHashSet();
14
15 public Sensing(final Mob mob) {
16 this.mob = mob;
17 }
18
19 public void tick() {
20 this.seen.clear();
21 this.unseen.clear();
22 }
23
24 public boolean hasLineOfSight(final Entity target) {
25 int targetId = target.getId();
26 if (this.seen.contains(targetId)) {
27 return true;
28 }
29
30 if (this.unseen.contains(targetId)) {
31 return false;
32 }
33
34 ProfilerFiller profiler = Profiler.get();
35 profiler.push("hasLineOfSight");
36 boolean hasLineOfSight = this.mob.hasLineOfSight(target);
37 profiler.pop();
38 if (hasLineOfSight) {
39 this.seen.add(targetId);
40 } else {
41 this.unseen.add(targetId);
42 }
43
44 return hasLineOfSight;
45 }
46 }
47
Decompiled Minecraft 26.3 source of Sensing (net/minecraft/world/entity/ai/sensing/Sensing.java) with Mojang official mappings, stored verbatim on the site.