ShoulderRidingEntity .java

net.minecraft.world.entity.animal.parrot.ShoulderRidingEntity (class, 45 lines): members: rideCooldownCounter, canSitOnShoulder, RIDE_COOLDOWN, tick.

net.minecraft.world.entity.animal.parrotclass45 linescommonextends TamableAnimal1.4 KB

API Surface (3)

boolean setEntityOnShoulder(final ServerPlayer player)
void tick()
boolean canSitOnShoulder()

Fields & Constants (3)

LOGGER
RIDE_COOLDOWN
rideCooldownCounter

Same Package (2)

Code Graph: Dependencies (6)

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

Full Source

ShoulderRidingEntity.java45 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.animal.parrot;
2
3
import com.mojang.logging.LogUtils;
4
import net.minecraft.server.level.ServerPlayer;
5
import net.minecraft.util.ProblemReporter;
6
import net.minecraft.world.entity.EntityType;
7
import net.minecraft.world.entity.TamableAnimal;
8
import net.minecraft.world.level.Level;
9
import net.minecraft.world.level.storage.TagValueOutput;
10
import org.slf4j.Logger;
11
12
public abstract class ShoulderRidingEntity extends TamableAnimal {
13
	private static final Logger LOGGER = LogUtils.getLogger();
14
	private static final int RIDE_COOLDOWN = 100;
15
	private int rideCooldownCounter;
16
17
	protected ShoulderRidingEntity(final EntityType<? extends ShoulderRidingEntity> type, final Level level) {
18
		super(type, level);
19
	}
20
21
	public boolean setEntityOnShoulder(final ServerPlayer player) {
22
		try (ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(this.problemPath(), LOGGER)) {
23
			TagValueOutput output = TagValueOutput.createWithContext(reporter, this.registryAccess());
24
			this.saveWithoutId(output);
25
			output.putString("id", this.getEncodeId());
26
			if (player.setEntityOnShoulder(output.buildResult())) {
27
				this.discard();
28
				return true;
29
			}
30
		}
31
32
		return false;
33
	}
34
35
	@Override
36
	public void tick() {
37
		this.rideCooldownCounter++;
38
		super.tick();
39
	}
40
41
	public boolean canSitOnShoulder() {
42
		return this.rideCooldownCounter > 100;
43
	}
44
}
45

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