Enum Class LootModifierManager
- All Implemented Interfaces:
Serializable,Comparable<LootModifierManager>,Constable
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
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
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.static LootModifierManagerReturns the enum constant of this class with the specified name.static LootModifierManager[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
INSTANCE
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
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.
-