MoveTowardsRestrictionGoal .java

net.minecraft.world.entity.ai.goal.MoveTowardsRestrictionGoal (class): members: wantedX, wantedY, wantedZ, speedModifier, canContinueToUse, mob, canUse.

net.minecraft.world.entity.ai.goalclass48 linescommonextends Goal1.2 KB

API Surface (3)

boolean canUse()
boolean canContinueToUse()
void start()

Fields & Constants (5)

mob
wantedX
wantedY
wantedZ
speedModifier

Code Graph: Dependencies (4)

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

Full Source

MoveTowardsRestrictionGoal.java48 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.ai.goal;
2
3
import java.util.EnumSet;
4
import net.minecraft.world.entity.PathfinderMob;
5
import net.minecraft.world.entity.ai.util.DefaultRandomPos;
6
import net.minecraft.world.phys.Vec3;
7
8
public class MoveTowardsRestrictionGoal extends Goal {
9
	private final PathfinderMob mob;
10
	private double wantedX;
11
	private double wantedY;
12
	private double wantedZ;
13
	private final double speedModifier;
14
15
	public MoveTowardsRestrictionGoal(final PathfinderMob mob, final double moveSpeedModifier) {
16
		this.mob = mob;
17
		this.speedModifier = moveSpeedModifier;
18
		this.setFlags(EnumSet.of(Goal.Flag.MOVE));
19
	}
20
21
	@Override
22
	public boolean canUse() {
23
		if (this.mob.isWithinHome()) {
24
			return false;
25
		}
26
27
		Vec3 pos = DefaultRandomPos.getPosTowards(this.mob, 16, 7, Vec3.atBottomCenterOf(this.mob.getHomePosition()), (float) (Math.PI / 2));
28
		if (pos == null) {
29
			return false;
30
		}
31
32
		this.wantedX = pos.x;
33
		this.wantedY = pos.y;
34
		this.wantedZ = pos.z;
35
		return true;
36
	}
37
38
	@Override
39
	public boolean canContinueToUse() {
40
		return !this.mob.getNavigation().isDone();
41
	}
42
43
	@Override
44
	public void start() {
45
		this.mob.getNavigation().moveTo(this.wantedX, this.wantedY, this.wantedZ, this.speedModifier);
46
	}
47
}
48

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