fix: launch player in air with gliding enabled for ElytraMode
This commit is contained in:
parent
0ce5ac97f2
commit
e4a476e3be
1 changed files with 20 additions and 4 deletions
|
|
@ -55,20 +55,36 @@ public class ElytraGenerator extends ParkourGenerator implements Listener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateFirst(Location spawn, Location blockSpawn) {
|
public void generateFirst(Location spawn, Location blockSpawn) {
|
||||||
// Generate initial rings
|
// Generate initial rings starting from spawn position
|
||||||
Vector initialDirection = new Vector(1, 0, 0); // East direction
|
Vector initialDirection = new Vector(1, 0, 0); // East direction
|
||||||
List<ElytraRing> initialRings = ringGenerator.generateRings(spawn, initialDirection, config.getRingLead());
|
List<ElytraRing> initialRings = ringGenerator.generateRings(spawn, initialDirection, config.getRingLead());
|
||||||
rings.addAll(initialRings);
|
rings.addAll(initialRings);
|
||||||
|
|
||||||
// Initialize player data
|
// Initialize player data and launch them
|
||||||
for (ParkourPlayer player : getPlayers()) {
|
for (ParkourPlayer player : getPlayers()) {
|
||||||
playerRingIndex.put(player, 0);
|
playerRingIndex.put(player, 0);
|
||||||
giveElytraAndFireworks(player);
|
giveElytraAndFireworks(player);
|
||||||
|
launchPlayer(player, spawn);
|
||||||
}
|
}
|
||||||
|
|
||||||
startTasks();
|
startTasks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void launchPlayer(@NotNull ParkourPlayer player, @NotNull Location spawn) {
|
||||||
|
Player p = player.player;
|
||||||
|
|
||||||
|
// Teleport player above spawn (10 blocks up)
|
||||||
|
Location launchPos = spawn.clone().add(0, 10, 0);
|
||||||
|
p.teleport(launchPos);
|
||||||
|
|
||||||
|
// Enable gliding
|
||||||
|
p.setGliding(true);
|
||||||
|
|
||||||
|
// Give initial forward velocity
|
||||||
|
Vector velocity = new Vector(1, 0, 0).normalize().multiply(1.5);
|
||||||
|
p.setVelocity(velocity);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue