RandomStandGoal .java

net.minecraft.world.entity.ai.goal.RandomStandGoal (class, 53 lines): members: nextStand, horse, requiresUpdateEveryTick, canContinueToUse, canUse, start.

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

API Surface (4)

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

Fields & Constants (2)

horse
nextStand

Code Graph: Dependencies (3)

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

Full Source

RandomStandGoal.java53 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.ai.goal;
2
3
import net.minecraft.sounds.SoundEvent;
4
import net.minecraft.world.entity.animal.equine.AbstractHorse;
5
6
public class RandomStandGoal extends Goal {
7
	private final AbstractHorse horse;
8
	private int nextStand;
9
10
	public RandomStandGoal(final AbstractHorse horse) {
11
		this.horse = horse;
12
		this.resetStandInterval(horse);
13
	}
14
15
	@Override
16
	public void start() {
17
		this.horse.standIfPossible();
18
		this.playStandSound();
19
	}
20
21
	private void playStandSound() {
22
		SoundEvent ambientStandSound = this.horse.getAmbientStandSound();
23
		if (ambientStandSound != null) {
24
			this.horse.playSound(ambientStandSound);
25
		}
26
	}
27
28
	@Override
29
	public boolean canContinueToUse() {
30
		return false;
31
	}
32
33
	@Override
34
	public boolean canUse() {
35
		this.nextStand++;
36
		if (this.nextStand > 0 && this.horse.getRandom().nextInt(1000) < this.nextStand) {
37
			this.resetStandInterval(this.horse);
38
			return !this.horse.isImmobile() && this.horse.getRandom().nextInt(10) == 0;
39
		} else {
40
			return false;
41
		}
42
	}
43
44
	private void resetStandInterval(final AbstractHorse horse) {
45
		this.nextStand = -horse.getAmbientStandInterval();
46
	}
47
48
	@Override
49
	public boolean requiresUpdateEveryTick() {
50
		return true;
51
	}
52
}
53

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