LandOnOwnersShoulderGoal .java

net.minecraft.world.entity.ai.goal.LandOnOwnersShoulderGoal (class, 43 lines): members: isSittingOnShoulder, isInterruptable, entity, canUse, start, tick.

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

API Surface (4)

boolean canUse()
boolean isInterruptable()
void start()
void tick()

Fields & Constants (2)

entity
isSittingOnShoulder

Code Graph: Dependencies (3)

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

Full Source

LandOnOwnersShoulderGoal.java43 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.ai.goal;
2
3
import net.minecraft.server.level.ServerPlayer;
4
import net.minecraft.world.entity.animal.parrot.ShoulderRidingEntity;
5
6
public class LandOnOwnersShoulderGoal extends Goal {
7
	private final ShoulderRidingEntity entity;
8
	private boolean isSittingOnShoulder;
9
10
	public LandOnOwnersShoulderGoal(final ShoulderRidingEntity entity) {
11
		this.entity = entity;
12
	}
13
14
	@Override
15
	public boolean canUse() {
16
		if (!(this.entity.getOwner() instanceof ServerPlayer owner)) {
17
			return false;
18
		} else {
19
			boolean ownerThatCanBeSatOn = !owner.isSpectator() && !owner.getAbilities().flying && !owner.isInWater() && !owner.isInPowderSnow;
20
			return !this.entity.isOrderedToSit() && ownerThatCanBeSatOn && this.entity.canSitOnShoulder();
21
		}
22
	}
23
24
	@Override
25
	public boolean isInterruptable() {
26
		return !this.isSittingOnShoulder;
27
	}
28
29
	@Override
30
	public void start() {
31
		this.isSittingOnShoulder = false;
32
	}
33
34
	@Override
35
	public void tick() {
36
		if (!this.isSittingOnShoulder && !this.entity.isInSittingPose() && !this.entity.isLeashed()) {
37
			if (this.entity.getOwner() instanceof ServerPlayer owner && this.entity.getBoundingBox().intersects(owner.getBoundingBox())) {
38
				this.isSittingOnShoulder = this.entity.setEntityOnShoulder(owner);
39
			}
40
		}
41
	}
42
}
43

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