-
Notifications
You must be signed in to change notification settings - Fork 0
API‐Reference
Dinner edited this page Jul 20, 2026
·
2 revisions
Endless Gravity exposes an API for other mods to interact with gravity mechanics.
Add Endless Gravity as a compileOnly dependency in your build.gradle:
repositories {
maven {
url = "https://api.modrinth.com/maven"
}
}
dependencies {
compileOnly "maven.modrinth:endless-gravity:1.0.2:neoforge-1.21.1"
}Static utility class with config getters and tag access.
import dinner.dev.endless_gravity.EndlessGravityAPI;
// Check if gravity is active in the current dimension
boolean active = EndlessGravityAPI.isGravityEnabled(level);
// Check if an entity is gravity immune
boolean immune = EndlessGravityAPI.isGravityImmune(entity);
// Read config values
double playerOffset = EndlessGravityAPI.getPlayerGravityOffset();
boolean playerEnabled = EndlessGravityAPI.isPlayerGravityEnabled();
int damageMode = EndlessGravityAPI.getFallDamageMode();Fired before gravity is applied to an entity in The End.
| Field | Description |
|---|---|
getEntity() |
The entity about to have gravity applied |
getOffset() |
Current gravity offset from config |
setOffset(double) |
Set a custom offset (0 = no gravity) |
Cancel the event to prevent gravity entirely.
@SubscribeEvent
public void onGravity(GravityApplicationEvent event) {
// Cancel gravity for entities with levitation enchantment
if (event.getEntity() instanceof Player player) {
if (hasLevitation(player)) {
event.setCanceled(true);
}
}
}
@SubscribeEvent
public void amplifyGravity(GravityApplicationEvent event) {
// Double the gravity effect
event.setOffset(event.getOffset() * 2.0);
}Fired when velocity-based fall damage is calculated (mode 2 only).
| Field | Description |
|---|---|
getPlayer() |
The player taking damage |
getDamageMultiplier() |
Current damage multiplier (default 1.0) |
setDamageMultiplier(float) |
Modify the multiplier |
getDistance() |
Calculated fall distance |
setDistance(float) |
Modify the distance |
Cancel the event to prevent fall damage entirely.
@SubscribeEvent
public void onFallDamage(FallDamageCalculationEvent event) {
// Reduce damage by 50% for players with feather falling
if (hasFeatherFalling(event.getPlayer())) {
event.setDamageMultiplier(0.5F);
}
}Entities in this tag skip gravity in The End entirely.
Add entries via datapack:
{
"replace": false,
"values": [
"mymod:my_entity"
]
}Or in code:
// Check if an entity type is gravity immune
boolean immune = entity.getType().is(EndlessGravityAPI.GRAVITY_IMMUNE);