Class LootModifierManager
An instance of this manager can be obtained via the LootManager.
The main usage of this manager is for registering "global loot modifiers", also known as "loot modifiers" for short. A global loot modifier runs on the loot drop of every loot table (unless otherwise specified by conditions) and is as such able to modify it according either to predetermined parameters (e.g. replacing items) or via completely customized code that leverages the dropping context.
For more information, refer to ILootModifier.
- DocParam:
- this loot.modifiers
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiongetAll()Gets a list containing all currently registered loot modifiers.List<net.minecraft.resources.ResourceLocation> Gets a list of all the names of the currently registered loot modifiers.Gets the loot modifier with the given name, if it exists.voidregister(String name, LootConditions conditions, ILootModifier modifier) Registers a new global loot modifier with the given name.voidRemoves all loot modifiers that have been registered up to this point.voidremoveByModId(String modId) Removes all loot modifiers that have been registered by the mod with the given ID.voidremoveByName(String name) Removes the loot modifier with the given name.voidremoveByRegex(String regex) Removes all loot modifiers whose name matches the given regular expression.
-
Field Details
-
INSTANCE
-
-
Method Details
-
register
Registers a new global loot modifier with the given name.The loot modifier will be run only when the given set of conditions is satisfied.
- Parameters:
name- The unique identifier for the loot modifier. It must be all lowercase and devoid of both spaces and colons.conditions- A set of conditions that restrict the context in which the loot modifier applies.modifier- The loot modifier itself. It may be created viaCommonLootModifiers.
-
getByName
Gets the loot modifier with the given name, if it exists.If no loot modifier with that name exists, a default no-op instance is returned.
- Parameters:
name- The name of the loot modifier.- Returns:
- The
ILootModifierwith the given name, or a default one if no such instance exists.
-
getAllNames
Gets a list of all the names of the currently registered loot modifiers.- Returns:
- A list with all the names of the currently registered loot modifiers.
-
getAll
Gets a list containing all currently registered loot modifiers.- Returns:
- A list containing all currently registered loot modifiers.
-
removeByName
Removes the loot modifier with the given name.The name may either contain a colon or not. If no colon is present, it is assumed that the loot modifier name is one of the modifiers that have been already registered in a script.
- Parameters:
name- The name of the loot modifier to remove.
-
removeByModId
Removes all loot modifiers that have been registered by the mod with the given ID.- Parameters:
modId- The mod ID.
-
removeByRegex
Removes all loot modifiers whose name matches the given regular expression.The entire name is taken into consideration for the match, effectively matching the format of a
ResourceLocation.- Parameters:
regex- The regular expression to match.
-
removeAll
public void removeAll()Removes all loot modifiers that have been registered up to this point.
-