Resistances - yeelp/Distinct-Damage-Descriptions GitHub Wiki
Resistances are the CraftTweaker representation of DDD's mob resistances. Each mob spawns with one, even players!
Importing the class
You may need to import the class if you encounter any issues.
import mods.ddd.Resistances;
Iterating
The Resistances ZenClass is marked as IterableMap. What that means is you can iterate over Resistances as if it was a map. You can iterate over the IDDDDamageType keys and the float values at the same time.
//Here, resistances is an instance of the Resistances ZenClass. Maybe you got it from a mob or from the AssignMobResistancesEvent.
for type, amount in resistances {
//type is an IDDDDamageType, like say <dddtype:force>
//amount is the mob's resistance to whatever type is
print(type.name ~ " with resistance " ~ amount);
}
What can you do with it?
A lot!
ZenGetters
ZenGetters | Return Type | Notes |
---|---|---|
adaptability | boolean | true if the mob has adaptability. Depending on adaptability chance, not all mobs of the same type will have this as true. This ZenGetter is if this mob has it. |
adaptabilityAmount | float | The amount a mob will increase their resistances by if they are adaptive and it is triggered. A mob that isn't adaptive may still have this field set to something non-zero if the config gives them an adaptability amount. |
ZenMethods
float getResistance(IDDDDamageType);
- Gets the resistance a mob has to this type.
- A positive amount indicates a resistance, and a negative amount indicates a weakness. Positive values above 1.0 will reduce all damage of that type to 0, barring other modifiers like the Brute Force enchantment.
- Zero indicates no resistance/weakness.
boolean hasImmunity(IDDDDamageType);
true
if this mob is immune to damage from this type, barring other modifiers like the Sly Strike enchantment.
boolean isDefault()
- Checks if this instance of Resistances are the default resistances. Default resistances are given to mobs with no explicit resistances set in the config. Trying to make changes to the default resistances will throw a
UnsupportedOperationException
and Minecraft will crash!
Removed Features
The following were removed as of DDD 1.7, but have been moved to this section to document the removed features.
Removed ZenSetters
ZenSetter | Parameter Type | Notes |
---|---|---|
adaptibility | boolean | Setting this to true turns on this mob's adaptability and will use their adaptability amount for adaptability calculations. |
adaptabilityAmount | float | The amount a mob will adjust their resistances by if they are adaptive. There are other ways to force trigger adaptability without a mob's adaptability field being set to true . But regardless if adaptability is forced or not, this is the value the mob will use by default. |
Removed ZenMethods
void setResistance(IDDDDamageType, float);
- Sets the resistance this mob will have to the specified type to the specified amount
- This change is permanent. It will remain unless it is changed again via this ZenMethod.
void removeResistance(IDDDDamageType);
- Removes the resistance this mob has to this type.
- It's not exactly the same as
setResistance(type, 0);
- This will remove the resistance from the mob.
setResistance(type, 0)
just sets the resistance to 0. They function similarly but a mob with zero resistance to a type is still said to "have resistance" though it does nothing. - When in doubt, use this ZenMethod to remove resistances instead of setting them to zero.
- This will remove the resistance from the mob.
void setImmunity(IDDDDamageType, boolean);
- Sets this mobs immunity to this type
- If the second argument is
true
, it gives the mob immunity - If the second argument is
false
, it takes away the immunity
- If the second argument is
- This change is permanent until this ZenMethod is called on this mob again.