DragonChargePlayerPhase .java

net.minecraft.world.entity.boss.enderdragon.phases.DragonChargePlayerPhase (class): members: CHARGE_RECOVERY_TIME, timeSinceCharge, getFlySpeed, setTarget.

net.minecraft.world.entity.boss.enderdragon.phasesclass60 linescommonextends AbstractDragonPhaseInstance1.8 KB

API Surface (5)

void doServerTick(final ServerLevel level)
void begin()
void setTarget(final Vec3 target)
float getFlySpeed()
EnderDragonPhase<DragonChargePlayerPhase> getPhase()

Fields & Constants (4)

LOGGER
CHARGE_RECOVERY_TIME
targetLocation
timeSinceCharge

String literals (1)

"Aborting charge player as no target was set."

Code Graph: Dependencies (5)

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

Full Source

DragonChargePlayerPhase.java60 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.boss.enderdragon.phases;
2
3
import com.mojang.logging.LogUtils;
4
import net.minecraft.server.level.ServerLevel;
5
import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
6
import net.minecraft.world.phys.Vec3;
7
import org.jspecify.annotations.Nullable;
8
import org.slf4j.Logger;
9
10
public class DragonChargePlayerPhase extends AbstractDragonPhaseInstance {
11
	private static final Logger LOGGER = LogUtils.getLogger();
12
	private static final int CHARGE_RECOVERY_TIME = 10;
13
	private @Nullable Vec3 targetLocation;
14
	private int timeSinceCharge;
15
16
	public DragonChargePlayerPhase(final EnderDragon dragon) {
17
		super(dragon);
18
	}
19
20
	@Override
21
	public void doServerTick(final ServerLevel level) {
22
		if (this.targetLocation == null) {
23
			LOGGER.warn("Aborting charge player as no target was set.");
24
			this.dragon.getPhaseManager().setPhase(EnderDragonPhase.HOLDING_PATTERN);
25
		} else if (this.timeSinceCharge > 0 && this.timeSinceCharge++ >= 10) {
26
			this.dragon.getPhaseManager().setPhase(EnderDragonPhase.HOLDING_PATTERN);
27
		} else {
28
			double distToTarget = this.targetLocation.distanceToSqr(this.dragon.getX(), this.dragon.getY(), this.dragon.getZ());
29
			if (distToTarget < 100.0 || distToTarget > 22500.0 || this.dragon.horizontalCollision || this.dragon.verticalCollision) {
30
				this.timeSinceCharge++;
31
			}
32
		}
33
	}
34
35
	@Override
36
	public void begin() {
37
		this.targetLocation = null;
38
		this.timeSinceCharge = 0;
39
	}
40
41
	public void setTarget(final Vec3 target) {
42
		this.targetLocation = target;
43
	}
44
45
	@Override
46
	public float getFlySpeed() {
47
		return 3.0F;
48
	}
49
50
	@Override
51
	public @Nullable Vec3 getFlyTargetLocation() {
52
		return this.targetLocation;
53
	}
54
55
	@Override
56
	public EnderDragonPhase<DragonChargePlayerPhase> getPhase() {
57
		return EnderDragonPhase.CHARGING_PLAYER;
58
	}
59
}
60

Decompiled Minecraft 26.3 source of DragonChargePlayerPhase (net/minecraft/world/entity/boss/enderdragon/phases/DragonChargePlayerPhase.java) with Mojang official mappings, stored verbatim on the site.