Repository navigation
Turret API
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.
-
Register the turret in a plugin class implementing
OMTPlugin:- Fabric: an
openmodularturretsentrypoint infabric.mod.json. - NeoForge / Forge: annotate the class with
@OMTPlugin.Register.
- Fabric: an
-
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. -
Give it a weapon:
Weapon Does Built-in examples ProjectileWeaponspawns a projectile per shot, aimed with lead gun, rocket, plasma RayWeaponinstant ray to the target laser, rail gun, arc EffectWeaponruns an effect on the base's target slowing, teleporter AreaWeaponhits every entity in an area melee SelfTargetingWeaponpicks its own targets – Hooks such as
onHit,onEntityHitandonBlockHitrun your own code;OMTApi.canDamage/OMTApi.hurtapply the base's trust rules and count kills. -
Provide default stats with
TurretStats.builder(...); they become the entry underturrets.addon_turretsin the Configuration. -
Register a model on the client with
OMTClientPlugin(openmodularturrets_cliententrypoint, or@OMTClientPlugin.Register). -
Ship the assets and data in your own namespace: blockstate, item model, lang keys, loot table and recipe.