Adding Flight Modes - endorh/aerobatic-elytra GitHub Wiki

Adding a flight mode requires you to write a mod. If you don't have experience programming in Java or Kotlin, you may want to learn that first. If you don't have experience writing Forge mods, you may also want to learn how to get started.

It is possible to add additional flight modes to the Aerobatic Elytra by compiling a mod against this one. Unfortunately, there's no separate API artifact you can compile against.

Tip

The Aerobatic Elytra Jetpack mod is an open source example mod showcasing how you may add more flight modes to the Aerobatic Elytra. It provides a jetpack and hover modes, as well as a dashing feature that can be used to avoid attacks or quickly moving around, especially in hover mode.

If you're interested in changing how one of the existing modes work, you may create a pull request, either to this repository or the Aerobatic Elytra Jetpack repository.

Note

Pull requests suggesting new modes for this mod will most likely be rejected, but the Aerobatic Elytra Jetpack mod is probably more open to new flight modes, as it's already the mod I use to add broken OP features (jetpack and dashes are always broken, hover mode is basically creative flight, if not better). However, they should loosely fit into the Jetpack theme.

Compiling against Aerobatic Elytra

To compile against Aerobatic Elytra, you'll need to add its maven repository and its artifact as dependency to your build script.

Groovy Gradle
def mcVersion = "1.19.2"
def aerobaticElytraVersion = "1.0.+"

repositories {
    maven {
        url "https://maven.pkg.github.com/endorh/aerobatic-elytra"
        name = "GitHub/endorh/aerobatic-elytra"
        content {
            // Speed up dependency resolution by declaring the only contained group
            includeGroup("endorh.aerobaticelytra")
        }
        // Needed until GitHub supports unauthenticated read access to public maven repos
        credentials {
            username = "gradle" // Not relevant
            // read:packages only GitHub token published by Endor H, or use your own token
            password = "\u0067hp_SjEzHOWgAWIKVczipKZzLPPJcCMHHd1LILfK"
        }
    }
}

dependencies {
    // Aerobatic Elytra
    implementation fg.deobf("endorh.aerobaticelytra:aerobaticelytra-$mcVersion:$aerobaticElytraVersion")
}
Kotlin DSL
val mcVersion = "1.19.2"
val aerobaticElytraVersion = "1.0.+"

repositories {
    maven("https://maven.pkg.github.com/endorh/aerobatic-elytra") {
        name = "GitHub/endorh/aerobatic-elytra"
        content {
            // Speed up dependency resolution by declaring the only contained group
            includeGroup "endorh.aerobaticelytra"
        }
        // Needed until GitHub supports unauthenticated read access to public maven repos
        credentials {
            username "gradle" // Not relevant
            // read:packages only GitHub token published by Endor H, or use your own token
            password "\u0067hp_SjEzHOWgAWIKVczipKZzLPPJcCMHHd1LILfK"
        }
    }
}

dependencies {
    // Aerobatic Elytra
    implementation(fg.deobf("endorh.aerobaticelytra:aerobaticelytra-$mcVersion:$aerobaticElytraVersion"))
}

However, you may also want to add as dependencies Flight Core (only before 1.20), Simple Config and LazuLib. The first is a core mod providing some events Forge currently lacks, useful for changing the way players move. Simple Config makes creating config menus easier, and LazuLib can help you write the packet classes for movement sync with the server and other players, using its DistributedPlayerPacket base class, as well as other math & common utils.

Groovy Gradle
def mcVersion = "1.19.2"
def aerobaticElytraVersion = "1.0.+"
def flightCoreVersion = "1.0.+"
def simpleConfigApiVersion = "1.0.0"
def simpleConfigVersion = "1.0.+"
def lazuLibVersion = "1.0.+"

