Skip to content
Nicholas Kreimeyer edited this page Nov 22, 2026 · 3 revisions

Since 4.0, other mods can add their own turrets to Open Modular Turrets, on Fabric, NeoForge and Forge. An added turret is a full turret: it mounts on a base, uses the base's targeting, energy, ammo, upgrades, addons and trusted players, gets its own config entry and shows up in the OMT creative tab, tooltips and Jade. The 14 built-in turrets are registered through the same API.

The full developer documentation with code examples is in the repository: docs/turret-api.md on the branch of your Minecraft version: 1.20.1, 1.21.1, 1.21.11.

Overview

  1. Register the turret in a plugin class implementing OMTPlugin:

    • Fabric: an openmodularturrets entrypoint in fabric.mod.json.
    • NeoForge / Forge: annotate the class with @OMTPlugin.Register.
  2. Describe it with TurretType.builder("yourmod", "your_turret"): minimum base tier, ammo, targeting priority weights (see Targeting System), allowed faces, whether it ignores Scatter Shot or skips slowed targets.

  3. Give it a weapon:

    Weapon Does Built-in examples
    ProjectileWeapon spawns a projectile per shot, aimed with lead gun, rocket, plasma
    RayWeapon instant ray to the target laser, rail gun, arc
    EffectWeapon runs an effect on the base's target slowing, teleporter
    AreaWeapon hits every entity in an area melee
    SelfTargetingWeapon picks its own targets –

    Hooks such as onHit, onEntityHit and onBlockHit run your own code; OMTApi.canDamage / OMTApi.hurt apply the base's trust rules and count kills.

  4. Provide default stats with TurretStats.builder(...); they become the entry under turrets.addon_turrets in the Configuration.

  5. Register a model on the client with OMTClientPlugin (openmodularturrets_client entrypoint, or @OMTClientPlugin.Register).

  6. Ship the assets and data in your own namespace: blockstate, item model, lang keys, loot table and recipe.

Range falloff and turn rate (next release)

Coming with the next release of Open Modular Turrets for 1.12.2, 1.20.1, 1.21.1 and 1.21.11 (#539); not in the released 4.0 API yet. It needs OpenModularCore 2.2.0, which is not released yet either.

The built-in turrets get a range falloff and a turn rate (see Turret Heads and Aiming). An added turret has neither unless its stats set them, so a turret built against 4.0 behaves as before:

  • TurretStats.Builder.falloff(optimalShare, damageAtMaxRange): full damage up to optimalShare of the turret's range (with range upgrades), then linearly less down to damageAtMaxRange of the damage at the end of the range and beyond (config keys optimalRange and falloffDamage).
  • TurretStats.Builder.turnRate(degreesPerTick): how fast the turret turns towards its target, on yaw and pitch each (config key turnRate); 0, the default, turns instantly. An aiming turret with a turn rate fires only once its aim is within turrets.aimTolerance degrees.
  • Like all stats, the values become the defaults of the turret's config entry.

Which weapons the falloff applies to:

  • ProjectileWeapon: measured from the launch point to the hit, for projectiles that use the new damage helpers (below).
  • RayWeapon: OMT applies it, measured from the turret to where the ray enters the entity. A ray weapon always aims, so a turn rate on a turret whose model does not turn only delays its shots.
  • EffectWeapon, AreaWeapon and SelfTargetingWeapon: no falloff; a weapon that wants it scales its damage by base.getLogic().getDamageFactor(turret.getTurretType(), distance).
  • A SelfTargetingWeapon with aims = true turns towards the first picked entity at its turn rate; until its aim is within the tolerance, nothing is used, the shot is not called and the picker is asked again on the next tick.

Projectiles extending TurretProjectile get new protected helpers:

  • damage(Entity): the turret's damage with the bonus of the Damage Boost addon and the range falloff, measured from the launch point to where the projectile touches the entity; damage(float, Entity) does the same for your own base damage.
  • damageFactor(): the falloff at the projectile's position, for explosions and bursts (the same for every entity hit); multiply ampDamage(baseDamage(), entity) by it.
  • damageFactor(position) and hitPoint(Entity): the falloff at a given point, and where the projectile touches an entity.
  • damageWithAmp(int, Entity) is deprecated: it rounds to whole points and has no falloff. Projectiles that still use it keep working and deal full damage at every distance.

With this change, docs/turret-api.md on the branch of your Minecraft version (linked above) describes it in detail.

Clone this wiki locally