DragonLandingPhase .java

net.minecraft.world.entity.boss.enderdragon.phases.DragonLandingPhase (class): members: getTurnSpeed, doClientTick, getFlySpeed, targetLocation, begin.

net.minecraft.world.entity.boss.enderdragon.phasesclass90 linescommonextends AbstractDragonPhaseInstance2.6 KB

API Surface (6)

void doClientTick()
void doServerTick(final ServerLevel level)
float getFlySpeed()
float getTurnSpeed()
void begin()
EnderDragonPhase<DragonLandingPhase> getPhase()

Fields & Constants (1)

targetLocation

Full Source

DragonLandingPhase.java90 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.boss.enderdragon.phases;
2
3
import net.minecraft.core.particles.ParticleTypes;
4
import net.minecraft.core.particles.PowerParticleOption;
5
import net.minecraft.server.level.ServerLevel;
6
import net.minecraft.util.RandomSource;
7
import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
8
import net.minecraft.world.level.dimension.end.EnderDragonFight;
9
import net.minecraft.world.level.levelgen.Heightmap;
10
import net.minecraft.world.phys.Vec3;
11
import org.jspecify.annotations.Nullable;
12
13
public class DragonLandingPhase extends AbstractDragonPhaseInstance {
14
	private @Nullable Vec3 targetLocation;
15
16
	public DragonLandingPhase(final EnderDragon dragon) {
17
		super(dragon);
18
	}
19
20
	@Override
21
	public void doClientTick() {
22
		Vec3 look = this.dragon.getHeadLookVector(1.0F).normalize();
23
		look.yRot((float) (-Math.PI / 4));
24
		double particleX = this.dragon.head.getX();
25
		double particleY = this.dragon.head.getY(0.5);
26
		double particleZ = this.dragon.head.getZ();
27
28
		for (int i = 0; i < 8; i++) {
29
			RandomSource random = this.dragon.getRandom();
30
			double px = particleX + random.nextGaussian() / 2.0;
31
			double py = particleY + random.nextGaussian() / 2.0;
32
			double pz = particleZ + random.nextGaussian() / 2.0;
33
			Vec3 movement = this.dragon.getDeltaMovement();
34
			this.dragon
35
				.level()
36
				.addParticle(
37
					PowerParticleOption.create(ParticleTypes.DRAGON_BREATH, 1.0F),
38
					px,
39
					py,
40
					pz,
41
					-look.x * 0.08F + movement.x,
42
					-look.y * 0.3F + movement.y,
43
					-look.z * 0.08F + movement.z
44
				);
45
			look.yRot((float) (Math.PI / 16));
46
		}
47
	}
48
49
	@Override
50
	public void doServerTick(final ServerLevel level) {
51
		if (this.targetLocation == null) {
52
			this.targetLocation = Vec3.atBottomCenterOf(
53
				level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EnderDragonFight.getPodiumLocation(this.dragon.getFightOrigin()))
54
			);
55
		}
56
57
		if (this.targetLocation.distanceToSqr(this.dragon.getX(), this.dragon.getY(), this.dragon.getZ()) < 1.0) {
58
			this.dragon.getPhaseManager().getPhase(EnderDragonPhase.SITTING_FLAMING).resetFlameCount();
59
			this.dragon.getPhaseManager().setPhase(EnderDragonPhase.SITTING_SCANNING);
60
		}
61
	}
62
63
	@Override
64
	public float getFlySpeed() {
65
		return 1.5F;
66
	}
67
68
	@Override
69
	public float getTurnSpeed() {
70
		float rotSpeed = (float)this.dragon.getDeltaMovement().horizontalDistance() + 1.0F;
71
		float dist = Math.min(rotSpeed, 40.0F);
72
		return dist / rotSpeed;
73
	}
74
75
	@Override
76
	public void begin() {
77
		this.targetLocation = null;
78
	}
79
80
	@Override
81
	public @Nullable Vec3 getFlyTargetLocation() {
82
		return this.targetLocation;
83
	}
84
85
	@Override
86
	public EnderDragonPhase<DragonLandingPhase> getPhase() {
87
		return EnderDragonPhase.LANDING;
88
	}
89
}
90

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