ResistancesModifierBuilder - yeelp/Distinct-Damage-Descriptions GitHub Wiki
DDD's ResistancesModifierBuilder lets you alter the resistances of mobs dynamically, including players! You'll need definedEntitiesOnly set to false in the config to make sure the modifiers apply to all entities, not just the ones defined in the config.
You may want to read the article on Resistances to familiarize yourself with the properties a typical MobResistances capability has.
Importing the class
You might need to import the class to avoid any errors.
import mods.ddd.modifiers.ResistancesModifierBuilder;
Extending ModifierBuilder
This ZenClass extends ModifierBuilder. So anything accessible from that ZenClass is accessible from ResistancesModifierBuilder, including all ZenProperties.
Creating a resistances modifier
To create a resistances modifier, use the static create(string)
ZenMethod. The name of the modifier must be unique amongst all other resistances modifiers!
The modifier function
The ResistancesModifierBuilder uses an additional ZenProperty of the type IsModifierApplicableForEntityLivingBase to determine if the modifier is applicable to the mob.
Additional things that are unique to ResistancesModifierBuilder
The ResistancesModifierBuilder has some additional properties and fields that can be changed that other ModifierBuilders do not. These fields and properties are for setting mob adaptability status, adaptability amount, and immunities.
ZenProperties
ZenProperty Name | Type | Notes |
---|---|---|
isModifierApplicable | isModifierApplicableForEntityLivingBase | This function determines if the modifier is applicable for the given entity living base. |
adaptabilityMod | float | The amount to add to a mob's adaptability amount. Typically, mobs without an adaptability chance on spawn will have 0% adaptability amount, so you'll usually want to set this to something if you intend making mobs adaptive with this modifier! Setting a negative amount here will lower a mob's adaptability amount. |
ZenMethods
void setAdaptability(boolean)
- Sets the adaptability status of this modifier. Mobs this modifier applies to will have their adaptability status set to the passed in argument, regardless of what their adaptability status was before. If this ZenMethod is not used during modifier creation, the resulting modifier will leave adaptability status unchanged from whatever the mob had originally/whatever modifiers of higher priority had already set. So long as one resistance modifier has this set to something, it is impossible for another resistance modifier to set the adaptability status of a mob back to what it was originally.
void addImmunity(string)
- Adds an immunity to specified internal damage type name to this modifier. Mobs will gain this immunity when the modifier applies if they don't have it already.
void removeImmunity(string)
- Removes an immunity to the specified internal damage type name to this modifier. Mobs will lose this immunity when the modifier applies if they have the immunity. This is removing immunities from the mobs this modifier applies to, NOT removing an immunity from this modifier.
Static ZenMethod
ResistancesModifierBuilder create(string)
- Create a new ResistancesModifierBuilder with the specified name as its internal name. Must be unique.
Example
This script causes all mobs named "Kenold" to become adaptive and increase their adapability amount by 50%. It also removed their bludgeoning immunity if they have it.
#loader contenttweaker
#modloaded distinctdamagedescriptions
import mods.ddd.modifiers.ResistancesModifierBuilder;
val builder = mods.ddd.modifiers.ResistancesModifierBuilder.create("kenold");
builder.setAdaptability(true);
builder.adaptabilityMod = 0.5;
builder.removeImmunity("bludgeoning");
builder.isModifierApplicable = function(entityLivingBase) {
return entityLivingBase.hasCustomName && entityLivingBase.customName == "Kenold";
};
builder.priority = -1;
builder.build();