Tacz Js Wiki › Guides › Create a Custom Gun with KubeJS
Create a Custom Gun with KubeJS
Setting Up Your Custom Gun
To create a new gun using KubeJS, you'll need to define it in your server scripts folder. Start by creating or editing a .js file in your kubejs/server_scripts/ directory.
Writing the Gun Definition
Use the TaCZ integration to register your gun. You'll specify:
- Gun ID: A unique identifier for your weapon
- Display name: What players see in inventory
- Model and texture: Visual appearance
- Firing mechanics: Rate of fire, accuracy, and recoil behavior
- Ammunition type: Which ammo this gun accepts
- Damage values: How much harm it deals
- Attachment slots: Where players can add scopes, grips, or other accessories
Define these properties in your script using the mod's KubeJS event handlers. Reference the TaCZ gun structure to ensure compatibility with existing attachment systems.
Testing Your Gun
After writing your script, reload your world or server. Your custom gun should appear in the creative menu and function with standard TaCZ mechanics like aiming, reloading, and melee attacks. Test firing, attachment compatibility, and ammunition consumption to verify everything works as intended.