So I am looking for some input on this as some of it may not be fit to be in Sponge outside of the check to see if someone is flying with an elytra.
Essentially I would like to add ElytraFlyingData to the SpongeAPI, which allows you to not only check if a player is flying with an elytra, but also force them to start flying with an elytra and allow them to fly like they are using an elytra without one actually on. Some of this is not exactly the smoothest implementation in SpongeCommon(SV/SF), with some slightly weird changes to Minecraft.
The main API this PR would add would be a way to check if a player is currently elytra flying, but it would also be possible to force them to start elytra flying or stop them from elytra flying by offering the relevant value. Due to this ability to force players to elytra fly, a sort of elytra capability is needed to control the check if a player can actually elytra fly.
A large part of this would be a player's "elytra capability" which would essentially be an enum that is accessible from a player's ElytraFlyingData which represents the various ways a player could elytra fly, whether that's disabled(even with elytra), enabled(even without elytra), or normal requiring an item with a true ElytraFlyingProperty(which in Vanilla is only the Elytra). One thing that must be recognized, is that a player cannot activate elytra flying themselves if they are not wearing one or some other item with the property not registered locally through Forge as an elytra item(would need to finish this PR in some fashion though first). As a whole the API would look something like this:
ElytraCapability.java
/**
* Represents the possible capabilities a player can have relating to
* elytra flying.
*/
public enum ElytraCapability {
/**
* Requires an item with a true {@link ElytraFlyingProperty} to be
* worn in the chest slot.
*/
EQUIPMENT,
/**
* Allows a player to fly like they are wearing an elytra item
* without actually wearing one.
*/
ENABLED,
/**
* Does not allow a player to fly like they are wearing an elytra
* item, even if they are.
*/
DISABLED
}
ElytraFlyingProperty.java
/**
* Represents the property which shows whether or not an item works
* as an elytra for flying.
*/
public class ElytraFlyingProperty extends BooleanProperty {
/**
* Creates a new {@link ElytraFlyingProperty} with the provided boolean value.
*
* @param value The value
*/
public ElytraFlyingProperty(boolean value) {
super(value);
}
/**
* Creates a new {@link ElytraFlyingProperty} with the provided boolean value
* and {@link Operator} comparison operator.
*
* @param value The value
* @param operator The operator for comparisons
*/
public ElytraFlyingProperty(boolean value, Operator operator) {
super(value, operator);
}
}
ElytraFlyingData.java
/**
* A {@link DataManipulator} for manipulating a living entity,
* generally a {@link Player}'s ability to fly with an elytra.
*/
public interface ElytraFlyingData extends DataManipulator<ElytraFlyingData, ImmutableElytraFlyingData> {
/**
* Gets the {@link Value} for the elytra flying
* capabilities of a player.
*
* @return The value for the player's elytra capabilities.
* @see Keys#ELYTRA_CAPABILITY
*/
Value<ElytraCapability> elytraCapability();
/**
* Gets the {@link Value} for if the player is flying
* with an elytra.
*
* @return The value for the elytra flying state
* @see Keys#IS_ELYTRA_FLYING
*/
Value<Boolean> elytraFlying();
}
Keys.java
/**
* An enumeration of known {@link Key}s used throughout the API.
*/
public final class Keys {
/**
* Represents the ability of a {@link Player} to utilize elytra style
* flying being either disabled, enabled, or requiring an elytra.
*
* @see ElytraFlyingData#elytraCapability()
*/
public static final Key<Value<ElytraCapability>> ELYTRA_CAPABILITY = KeyFactory.fake("ELYTRA_CAPABILITY");
/**
* Represents the {@link Key} for whether a {@link Player} is currently
* flying with an elytra.
*
* <p>Offering this to a player will only work properly if they
* are currently wearing an elytra.</p>
*
* @see ElytraFlyingData#elytraFlying()
*/
public static final Key<Value<Boolean>> IS_ELYTRA_FLYING = KeyFactory.fake("IS_ELYTRA_FLYING");
Some of this implementation won't be the cleanest, but I can see the use of these changes. If nothing else, I'd just like to implement Keys.IS_ELYTRA_FLYING in ElytraFlyingData, but I do think discussion on these other changes are useful, especially since other implementations of Sponge(Lantern) could make even better use of the API.
I am also open to other data related to elytra if you can think of them(that would be reasonable to implement), but this is what has come to mind so far. I'm also open to other additions, such as a method in the player(?) class that simulates the boost a firework provides while flying an elytra.
Often stated in Sponge's history is the idea of exposing possibilities/capabilities in the API that would have previously required NMS or modifying MC's code manually in the plugin, as to be implementation independent. So please keep an open mind, because I do think some plugins could accomplish some cool stuff with this functionality.
So I am looking for some input on this as some of it may not be fit to be in Sponge outside of the check to see if someone is flying with an elytra.
Essentially I would like to add
ElytraFlyingDatato the SpongeAPI, which allows you to not only check if a player is flying with an elytra, but also force them to start flying with an elytra and allow them to fly like they are using an elytra without one actually on. Some of this is not exactly the smoothest implementation in SpongeCommon(SV/SF), with some slightly weird changes to Minecraft.The main API this PR would add would be a way to check if a player is currently elytra flying, but it would also be possible to force them to start elytra flying or stop them from elytra flying by offering the relevant value. Due to this ability to force players to elytra fly, a sort of elytra capability is needed to control the check if a player can actually elytra fly.
A large part of this would be a player's "elytra capability" which would essentially be an enum that is accessible from a player's
ElytraFlyingDatawhich represents the various ways a player could elytra fly, whether that's disabled(even with elytra), enabled(even without elytra), or normal requiring an item with a trueElytraFlyingProperty(which in Vanilla is only the Elytra). One thing that must be recognized, is that a player cannot activate elytra flying themselves if they are not wearing one or some other item with the property not registered locally through Forge as an elytra item(would need to finish this PR in some fashion though first). As a whole the API would look something like this:ElytraCapability.java
ElytraFlyingProperty.java
ElytraFlyingData.java
Keys.java
Some of this implementation won't be the cleanest, but I can see the use of these changes. If nothing else, I'd just like to implement
Keys.IS_ELYTRA_FLYINGinElytraFlyingData, but I do think discussion on these other changes are useful, especially since other implementations of Sponge(Lantern) could make even better use of the API.I am also open to other data related to elytra if you can think of them(that would be reasonable to implement), but this is what has come to mind so far. I'm also open to other additions, such as a method in the player(?) class that simulates the boost a firework provides while flying an elytra.
Often stated in Sponge's history is the idea of exposing possibilities/capabilities in the API that would have previously required NMS or modifying MC's code manually in the plugin, as to be implementation independent. So please keep an open mind, because I do think some plugins could accomplish some cool stuff with this functionality.