Digging .java

net.minecraft.world.entity.ai.behavior.warden.Digging (class): members: checkExtraStartConditions, canStillUse, stop, start. imports: Warden, Behavior.

net.minecraft.world.entity.ai.behavior.wardenclass42 linescommonextends Warden>1.5 KB

API Surface (4)

boolean canStillUse(final ServerLevel level, final E body, final long timestamp)
boolean checkExtraStartConditions(final ServerLevel level, final E body)
void start(final ServerLevel level, final E body, final long timestamp)
void stop(final ServerLevel level, final E body, final long timestamp)

Code Graph: Dependencies (8)

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

Full Source

Digging.java42 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.ai.behavior.warden;
2
3
import com.google.common.collect.ImmutableMap;
4
import net.minecraft.server.level.ServerLevel;
5
import net.minecraft.sounds.SoundEvents;
6
import net.minecraft.world.entity.Entity;
7
import net.minecraft.world.entity.Pose;
8
import net.minecraft.world.entity.ai.behavior.Behavior;
9
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
10
import net.minecraft.world.entity.ai.memory.MemoryStatus;
11
import net.minecraft.world.entity.monster.warden.Warden;
12
13
public class Digging<E extends Warden> extends Behavior<E> {
14
	public Digging(final int ticks) {
15
		super(ImmutableMap.of(MemoryModuleType.ATTACK_TARGET, MemoryStatus.VALUE_ABSENT, MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT), ticks);
16
	}
17
18
	protected boolean canStillUse(final ServerLevel level, final E body, final long timestamp) {
19
		return body.getRemovalReason() == null;
20
	}
21
22
	protected boolean checkExtraStartConditions(final ServerLevel level, final E body) {
23
		return body.onGround() || body.isInLiquid();
24
	}
25
26
	protected void start(final ServerLevel level, final E body, final long timestamp) {
27
		if (body.onGround()) {
28
			body.setPose(Pose.DIGGING);
29
			body.playSound(SoundEvents.WARDEN_DIG, 5.0F, 1.0F);
30
		} else {
31
			body.playSound(SoundEvents.WARDEN_AGITATED, 5.0F, 1.0F);
32
			this.stop(level, body, timestamp);
33
		}
34
	}
35
36
	protected void stop(final ServerLevel level, final E body, final long timestamp) {
37
		if (body.getRemovalReason() == null) {
38
			body.remove(Entity.RemovalReason.DISCARDED);
39
		}
40
	}
41
}
42

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