HoverRandomPos .java

net.minecraft.world.entity.ai.util.HoverRandomPos (class): members: hoverMaxHeight, maxXzRadiansDifference, horizontalDist, xDir, zDir, verticalDist, mob.

net.minecraft.world.entity.ai.utilclass43 linescommon1.3 KB

API Surface (0)

No public/protected methods detected (fields or constants only).

Fields & Constants (7)

mob
horizontalDist
verticalDist
xDir
zDir
maxXzRadiansDifference
hoverMaxHeight

Code Graph: Dependencies (6)

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

Full Source

HoverRandomPos.java43 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.ai.util;
2
3
import net.minecraft.core.BlockPos;
4
import net.minecraft.world.entity.PathfinderMob;
5
import net.minecraft.world.phys.Vec3;
6
import org.jspecify.annotations.Nullable;
7
8
public class HoverRandomPos {
9
	public static @Nullable Vec3 getPos(
10
		final PathfinderMob mob,
11
		final int horizontalDist,
12
		final int verticalDist,
13
		final double xDir,
14
		final double zDir,
15
		final float maxXzRadiansDifference,
16
		final int hoverMaxHeight,
17
		final int hoverMinHeight
18
	) {
19
		boolean restrict = GoalUtils.mobRestricted(mob, horizontalDist);
20
		return RandomPos.generateRandomPos(
21
			mob,
22
			() -> {
23
				BlockPos direction = RandomPos.generateRandomDirectionWithinRadians(
24
					mob.getRandom(), 0.0, horizontalDist, verticalDist, 0, xDir, zDir, maxXzRadiansDifference
25
				);
26
				if (direction == null) {
27
					return null;
28
				}
29
30
				BlockPos pos = LandRandomPos.generateRandomPosTowardDirection(mob, horizontalDist, restrict, direction);
31
				if (pos == null) {
32
					return null;
33
				}
34
35
				pos = RandomPos.moveUpToAboveSolid(
36
					pos, mob.getRandom().nextInt(hoverMaxHeight - hoverMinHeight + 1) + hoverMinHeight, mob.level().getMaxY(), blockPos -> GoalUtils.isSolid(mob, blockPos)
37
				);
38
				return !GoalUtils.isWater(mob, pos) && !GoalUtils.hasMalus(mob, pos) ? pos : null;
39
			}
40
		);
41
	}
42
}
43

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