Class CommonLootModifiers
ILootModifier of common usage.
These can be used freely instead of rewriting the same code more than once. They are also guaranteed to behave correctly.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ILootModifieradd(IItemStack stack) Adds the givenIItemStackto the drops.static ILootModifieraddAll(IItemStack... stacks) Adds all the givenIItemStackto the drops.static ILootModifieraddAllWithBinomialBonus(net.minecraft.world.item.enchantment.Enchantment enchantment, int extra, float p, IItemStack... stacks) Adds the givenIItemStacks to the drops, modifying their count based on the level of the givenEnchantmenton the tool used, if available.static ILootModifieraddAllWithChance(Percentaged<IItemStack>... stacks) Adds the givenPercentagedIItemStacks to the drops, according to the specified chances.static ILootModifieraddAllWithOreDropsBonus(net.minecraft.world.item.enchantment.Enchantment enchantment, IItemStack... stacks) Adds the givenIItemStacks to the drops, modifying their count based on the level of the givenEnchantmenton the tool used, if available.static ILootModifieraddAllWithUniformBonus(net.minecraft.world.item.enchantment.Enchantment enchantment, int multiplier, IItemStack... stacks) Adds the givenIItemStacks to the drops, modifying their count based on the level of the givenEnchantmenton the tool used, if available.static ILootModifieraddWithBinomialBonus(net.minecraft.world.item.enchantment.Enchantment enchantment, int extra, float p, IItemStack stack) Adds the givenIItemStackto the drops, modifying its count based on the level of the givenEnchantmenton the tool used, if available.static ILootModifieraddWithChance(Percentaged<IItemStack> stack) Adds the givenPercentagedIItemStackto the drops, according to the specified chances.static ILootModifieraddWithOreDropsBonus(net.minecraft.world.item.enchantment.Enchantment enchantment, IItemStack stack) Adds the givenIItemStackto the drops, modifying its count based on the level of the givenEnchantmenton the tool used, if available.static ILootModifieraddWithRandomAmount(IItemStack stack, int min, int max) Adds the givenIItemStackto the drops, with an amount chosen randomly between the given bounds.static ILootModifieraddWithUniformBonus(net.minecraft.world.item.enchantment.Enchantment enchantment, int multiplier, IItemStack stack) Adds the givenIItemStackto the drops, modifying its count based on the level of the givenEnchantmenton the tool used, if available.static ILootModifierchaining(ILootModifier... modifiers) Chains the given list ofILootModifiers to be executed one after the other.static ILootModifierclearing(ILootModifier... modifiers) Chains the given list ofILootModifiers together after having cleaned the original loot.static ILootModifierClears the entire drop list.static ILootModifierremove(IIngredient target) Removes every instance of the targetedIIngredientfrom the drops.static ILootModifierremoveAll(IIngredient... targets) Removes every instance of all the targetedIIngredients from the drops.static ILootModifierreplaceAllStacksWith(Map<IIngredientWithAmount, IItemStack> replacementMap) Replaces every instance of the targetedIItemStacks with the replacementIItemStacks, proportionally.static ILootModifierreplaceAllWith(Map<IIngredient, IItemStack> replacementMap) Replaces every instance of the targetedIIngredients with their corresponding replacementIItemStack.static ILootModifierreplaceStackWith(IIngredientWithAmount target, IItemStack replacement) Replaces every instance of the targetedIIngredientWithAmountwith the replacementIItemStack, proportionally.static ILootModifierreplaceWith(IIngredient target, IItemStack replacement) Replaces every instance of the targetedIIngredientwith the replacementIItemStack.
-
Constructor Details
-
CommonLootModifiers
public CommonLootModifiers()
-
-
Method Details
-
add
Adds the givenIItemStackto the drops.- Parameters:
stack- The stack to add- Returns:
- An
ILootModifierthat carries out the operation. - DocParam:
- stack <item:minecraft:cobblestone>
-
addAll
Adds all the givenIItemStackto the drops.- Parameters:
stacks- The stacks to add- Returns:
- An
ILootModifierthat carries out the operation. - DocParam:
- stacks <item:minecraft:iron_ingot>, <item:minecraft:iron_nugget> * 5
-
addWithChance
Adds the givenPercentagedIItemStackto the drops, according to the specified chances.The chance will be computed on each modifier roll.
- Parameters:
stack- The stack to add.- Returns:
- An
ILootModifierthat carries out the operation. - DocParam:
- stack <item:minecraft:gilded_blackstone> % 50
-
addAllWithChance
Adds the givenPercentagedIItemStacks to the drops, according to the specified chances.The chance will be computed on each modifier roll, and independently for each of the given stacks.
- Parameters:
stacks- The stacks to add.- Returns:
- An
ILootModifierthat carries out the operation. - DocParam:
- stacks <item:minecraft:honey_bottle> % 50, <item:minecraft:dried_kelp> % 13
-
addWithOreDropsBonus
public static ILootModifier addWithOreDropsBonus(net.minecraft.world.item.enchantment.Enchantment enchantment, IItemStack stack) Adds the givenIItemStackto the drops, modifying its count based on the level of the givenEnchantmenton the tool used, if available.In case no tool is used to obtain the stack, then this loot modifier behaves exactly like
add(IItemStack).The formula used is based on the
ore_dropsformula used by vanilla, which multiplies the stack's original count by a random number between 1 and the tool's enchantment level + 1. This is the formula used by all vanilla ores to determine their drop count.- Parameters:
enchantment- The enchantment to check for.stack- The stack to add.- Returns:
- An
ILootModifierthat carries out the operation. - DocParam:
- enchantment <enchantment:minecraft:fortune>, stack <item:minecraft:coal>
-
addWithBinomialBonus
public static ILootModifier addWithBinomialBonus(net.minecraft.world.item.enchantment.Enchantment enchantment, int extra, float p, IItemStack stack) Adds the givenIItemStackto the drops, modifying its count based on the level of the givenEnchantmenton the tool used, if available.In case no tool is used to obtain the stack, then this loot modifier behaves exactly like
add(IItemStack).The formula used is based on the
binomial_with_bonus_countformula used by vanilla. In this case, the value ofextrais added to the current tool's enchantment level; that determines the amount of times the randomness will roll. Every roll that is higher thanpwill add one element to the stack. This is the formula used by potatoes and carrots to determine their drop count.- Parameters:
enchantment- The enchantment to check for.extra- An extra value that will be added to the tool's enchantment level.p- The probability of the binomial distribution, between 0.0 and 1.0 (both exclusive).stack- The stack to add.- Returns:
- An
ILootModifierthat carries out the operation. - DocParam:
- enchantment <enchantment:minecraft:fortune>, extra 3, p 0.5714286, stack <item:minecraft:wheat_seeds>
-
addWithUniformBonus
public static ILootModifier addWithUniformBonus(net.minecraft.world.item.enchantment.Enchantment enchantment, int multiplier, IItemStack stack) Adds the givenIItemStackto the drops, modifying its count based on the level of the givenEnchantmenton the tool used, if available.In case no tool is used to obtain the stack, then this loot modifier behaves exactly like
add(IItemStack).The formula used is based on the
uniform_bonus_countformula used by vanilla. In this case, the enchantment level is multiplied bymultiplierand a random number is extracted between 0 and the result. This number is then added to the original's stack count. This is the formula used by redstone ore and glowstone to determine their drop count.- Parameters:
enchantment- The enchantment to check for.multiplier- A multiplier that will be used in conjunction with the enchantment's level.stack- The stack to add.- Returns:
- An
ILootModifierthat carries out the operation. - DocParam:
- enchantment <enchantment:minecraft:fortune>, multiplier 1, stack <item:minecraft:glowstone_dust>
-
addAllWithOreDropsBonus
public static ILootModifier addAllWithOreDropsBonus(net.minecraft.world.item.enchantment.Enchantment enchantment, IItemStack... stacks) Adds the givenIItemStacks to the drops, modifying their count based on the level of the givenEnchantmenton the tool used, if available.In case no tool is used to obtain the stack, then this loot modifier behaves exactly like
addAll(IItemStack...).The fortune modifier is applied separately for each
IItemStack.The formula used is based on the
ore_dropsformula used by vanilla, which multiplies the stack's original count by a random number between 1 and the tool's enchantment level + 1. This is the formula used by all vanilla ores to determine their drop count.- Parameters:
enchantment- The enchantment to check for.stacks- The stacks to add.- Returns:
- An
ILootModifierthat carries out the operation. - DocParam:
- enchantment <enchantment:minecraft:fortune>, stacks <item:minecraft:coal>, <item:minecraft:diamond>
-
addAllWithBinomialBonus
public static ILootModifier addAllWithBinomialBonus(net.minecraft.world.item.enchantment.Enchantment enchantment, int extra, float p, IItemStack... stacks) Adds the givenIItemStacks to the drops, modifying their count based on the level of the givenEnchantmenton the tool used, if available.In case no tool is used to obtain the stack, then this loot modifier behaves exactly like
addAll(IItemStack...).The fortune modifier is applied separately for each
IItemStack.The formula used is based on the
binomial_with_bonus_countformula used by vanilla. In this case, the value ofextrais added to the current tool's enchantment level; that determines the amount of times the randomness will roll. Every roll that is higher thanpwill add one element to the stack. This is the formula used by potatoes and carrots to determine their drop count.- Parameters:
enchantment- The enchantment to check for.extra- An extra value that will be added to the tool's enchantment level.p- The probability of the binomial distribution, between 0.0 and 1.0 (both exclusive).stacks- The stacks to add.- Returns:
- An
ILootModifierthat carries out the operation. - DocParam:
- enchantment <enchantment:minecraft:fortune>, extra 3, p 0.5714286, stacks <item:minecraft:wheat_seeds>, <item:minecraft:carrot> * 9
-
addAllWithUniformBonus
public static ILootModifier addAllWithUniformBonus(net.minecraft.world.item.enchantment.Enchantment enchantment, int multiplier, IItemStack... stacks) Adds the givenIItemStacks to the drops, modifying their count based on the level of the givenEnchantmenton the tool used, if available.In case no tool is used to obtain the stack, then this loot modifier behaves exactly like
addAll(IItemStack...).The fortune modifier is applied separately for each
IItemStack.The formula used is based on the
uniform_bonus_countformula used by vanilla. In this case, the enchantment level is multiplied bymultiplierand a random number is extracted between 0 and the result. This number is then added to the original's stack count. This is the formula used by redstone ore and glowstone to determine their drop count.- Parameters:
enchantment- The enchantment to check for.multiplier- A multiplier that will be used in conjunction with the enchantment's level.stacks- The stacks to add.- Returns:
- An
ILootModifierthat carries out the operation. - DocParam:
- enchantment <enchantment:minecraft:fortune>, multiplier 1, stacks <item:minecraft:glowstone_dust>, <item:minecraft:prismarine_crystals>
-
addWithRandomAmount
Adds the givenIItemStackto the drops, with an amount chosen randomly between the given bounds.Any original stack size given to this method is ignored; if an addition behavior is desired (as in random chance on top of the original stack size), a combining loot modifier should be used instead.
- Parameters:
stack- The stack to add.min- The minimum amount that this stack can be.max- The maximum amount that this stack can be.- Returns:
- An
ILootModifierthat carries out the operation. - DocParam:
- stack <item:minecraft:conduit>, min 2, max 9
-
replaceWith
Replaces every instance of the targetedIIngredientwith the replacementIItemStack. In this case, a simple matching procedure is used, where every stack that matches the giventargetis replaced by thereplacementwithout considering stack size. If stack size is to be preserved, refer toreplaceStackWith(IIngredientWithAmount, IItemStack).- Parameters:
target- The target to replace.replacement- The replacement to use.- Returns:
- An
ILootModifierthat carries out the operation. - DocParam:
- target <tag:items:forge:ingots/iron>, replacement <item:minecraft:iron_ingot>
-
replaceAllWith
Replaces every instance of the targetedIIngredients with their corresponding replacementIItemStack. In this case, a simple matching procedure is used, where every stack that matches the key of the pair is replaced by the corresponding value, without considering stack size. If stack size is to be preserved, refer toreplaceAllStacksWith(Map).- Parameters:
replacementMap- A map of key-value pairs dictating the target to replace along with their replacement.- Returns:
- An
ILootModifierthat carries out the operation. - DocParam:
- replacementMap { <tag:items:forge:gems/emerald> : <item:minecraft:emerald> }
-
replaceStackWith
Replaces every instance of the targetedIIngredientWithAmountwith the replacementIItemStack, proportionally. As an example, if the loot drops 5 carrots and this loot modifier runs with 2 carrots as thetargetand 1 potato as thereplacement, the loot will be modified to 2 potatoes and 1 carrot. This happens because every 2-carrot stack will be actively replaced by a 1-potato stack, without exceptions. This loot modifier acts differently thanreplaceWith(IIngredient, IItemStack), where a simpler approach is used.- Parameters:
target- The target to replace.replacement- The replacement to use.- Returns:
- An
ILootModifierthat carries out the operation. - DocParam:
- target <item:minecraft:carrots> * 2, replacement <item:minecraft:potatoes>
-
replaceAllStacksWith
public static ILootModifier replaceAllStacksWith(Map<IIngredientWithAmount, IItemStack> replacementMap) Replaces every instance of the targetedIItemStacks with the replacementIItemStacks, proportionally. As an example, if the loot drops 5 carrots and this loot modifier runs with 2 carrots as the key of a pair and 1 potato as the corresponding value, the loot will be modified to 2 potatoes and 1 carrot. This happens because every 2-carrot stack will be actively replaced by a 1-potato stack, without exceptions. This loot modifier acts differently thanreplaceAllWith(Map), where a simpler approach is used.- Parameters:
replacementMap- A map of key-value pairs dictating the target to replace along with their replacement.- Returns:
- An
ILootModifierthat carries out the operation. - DocParam:
- replacementMap { <item:minecraft:carrots> * 2 : <item:minecraft:potatoes> }
-
remove
Removes every instance of the targetedIIngredientfrom the drops.- Parameters:
target- TheIIngredientto remove.- Returns:
- An
ILootModifierthat carries out the operation. - DocParam:
- target <tag:items:minecraft:creeper_drop_music_discs>
-
removeAll
Removes every instance of all the targetedIIngredients from the drops.- Parameters:
targets- TheIIngredients to remove.- Returns:
- An
ILootModifierthat carries out the operation. - DocParam:
- targets <item:minecraft:bell>, <tag:items:minecraft:rails>
-
clearLoot
Clears the entire drop list.- Returns:
- An
ILootModifierthat carries out the operation.
-
chaining
Chains the given list ofILootModifiers to be executed one after the other.- Parameters:
modifiers- The modifier list.- Returns:
- An
ILootModifierthat carries out the operation. - DocParam:
- modifiers CommonLootModifiers.clearLoot(), CommonLootModifiers.add(<item:minecraft:warped_hyphae>)
-
clearing
Chains the given list ofILootModifiers together after having cleaned the original loot.- Parameters:
modifiers- The modifier list.- Returns:
- An
ILootModifierthat carries out the operation. - DocParam:
- modifiers CommonLootModifiers.add(<item:minecraft:warped_hyphae>)
-