Ranged Weapon API

Ranged Weapon API

2M Downloads

RangedWeaponAPI

🏹 Making bows and crossbows has never been easier!

Features

Ranged weapons

  • Bows and Crossbow construction
  • Customizable weapon properties: damage, pull time, projectile velocity (optional)
  • Automatic item model predicate registration (matching vanilla model predicates)
  • Tooltip includes weapon properties
  • Correct rendering first and third person rendering
  • Correct pull FOV
  • AI can use these weapons

Example

Attributes

  • Ranged Damage attribute
    • ID: ranged_weapon:damage
    • Specifies the damage amount of projectiles, randomized by the same relative amount as vanilla weapons, critical strike mechanic applies the same way
  • Draw Speed attribute
    • ID: ranged_weapon:haste
    • Base value = 100
    • Example values: 50, -50% attack speed
    • Example values: 200, +100% attack speed

/give @p minecraft:leather_helmet[attribute_modifiers={modifiers:[{type:"ranged_weapon:haste",amount:0.2,slot:head,id:"armor_head_bonus",operation:add_multiplied_base}]}]

attribute_haste.png

Each attribute has a corresponding status effect.

/effect give @p ranged_weapon:damage

status_effect_damage.png

/effect give @p ranged_weapon:haste

status_effect_haste.png

Try it out

Check out this repo, resolve dependencies, select Testmod client run config.

Run config

Use /give @p testmod:custom_longbow to get a test bow.

Installation

Add this mod as dependency into your build.gradle file.

Repository

repositories {
    maven {
        name = 'Modrinth'
        url = 'https://api.modrinth.com/maven'
        content {
            includeGroup 'maven.modrinth'
        }
    }
}

Dependency

dependencies {
    modImplementation "maven.modrinth:ranged-weapon-api:${project.ranged_weapon_api_version}"
}

Usage

  1. Create your bow/crossbow instance
  2. Configure it
  3. Register it
  4. Add model and texture files
  5. Done!
var bow = new CustomBow(
    new Item.Settings().maxDamage(300),
    new RangedConfig(30, 9, 0),
    () -> Ingredient.ofItems(Items.GOLD_INGOT)
);
Registry.register(
    Registries.ITEM,
    Identifier.of(NAMESPACE, "custom_longbow"), 
    bow
);

Check out the example mod.

Include or depend

Feel free to include this API in your mod, the license allows you to do so.

If you want to say thank you, you can link this project as a dependency on Modrinth/CruseForge, so downloads are counted for this project too.

Mod ID: ranged_weapon_api

Modrinth dependency (gradle entry): required.project 'ranged-weapon-api'

CurseForge dependency (gradle entry): requiredDependency 'ranged-weapon-api'