Adds new EntityAttribute to the game, with the following id: projectile_damage:generic
. This allows customization of damage done by individual Bow and Crossbow items in the game.
Adds new status effect named Impact
, that increases the projectile damage of the entity.
You can use the API provided by this mod, to set custom damage value to your custom ranged weapons.
Server side configuration can be found in the config
directory, after running the game with the mod installed.
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'
}
}
}
dependencies {
modImplementation "maven.modrinth:projectile-damage-attribute:VERSION-fabric"
}
In fabric.mod.json
add a dependency to the mod:
"depends": {
"projectile_damage": ">=VERSION"
},
(Substitute VERSION
with the name of the latest release available on Modrinth, for example: 3.0.0
)
dependencies {
implementation "maven.modrinth:projectile-damage-attribute:VERSION-forge"
}
In mods.toml
add a dependency to the mod:
modId="projectile_damage"
mandatory=true
versionRange="[VERSION,)"
ordering="AFTER"
side="BOTH"
(Substitute VERSION
with the name of the latest release available on Modrinth, for example: 3.0.0
)
-
Make sure your custom Bow or Crossbow inherits from vanilla Bow or Crossbow classes.
-
Set the projectile damage for your weapon instance, preferably before registering it. (Keep in mind, this doesn't fixate the damage output at a constant value, the vanilla behaviour adding randomness will be applied too)
((IProjectileWeapon)bowInstance).setProjectileDamage(10);
(Note: assigned damage value will be applied on the spawned arrow by this mod, no additional coding is required on your end.)
- (Optional) If your weapon releases arrows at a non default velocity, use the following to compensate the velocity and make the weapon perform the expected amount of damage. (Default velocity: bow: 3.0, crossbow: 3.15).
((IProjectileWeapon)bowInstance).setMaxProjectileVelocity(4.2);
Custom weapon types such as: canons, blowpipes, etc...
-
Make sure the inheritance chain of your custom ranged weapon includes the vanilla class
ProjectileWeaponItem
(yarn:RangedWeaponItem
) or provide a custom implementation ofnet.projectile_damage.api.IProjectileWeapon
interface (default implementaion can be found here). -
Create a custom weapon type and save it somewhere. This holds the shared properties of your weapon class, which each instance will be scaled against.
public static class MyModItems {
static RangedWeaponKind CANON = RangedWeaponKind.custom(6, 1.9D);
}
- Configure your items.
public static class MyModItems {
static RangedWeaponKind CANNON = RangedWeaponKind.custom(6, 1.9D);
public static MyCanon woodenCanon;
public static MyCanon ironCanon;
public static MyCanon diamondCanon;
static {
woodenCannon = new MyCannon(...);
((IProjectileWeapon)woodenCannon).setRangedWeaponKind(CANNON);
// No custom damage is configured, default will be used from weapon kind
ironCannon = new MyCannon(...);
((IProjectileWeapon)ironCannon).setRangedWeaponKind(CANNON);
((IProjectileWeapon)ironCannon).setProjectileDamage(8);
diamondCannon = new MyCannon(...);
((IProjectileWeapon)diamondCannon).setRangedWeaponKind(CANNON);
((IProjectileWeapon)ironCannon).setProjectileDamage(10);
}
}