CatLieOnBlockGoal .java

net.minecraft.world.entity.ai.goal.CatLieOnBlockGoal (class): members: cat, nextStartTick, isValidTarget, canUse, stop, start, tick. imports: Cat.

net.minecraft.world.entity.ai.goalclass58 linescommonextends MoveToBlockGoal1.4 KB

API Surface (6)

boolean canUse()
void start()
int nextStartTick(final PathfinderMob mob)
void stop()
void tick()
boolean isValidTarget(final LevelReader level, final BlockPos pos)

Fields & Constants (1)

cat

Code Graph: Dependencies (6)

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

Full Source

CatLieOnBlockGoal.java58 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.ai.goal;
2
3
import java.util.EnumSet;
4
import net.minecraft.core.BlockPos;
5
import net.minecraft.tags.BlockTags;
6
import net.minecraft.world.entity.PathfinderMob;
7
import net.minecraft.world.entity.animal.feline.Cat;
8
import net.minecraft.world.level.LevelReader;
9
10
public class CatLieOnBlockGoal extends MoveToBlockGoal {
11
	private final Cat cat;
12
13
	public CatLieOnBlockGoal(final Cat cat, final double speedModifier, final int searchRange) {
14
		super(cat, speedModifier, searchRange, 6);
15
		this.cat = cat;
16
		this.verticalSearchStart = -2;
17
		this.setFlags(EnumSet.of(Goal.Flag.JUMP, Goal.Flag.MOVE));
18
	}
19
20
	@Override
21
	public boolean canUse() {
22
		return this.cat.isTame() && !this.cat.isOrderedToSit() && !this.cat.isLying() && super.canUse();
23
	}
24
25
	@Override
26
	public void start() {
27
		super.start();
28
		this.cat.setInSittingPose(false);
29
	}
30
31
	@Override
32
	protected int nextStartTick(final PathfinderMob mob) {
33
		return 40;
34
	}
35
36
	@Override
37
	public void stop() {
38
		super.stop();
39
		this.cat.setLying(false);
40
	}
41
42
	@Override
43
	public void tick() {
44
		super.tick();
45
		this.cat.setInSittingPose(false);
46
		if (!this.isReachedTarget()) {
47
			this.cat.setLying(false);
48
		} else if (!this.cat.isLying()) {
49
			this.cat.setLying(true);
50
		}
51
	}
52
53
	@Override
54
	protected boolean isValidTarget(final LevelReader level, final BlockPos pos) {
55
		return level.isEmptyBlock(pos.above()) && level.getBlockState(pos).is(BlockTags.CATS_CAN_LIE_ON);
56
	}
57
}
58

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