Start with the elytra implementation

This commit is contained in:
R0bbyYT 2021-05-14 18:35:09 +02:00
parent 6a712b33a0
commit 34d428be10
3 changed files with 29 additions and 4 deletions

View File

@ -595,6 +595,14 @@ public class LivingEntity extends Entity implements EquipmentHandler {
}
}
public boolean isFlyingWithElytra() {
return this.entityMeta.isFlyingWithElytra();
}
public void setFlyingWithElytra(boolean isFlying) {
this.entityMeta.setFlyingWithElytra(isFlying);
}
/**
* Used to change the {@code isDead} internal field.
*

View File

@ -0,0 +1,12 @@
package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.PlayerEvent;
import org.jetbrains.annotations.NotNull;
public class PlayerStartFlyingWithElytraEvent extends PlayerEvent {
public PlayerStartFlyingWithElytraEvent(@NotNull Player player) {
super(player);
}
}

View File

@ -1,10 +1,7 @@
package net.minestom.server.listener;
import net.minestom.server.entity.Player;
import net.minestom.server.event.player.PlayerStartSneakingEvent;
import net.minestom.server.event.player.PlayerStartSprintingEvent;
import net.minestom.server.event.player.PlayerStopSneakingEvent;
import net.minestom.server.event.player.PlayerStopSprintingEvent;
import net.minestom.server.event.player.*;
import net.minestom.server.network.packet.client.play.ClientEntityActionPacket;
public class EntityActionListener {
@ -24,6 +21,9 @@ public class EntityActionListener {
case STOP_SPRINTING:
EntityActionListener.setSprinting(player, false);
break;
case START_FLYING_ELYTRA:
EntityActionListener.startFlyingElytra(player);
break;
// TODO do remaining actions
}
}
@ -55,4 +55,9 @@ public class EntityActionListener {
}
}
}
private static void startFlyingElytra(Player player) {
player.setFlyingWithElytra(true);
player.callEvent(PlayerStartFlyingWithElytraEvent.class, new PlayerStartFlyingWithElytraEvent(player));
}
}