Knockback API

Knockback API

Plugin

A simple and easy to use api to configure the knockback behaivor of entities

Server Game MechanicsLibraryUtility

48 downloads
1 follower
Created2 years ago
Updated2 years ago

Follow Save
Host your Minecraft server on BisectHosting - get 25% off your first month with code MODRINTH.

knockback-api

KnockbackAPI is really a simple and easy to use api to configure the knockback behaivor of entities. It allows you to turn the minecraft knockback completely upside-down!

Tutorial (for Developers)

Add the dependency

KnockbackAPI is available on the centarl maven repository.

Kotlin Gradle DSL

dependencies {
    implementation("de.hglabor:knockback-api:1.19.0")
}

Groovy Gradle

dependencies {
    implementation 'de.hglabor:knockback-api:1.19.0'
}

Maven

<dependency>
    <groupId>de.hglabor</groupId>
    <artifactId>knockback-api</artifactId>
    <version>1.19.0</version>
</dependency>

Let's knock entities to the aether!

In this tutorial we will turn up the vertical knockback until they fly to the aether.

If you have multiple plugins registering a knockback configuration, enter the name of the plugin whose config you want to use in the configuration file (config/knockback-api.yaml)

Start by creating a normal paper plugin and registering a new knockback configuration:

public class Example extends JavaPlugin {
    @Override
    public void onEnable() {
        EntityKnockbackRegistry.INSTANCE.register(
                this,
                new KnockbackConfiguration(
                        Map.of(),
                        new KnockbackSettings()
                                .modifyKnockback(true)
                                .knockbackVerticalLimit(6)
                                .knockbackVertical(6)
                ));
    }
}

⚠️ Please note: knockbackVerticalLimit must always be higher or equal than knockbackVertical

I don't like a player, let's knock them to the other side of the world!

If you want to create a per-player configuration, just place it in the map

public class Example extends JavaPlugin {
    @Override
    public void onEnable() {
        EntityKnockbackRegistry.INSTANCE.register(
                this,
                new KnockbackConfiguration(
                        Map.of(
                                UUID.fromString("50bf6931-e149-4743-9210-92cd58d85c5d"),
                                new KnockbackSettings()
                                        .modifyKnockback(true)
                                        .knockbackHorizontal(6.0)
                        ),
                        new KnockbackSettings()
                                .modifyKnockback(true)
                                .knockbackVerticalLimit(6.0)
                                .knockbackVertical(6.0)
                ));
    }
}

Jokes aside

6.0 is a very high number for knockback you will have to find good values by yourself. If you want to replicate the 1.8 knockback, taito2019 made a good set of values, these aren't the original ones but i bet you won't see a real difference!

new KnockbackSettings()
        .modifyKnockback(true)
        .knockbackFriction(3.0)
        .knockbackHorizontal(0.65)

External resources



Project members

mooziii

Owner


Technical information

License
GPL-3.0-only
Project ID