ItemModifierBuilder - yeelp/Distinct-Damage-Descriptions GitHub Wiki

DDD's ItemModifierBuilder is used for creating modifiers that apply to item stacks. It can be used to modify item damage distirbutions, armor distributions and shield distributions.

Importing the class

It may be required to import the class to avoid any errors.

import mods.ddd.modifiers.ItemModifierBuilder

Extending ModifierBuilder

This ZenClass extends ModifierBuilder. So anything accessible from that ZenClass is accessible from ItemModifierBuilder, including all ZenProperties.

Creating an item modifier

There are three static ZenMethods you can used depending on which kind of item modifier you're looking to make.

  • createItemDamageModifier(string) used for making item damage modifiers
  • createArmorModifier(string) used for making armor modifiers
  • createShieldModifier(string) used for making shield modifiers.

Note item damage modifiers will scale the resulting damage distribution to 100% total weight. See The ModifierBuilder section on how the modifier applies.

The modifier function

The ItemModifierBuilder uses an additional ZenProperty of type IsModifierApplicableForItemStack to determine if the modifier is applicable to the item stack.

ZenProperties

Zen Property Name Type Notes
isModifierApplicable IsModifierApplicableForItemStack This function determines if the modifier is applicable to the given item stack.

Static ZenMethods

ItemModifierBuilder createItemDamageModifier(string);

  • Creates a new item damage modifier. The string is the internal name of the modifier, which must be unique.

ItemModifierBuilder createArmorModifier(string);

  • Creates a new armor modifier. The string is the internal name of the modifier, which must be unique.

ItemModifierBuilder createShieldModifier(string);

  • Creates a new shield modifier. The string is the internal name of the modifier, which must be unique.

Example

Example Item Damage Modifier

This script applies a 25% bludgeoning reallocating modifier to stacks with less than 25% durability. The modifier is removed if the durability is repaired.

#loader contenttweaker
#modloaded distinctdamagedescriptions
import mods.ddd.modifiers.ItemModifierBuilder;

val builder = mods.ddd.modifiers.ItemModifierBuilder.createItemDamageModifier("durability");
builder.shouldReallocate = true;
builder.setMod("bludgeoning", 0.25);
builder.isModifierApplicable = function(stack) {
    return stack.isDamageable && ((stack.maxDamage - stack.damage) as double) <= 0.25*(stack.maxDamage as double);
};
builder.priority = -1;
builder.build();

Example Armor Modifier

This script gives a bonus Force effectiveness if the armor is enchanted.

#loader contenttweaker
#modloaded distinctdamagedescriptions
import mods.ddd.modifiers.ItemModifierBuilder;

val builder = mods.ddd.modifiers.ItemModifierBuilder.createArmorModifier("enchanted");
builder.setMod("force", 0.2);
builder.isModifierApplicable = function(stack) {
    return stack.isEnchanted;
};
builder.priority = -1;
builder.build();