FloatGoal .java

net.minecraft.world.entity.ai.goal.FloatGoal (class): members: fluid, requiresUpdateEveryTick, mob, canUse, tick. imports: Fluid, FluidTags, TagKey, Mob.

net.minecraft.world.entity.ai.goalclass41 linescommonextends Goal956 B

API Surface (3)

boolean canUse()
boolean requiresUpdateEveryTick()
void tick()

Fields & Constants (2)

mob
fluid

Code Graph: Dependencies (5)

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

Full Source

FloatGoal.java41 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.ai.goal;
2
3
import java.util.EnumSet;
4
import net.minecraft.tags.FluidTags;
5
import net.minecraft.tags.TagKey;
6
import net.minecraft.world.entity.Mob;
7
import net.minecraft.world.level.material.Fluid;
8
9
public class FloatGoal extends Goal {
10
	private final Mob mob;
11
	protected final TagKey<Fluid> fluid;
12
13
	public FloatGoal(final Mob mob) {
14
		this(mob, FluidTags.ENTITY_FLOATABLE);
15
	}
16
17
	public FloatGoal(final Mob mob, final TagKey<Fluid> fluid) {
18
		this.mob = mob;
19
		this.fluid = fluid;
20
		this.setFlags(EnumSet.of(Goal.Flag.JUMP));
21
		mob.getNavigation().setCanFloat(true);
22
	}
23
24
	@Override
25
	public boolean canUse() {
26
		return this.mob.isInFluidDeeperThan(this.mob.getFluidJumpThreshold(), this.fluid) || this.mob.isInLava();
27
	}
28
29
	@Override
30
	public boolean requiresUpdateEveryTick() {
31
		return true;
32
	}
33
34
	@Override
35
	public void tick() {
36
		if (this.mob.getRandom().nextFloat() < 0.8F) {
37
			this.mob.getJumpControl().jump();
38
		}
39
	}
40
}
41

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