IDDDAssignMobResistancesEvent - yeelp/Distinct-Damage-Descriptions GitHub Wiki

THIS EVENT WAS REMOVED AS OF DDD 1.7! Use ResistancesModifiers and other CraftTweaker on spawn events instead! This article is left here to document the removed feature for older versions of DDD.

This event is fired when a mob is spawned in the world. It is only ever fired once per mob. It is even fired for players too (it will fire once for each player when they join the world for the first time, and never again), so keep that in mind. This event is designed to allow you to alter a mob's resistances permanently when they spawn to create conditional resistances such as mobs having special resistances when spawned in certain dimensions, etc.

A note on default resistances

Note that if you alter the config to set OnlyUseDefinedEntityDistributions to true, you should make sure the Resistances can be modified by checking if event_var.resistances.isDefault() returns false, where event_var is the variable that represents this event. If it does return false, you're good to go. Otherwise, making changes to the resistances will cause Minecraft to crash. This is intended behavior, as default resistances can't be changed! If you want default resistances for whatever reason, make sure you set starting resistance values to the mob ID's you intend to change resistances for!

Note that this situation never occurs for players, as players are always assigned a blank set of resistances, never the default ones.

Importing the class

You may need to import the class to avoid any errors.

import mods.ddd.events.AssignMobResistancesEvent;

Extending ILivingEvent

This event extends CraftTweaker's ILivingEvent. So anything accessible to that event is also accessible to IAssignMobResistancesEvent.

What can you do with this?

ZenGetters

ZenGetters Return Type Notes
resistances Resistances Gets the resistances capability that will be given to the mob. The idea in using this event is to make changes to this in this event!
world IWorld Get the world the mob is about to be spawned in. Might be safer than trying to get the world from the ILivingEntity directly.