Skip to content

ModularShoot

ModularShoot is an attribute-driven, modular assembly gun system framework mod for NeoForge 1.21.1.

Framework only: This mod provides registration APIs, an attribute calculation pipeline, and a shooting engine. It ships with zero built-in guns, zero built-in plugins, and zero built-in traits. All content is added by other mods via the API or datapacks.

Key Features

FeatureDescription
Single ID + DataComponentAll guns share a single item ID (modularshoot:gun), differentiated via DataComponent. Same for plugins (modularshoot:plugin)
Pure Framework0 preset guns, 0 preset plugins, 0 preset traits — only API and engine
Attribute-DrivenGun behavior is entirely determined by attributes + traits. No hardcoded logic. ADD_VALUE → ADD_MULTIPLIED_BASE → ADD_MULTIPLIED_TOTAL three-stage stacking
Dual RegistrationSupports Java API registration and datapack JSON registration, sharing the same registries. /reload hot-reloads JSON; API entries are unaffected
Non-Entity BulletsBullets are lightweight data records managed by BulletManager, supporting thousands of simultaneous projectiles (chunk-bucketed indexing + capsule collision)
Fully Event-DrivenAll extension points exposed via events + callback APIs: shoot events, install/uninstall events, trait hooks, damage handlers, right-click/reload events
Server-AuthoritativeShooting, bullet flight, and hit detection are all server-side. Client is render-only, cheat-resistant

Quick Navigation

DocForContent
API ReferenceDevs calling framework functions in codeQuick-reference tables for all ModularShootAPI public methods
Registry ReferenceDevs understanding definition fieldsAll 6 dynamic registries and field details for each definition type
Datapack RegistrationDevs using JSON to register contentDatapack JSON file paths, fields, and format reference
Command ReferenceDevs using debug commands/modularshoot subcommand quick reference
ExamplesDevs wanting to see code directlyAll Java API and JSON examples in one place

6 Framework Registries

Registry IDPurposeRegistration Method
modularshoot:gunsGun definitionsJava API / Datapack JSON
modularshoot:pluginsPlugin definitionsJava API / Datapack JSON
modularshoot:plugin_typesPlugin type (category) definitionsJava API / Datapack JSON
modularshoot:traitsBoolean trait definitionsJava API / Datapack JSON
modularshoot:statesPersistent state definitionsJava API / Datapack JSON
modularshoot:attribute_metaAttribute metadata (defaults, display info, bindings)Datapack JSON

Attribute bodies (Attribute instances) must be registered using vanilla DeferredRegister into BuiltInRegistries.ATTRIBUTE. They are not in the dynamic registries above.

Preset Attributes

The framework pre-registers 9 numeric attributes (modularshoot namespace):

Attribute IDDescriptionDefault
hit_damageDamage per hit1.0
fire_rateShots per second (cap 20, ≤0 disables shooting)1.0
rangeMax bullet flight distance (blocks)50.0
accuracy_yawHorizontal spread angle (degrees)10.0
accuracy_pitchVertical spread angle (degrees)10.0
entity_penetrationEntities penetrated (0 = no penetration)0
bullet_speedBullet flight speed (blocks/sec)20.0
bullet_sizeBullet collision sphere radius (0 = raycast)0.5
block_penetrationBlocks penetrated (0 = no penetration)0

Key Events Overview

EventFires WhenCancellable
PreShootEventAfter shoot conditions passYes
PostShootEventAfter bullet is registeredNo
GunRightClickEventRight-click gun outside GUIYes
ReloadEventReload key pressed (default R)Yes
PrePluginInstallEventAfter install validation passesYes
PostPluginInstallEventAfter plugin written to componentNo
PrePluginUninstallEventBefore plugin removalYes
PostPluginUninstallEventAfter plugin removedNo

Released under the MIT License