LongJumpMidJump .java

net.minecraft.world.entity.ai.behavior.LongJumpMidJump (class): members: landingSound, timeBetweenLongJumps, TIME_OUT_DURATION, canStillUse, stop, start.

net.minecraft.world.entity.ai.behaviorclass45 linescommonextends Behavior<Mob>1.8 KB

API Surface (3)

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

Fields & Constants (3)

TIME_OUT_DURATION
timeBetweenLongJumps
landingSound

Full Source

LongJumpMidJump.java45 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.ai.behavior;
2
3
import com.google.common.collect.ImmutableMap;
4
import net.minecraft.server.level.ServerLevel;
5
import net.minecraft.sounds.SoundEvent;
6
import net.minecraft.sounds.SoundSource;
7
import net.minecraft.util.valueproviders.UniformInt;
8
import net.minecraft.world.entity.Mob;
9
import net.minecraft.world.entity.Pose;
10
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
11
import net.minecraft.world.entity.ai.memory.MemoryStatus;
12
13
public class LongJumpMidJump extends Behavior<Mob> {
14
	public static final int TIME_OUT_DURATION = 100;
15
	private final UniformInt timeBetweenLongJumps;
16
	private final SoundEvent landingSound;
17
18
	public LongJumpMidJump(final UniformInt timeBetweenLongJumps, final SoundEvent landingSound) {
19
		super(ImmutableMap.of(MemoryModuleType.LOOK_TARGET, MemoryStatus.REGISTERED, MemoryModuleType.LONG_JUMP_MID_JUMP, MemoryStatus.VALUE_PRESENT), 100);
20
		this.timeBetweenLongJumps = timeBetweenLongJumps;
21
		this.landingSound = landingSound;
22
	}
23
24
	protected boolean canStillUse(final ServerLevel level, final Mob body, final long timestamp) {
25
		return !body.onGround();
26
	}
27
28
	protected void start(final ServerLevel level, final Mob body, final long timestamp) {
29
		body.setDiscardFriction(true);
30
		body.setPose(Pose.LONG_JUMPING);
31
	}
32
33
	protected void stop(final ServerLevel level, final Mob body, final long timestamp) {
34
		if (body.onGround()) {
35
			body.setDeltaMovement(body.getDeltaMovement().multiply(0.1F, 1.0, 0.1F));
36
			level.playSound(null, body, this.landingSound, SoundSource.NEUTRAL, 2.0F, 1.0F);
37
		}
38
39
		body.setDiscardFriction(false);
40
		body.setPose(Pose.STANDING);
41
		body.getBrain().eraseMemory(MemoryModuleType.LONG_JUMP_MID_JUMP);
42
		body.getBrain().setMemory(MemoryModuleType.LONG_JUMP_COOLDOWN_TICKS, this.timeBetweenLongJumps.sample(level.getRandom()));
43
	}
44
}
45

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