repositories {
    // GitHub Packages
    def gitHubRepos = [
        "endorh/lazulib":          "endorh.util.lazulib",
        "endorh/flight-core":      "endorh.flightcore",
        "endorh/simple-config":    "endorh.simpleconfig",
        "endorh/aerobatic-elytra": "endorh.aerobaticelytra",
    ]
    gitHubRepos.each { repo, group ->
        maven {
            url "https://maven.pkg.github.com/$repo"
            name = "GitHub/$repo"
            content {
                // Speed up dependency resolution by declaring the only contained group
                includeGroup group
            }
            credentials {
                username "gradle" // Not relevant
                // read:packages only GitHub token published by Endor H, or use your own token
                password "\u0067hp_SjEzHOWgAWIKVczipKZzLPPJcCMHHd1LILfK"
            }
        }
    }
}

dependencies {
    // Aerobatic Elytra
    implementation fg.deobf("endorh.aerobaticelytra:aerobaticelytra-$mcVersion:$aerobaticElytraVersion")
    // Flight Core
    implementation fg.deobf("endorh.flightcore:flightcore-$mcVersion:$flightCoreVersion")
    // Simple Config
    compileOnly "endorh.simpleconfig:simpleconfig-$mcVersion-api:$simpleConfigApiVersion"
    runtimeOnly fg.deobf("endorh.simpleconfig:simpleconfig-$mcVersion:$simpleConfigVersion")
    // LazuLib
    implementation fg.deobf("endorh.util.lazulib:lazulib-$mcVersion:$lazuLibVersion")
}
Kotlin DSL
val mcVersion = "1.19.2"
val aerobaticElytraVersion = "1.0.+"
val flightCoreVersion = "1.0.+"
val simpleConfigApiVersion = "1.0.0"
val simpleConfigVersion = "1.0.+"
val lazuLibVersion = "1.0.+"

repositories {
    // GitHub Packages
    val gitHubRepos = mapOf(
        "endorh/lazulib" to "endorh.util.lazulib",
        "endorh/flight-core" to "endorh.flightcore",
        "endorh/simple-config" to "endorh.simpleconfig",
        "endorh/aerobatic-elytra" to "endorh.aerobaticelytra",
    )
    for (repo in gitHubRepos.entries) maven("https://maven.pkg.github.com/${repo.key}") {
        name = "GitHub/${repo.key}"
        content {
            // Speed up dependency resolution by declaring the only contained group
            includeGroup(repo.value)
        }
        credentials {
            username = "gradle" // Not relevant
            // read:packages only GitHub token published by Endor H, or use your own token
            password = "\u0067hp_SjEzHOWgAWIKVczipKZzLPPJcCMHHd1LILfK"
        }
    }
}

dependencies {
    // Aerobatic Elytra
    implementation(fg.deobf("endorh.aerobaticelytra:aerobaticelytra-$mcVersion:$aerobaticElytraVersion"))
    // Flight Core
    implementation(fg.deobf("endorh.flightcore:flightcore-$mcVersion:$flightCoreVersion"))
    // Simple Config
    compileOnly("endorh.simpleconfig:simpleconfig-$mcVersion-api:$simpleConfigApiVersion")
    runtimeOnly(fg.deobf("endorh.simpleconfig:simpleconfig-$mcVersion:$simpleConfigVersion"))
    // LazuLib
    implementation(fg.deobf("endorh.util.lazulib:lazulib-$mcVersion:$lazuLibVersion"))
}

Registering a Flight Mode

Aerobatic Elytra Flight Modes have their own registry. To create your own, you must implement the IFlightMode interface and register your modes using a RegisterEvent with the AerobaticElytraRegistries.FLIGHT_MODE_REGISTRY_KEY key.

Tip

You can see how the Aerobatic Elytra Jetpack does it. You may check the same file in other branches to find out how the registering process changes in different Minecraft versions.

The Aerobatic Elytra mod also registers its own flight mods using the same process, and may be used as inspiration as well.

Extra Stuff

Once you've added your flight mode, it's time to actually implement it, by implementing the methods from the IFlightMode interface. You may take inspiration in how the Aerobatic flight mode, the vanilla Elytra flight mode, the Jetpack and Hover modes are implemented.

After you're able to get your flight mode working, you may also be interested in:

Important

When (or if) this mode is ported to Fabric, major breaking changes will be made to the whole mod.

⚠️ **GitHub.com Fallback** ⚠️