Try to use a custom elytra for an entity.
A custom elytra is anything that allows an entity to enter and continue elytra flight when some condition is met.
Listeners should follow the following pattern:
EntityElytraEvents.CUSTOM.register((entity, tickElytra) -> {
if (check if condition for custom elytra is met) {
if (tickElytra) {
// Optionally consume some resources that are being used up in order to fly, for example damaging an item.
// Optionally perform other side effects of elytra flight, for example playing a sound.
}
// Allow entering/continuing elytra flight with this custom elytra
return true;
}
// Condition for the custom elytra is not met: don't let players enter or continue elytra flight (unless another elytra is available).
return false;
});
Parameters:
entity - the entity
tickElytra - false if this is just to check if the custom elytra can be used, true if the custom elytra should also be ticked, i.e. perform side-effects of flying such as using resources.
Returns:
true to use a custom elytra, enabling elytra flight for the entity and cancelling subsequent handlers