Skip to content

Addon Development

Dinner edited this page Jul 20, 2026 · 2 revisions

This guide covers creating mods that extend Endless Gravity's mechanics.

Use Cases

  • Enchantments that reduce, cancel, or amplify gravity
  • Armor that makes the wearer immune to gravity
  • Items that interact with low-gravity physics
  • Custom entities that float or behave differently in The End
  • Potions/effects that modify gravity for the player

Examples

Levitation Boots Enchantment

Cancel gravity for players wearing boots with this enchantment:

@SubscribeEvent
public void onGravity(GravityApplicationEvent event) {
    if (!(event.getEntity() instanceof Player player)) return;

    ItemStack boots = player.getItemBySlot(EquipmentSlot.FEET);
    int level = EnchantmentHelper.getItemEnchantmentLevel(MY_LEVITATION, boots);
    if (level > 0) {
        event.setCanceled(true);
    }
}

Gravity Amplifier Spell

Double gravity for targets under a debuff:

@SubscribeEvent
public void onGravity(GravityApplicationEvent event) {
    if (event.getEntity().hasEffect(MY_WEAKNESS)) {
        event.setOffset(event.getOffset() * 2.0);
    }
}

Feather Falling Override

Reduce velocity-based fall damage for specific armor:

@SubscribeEvent
public void onFallDamage(FallDamageCalculationEvent event) {
    ItemStack chest = event.getPlayer().getItemBySlot(EquipmentSlot.CHEST);
    if (chest.is(MY_GLIDER_ITEM)) {
        event.setDamageMultiplier(0.2F);
    }
}

Gravity Immune Entity

Make a custom entity ignore gravity via datapack:

Create data/mymod/tags/entity/gravity_immune.json:

{
  "replace": false,
  "values": [
    "mymod:my_floating_creature"
  ]
}

Custom Dimension Support

Apply gravity effects to your own dimension by checking the tag:

@SubscribeEvent
public void onEntityTick(EntityTickEvent.Pre event) {
    Entity entity = event.getEntity();
    Level level = entity.level();

    // Apply custom gravity to your dimension
    if (level.dimension() == MY_CUSTOM_DIMENSION) {
        entity.setDeltaMovement(
            entity.getDeltaMovement().add(0, 0.03, 0)
        );
    }
}

Tips

  • Subscribe to events with @SubscribeEvent on the NeoForge event bus
  • Use EndlessGravityAPI.isGravityEnabled(level) to check if the entity is in The End
  • Use EndlessGravityAPI.isGravityImmune(entity) to check the tag
  • Events are fired on the main thread — no async concerns
  • The GravityApplicationEvent is fired for both players and non-player entities

Clone this wiki locally