WallClimberNavigation .java

net.minecraft.world.entity.ai.navigation.WallClimberNavigation (class, 61 lines): members: pathToPosition, createPath, moveTo, tick. imports: Mob.

net.minecraft.world.entity.ai.navigationclass61 linescommonextends GroundPathNavigation1.8 KB

API Surface (4)

Path createPath(final BlockPos pos, final int reachRange)
Path createPath(final Entity target, final int reachRange)
boolean moveTo(final Entity target, final double speedModifier)
void tick()

Fields & Constants (1)

pathToPosition

Code Graph: Dependencies (6)

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

Full Source

WallClimberNavigation.java61 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.ai.navigation;
2
3
import net.minecraft.core.BlockPos;
4
import net.minecraft.world.entity.Entity;
5
import net.minecraft.world.entity.Mob;
6
import net.minecraft.world.level.Level;
7
import net.minecraft.world.level.pathfinder.Path;
8
import org.jspecify.annotations.Nullable;
9
10
public class WallClimberNavigation extends GroundPathNavigation {
11
	private @Nullable BlockPos pathToPosition;
12
13
	public WallClimberNavigation(final Mob mob, final Level level) {
14
		super(mob, level);
15
	}
16
17
	@Override
18
	public Path createPath(final BlockPos pos, final int reachRange) {
19
		this.pathToPosition = pos;
20
		return super.createPath(pos, reachRange);
21
	}
22
23
	@Override
24
	public Path createPath(final Entity target, final int reachRange) {
25
		this.pathToPosition = target.blockPosition();
26
		return super.createPath(target, reachRange);
27
	}
28
29
	@Override
30
	public boolean moveTo(final Entity target, final double speedModifier) {
31
		Path newPath = this.createPath(target, 0);
32
		if (newPath != null) {
33
			return this.moveTo(newPath, speedModifier);
34
		}
35
36
		this.pathToPosition = target.blockPosition();
37
		this.speedModifier = speedModifier;
38
		return true;
39
	}
40
41
	@Override
42
	public void tick() {
43
		if (!this.isDone()) {
44
			super.tick();
45
		} else {
46
			if (this.pathToPosition != null) {
47
				if (!this.pathToPosition.closerToCenterThan(this.mob.position(), this.mob.getBbWidth())
48
					&& (
49
						!(this.mob.getY() > this.pathToPosition.getY())
50
							|| !BlockPos.containing(this.pathToPosition.getX(), this.mob.getY(), this.pathToPosition.getZ())
51
								.closerToCenterThan(this.mob.position(), this.mob.getBbWidth())
52
					)) {
53
					this.mob.getMoveControl().setWantedPosition(this.pathToPosition.getX(), this.pathToPosition.getY(), this.pathToPosition.getZ(), this.speedModifier);
54
				} else {
55
					this.pathToPosition = null;
56
				}
57
			}
58
		}
59
	}
60
}
61

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