WaterAvoidingRandomStrollGoal .java

net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal (class): members: PROBABILITY, getPosition, probability. imports: LandRandomPos, Vec3.

net.minecraft.world.entity.ai.goalclass31 linescommonextends RandomStrollGoal1.0 KB

API Surface (0)

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

Fields & Constants (2)

PROBABILITY
probability

Code Graph: Dependencies (4)

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

Full Source

WaterAvoidingRandomStrollGoal.java31 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.ai.goal;
2
3
import net.minecraft.world.entity.PathfinderMob;
4
import net.minecraft.world.entity.ai.util.LandRandomPos;
5
import net.minecraft.world.phys.Vec3;
6
import org.jspecify.annotations.Nullable;
7
8
public class WaterAvoidingRandomStrollGoal extends RandomStrollGoal {
9
	public static final float PROBABILITY = 0.001F;
10
	protected final float probability;
11
12
	public WaterAvoidingRandomStrollGoal(final PathfinderMob mob, final double speedModifier) {
13
		this(mob, speedModifier, 0.001F);
14
	}
15
16
	public WaterAvoidingRandomStrollGoal(final PathfinderMob mob, final double speedModifier, final float probability) {
17
		super(mob, speedModifier);
18
		this.probability = probability;
19
	}
20
21
	@Override
22
	protected @Nullable Vec3 getPosition() {
23
		if (this.mob.isInWater()) {
24
			Vec3 pos = LandRandomPos.getPos(this.mob, 15, 7);
25
			return pos == null ? super.getPosition() : pos;
26
		} else {
27
			return this.mob.getRandom().nextFloat() >= this.probability ? LandRandomPos.getPos(this.mob, 10, 7) : super.getPosition();
28
		}
29
	}
30
}
31

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