CommonLootModifiers
Importing the class
If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.
import crafttweaker.api.loot.modifier.CommonLootModifiers;Description
Holds a set of implementations ofILootModifier of common usage.These can be used freely instead of rewriting the same code more than once. They are also guaranteed to behave correctly.
Members
IItemStack to the drops.Returns: An ILootModifier that carries out the operation.
CommonLootModifiers.add(<item:minecraft:cobblestone>);Parameters:
Return Type:
ILootModifier
IItemStack to the drops.Returns: An ILootModifier that carries out the operation.
CommonLootModifiers.addAll(<item:minecraft:iron_ingot>, <item:minecraft:iron_nugget> * 5);Parameters:
Return Type:
ILootModifier
IItemStacks to the drops, modifying their count based on the level of the given Enchantment on 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_count formula used by vanilla. In this case, the value of extra is added to the current tool's enchantment level; that determines the amount of times the randomness will roll. Every roll that is higher than p will add one element to the stack. This is the formula used by potatoes and carrots to determine their drop count.
Returns: An ILootModifier that carries out the operation.
// CommonLootModifiers.addAllWithBinomialBonus(enchantment as Enchantment, extra as int, p as float, stacks as IItemStack[]) as ILootModifier;CommonLootModifiers.addAllWithBinomialBonus(<enchantment:minecraft:fortune>, 3, 0.5714286, <item:minecraft:wheat_seeds>, <item:minecraft:carrot> * 9);Parameters:
extra: int Type: int
- An extra value that will be added to the tool's enchantment level. p: float Type: float
- The probability of the binomial distribution, between 0.0 and 1.0 (both exclusive).
Return Type:
ILootModifier
Percentaged s 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.
Returns: An ILootModifier that carries out the operation.
CommonLootModifiers.addAllWithChance(<item:minecraft:honey_bottle> % 50, <item:minecraft:dried_kelp> % 13);Parameters:
Return Type:
ILootModifier
IItemStacks to the drops, modifying their count based on the level of the given Enchantment on 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_drops formula 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.
Returns: An ILootModifier that carries out the operation.
// CommonLootModifiers.addAllWithOreDropsBonus(enchantment as Enchantment, stacks as IItemStack[]) as ILootModifier;CommonLootModifiers.addAllWithOreDropsBonus(<enchantment:minecraft:fortune>, <item:minecraft:coal>, <item:minecraft:diamond>);Parameters:
Return Type:
ILootModifier
IItemStacks to the drops, modifying their count based on the level of the given Enchantment on 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_count formula used by vanilla. In this case, the enchantment level is multiplied by multiplier and 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.
Returns: An ILootModifier that carries out the operation.
// CommonLootModifiers.addAllWithUniformBonus(enchantment as Enchantment, multiplier as int, stacks as IItemStack[]) as ILootModifier;CommonLootModifiers.addAllWithUniformBonus(<enchantment:minecraft:fortune>, 1, <item:minecraft:glowstone_dust>, <item:minecraft:prismarine_crystals>);Parameters:
multiplier: int Type: int
- A multiplier that will be used in conjunction with the enchantment's level.
Return Type:
ILootModifier
IItemStack to the drops, modifying its count based on the level of the given Enchantment on 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_count formula used by vanilla. In this case, the value of extra is added to the current tool's enchantment level; that determines the amount of times the randomness will roll. Every roll that is higher than p will add one element to the stack. This is the formula used by potatoes and carrots to determine their drop count.
Returns: An ILootModifier that carries out the operation.
// CommonLootModifiers.addWithBinomialBonus(enchantment as Enchantment, extra as int, p as float, stack as IItemStack) as ILootModifier;CommonLootModifiers.addWithBinomialBonus(<enchantment:minecraft:fortune>, 3, 0.5714286, <item:minecraft:wheat_seeds>);Parameters:
extra: int Type: int
- An extra value that will be added to the tool's enchantment level. p: float Type: float
- The probability of the binomial distribution, between 0.0 and 1.0 (both exclusive).
Return Type:
ILootModifier
Percentaged to the drops, according to the specified chances.The chance will be computed on each modifier roll.
Returns: An ILootModifier that carries out the operation.
CommonLootModifiers.addWithChance(<item:minecraft:gilded_blackstone> % 50);Parameters:
Return Type:
ILootModifier
IItemStack to the drops, modifying its count based on the level of the given Enchantment on 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_drops formula 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.
Returns: An ILootModifier that carries out the operation.
// CommonLootModifiers.addWithOreDropsBonus(enchantment as Enchantment, stack as IItemStack) as ILootModifier;CommonLootModifiers.addWithOreDropsBonus(<enchantment:minecraft:fortune>, <item:minecraft:coal>);Parameters:
Return Type:
ILootModifier
IItemStack to 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.
Returns: An ILootModifier that carries out the operation.
// CommonLootModifiers.addWithRandomAmount(stack as IItemStack, min as int, max as int) as ILootModifier;CommonLootModifiers.addWithRandomAmount(<item:minecraft:conduit>, 2, 9);Parameters:
min: int Type: int
- The minimum amount that this stack can be. max: int Type: int
- The maximum amount that this stack can be.
Return Type:
ILootModifier
IItemStack to the drops, modifying its count based on the level of the given Enchantment on 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_count formula used by vanilla. In this case, the enchantment level is multiplied by multiplier and 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.
Returns: An ILootModifier that carries out the operation.
// CommonLootModifiers.addWithUniformBonus(enchantment as Enchantment, multiplier as int, stack as IItemStack) as ILootModifier;CommonLootModifiers.addWithUniformBonus(<enchantment:minecraft:fortune>, 1, <item:minecraft:glowstone_dust>);Parameters:
multiplier: int Type: int
- A multiplier that will be used in conjunction with the enchantment's level.
Return Type:
ILootModifier
ILootModifiers to be executed one after the other.Returns: An ILootModifier that carries out the operation.
CommonLootModifiers.chaining(CommonLootModifiers.clearLoot(), CommonLootModifiers.add(<item:minecraft:warped_hyphae>));Parameters:
Return Type:
ILootModifier
ILootModifiers together after having cleaned the original loot.Returns: An ILootModifier that carries out the operation.
CommonLootModifiers.clearing(CommonLootModifiers.add(<item:minecraft:warped_hyphae>));Parameters:
Return Type:
ILootModifier
Returns: An ILootModifier that carries out the operation.
CommonLootModifiers.clearLoot();
Return Type:
ILootModifier
IIngredient from the drops.Returns: An ILootModifier that carries out the operation.
CommonLootModifiers.remove(<tag:items:minecraft:creeper_drop_music_discs>);Parameters:
Return Type:
ILootModifier
IIngredients from the drops.Returns: An ILootModifier that carries out the operation.
CommonLootModifiers.removeAll(<item:minecraft:bell>, <tag:items:minecraft:rails>);Parameters:
Return Type:
ILootModifier
IIngredient from the drops, until the maximum amount of removals is reached.For example, assume the loot drops 2 carrots, 3 potatoes, and 1 iron ingot and that this loot modifier has been asked to remove 4 edible items. The result of applying the loot modifier will be to remove the 2 carrots and 2 out of the 3 potatoes, resulting in a final drop list of 1 iron ingot and 1 potato.
Returns: An ILootModifier that carries out the operation.
CommonLootModifiers.removeExactly(<tag:items:minecraft:wooden_planks> * 2);Parameters:
target: IIngredientWithAmount Type: IIngredientWithAmount
- The IIngredient to remove along with its quantity.
Return Type:
ILootModifier
IIngredients from the drops, until the maximum amount of removals is reached.For example, assume the loot drops 2 carrots, 3 potatoes, and 1 iron ingot and that this loot modifier has been asked to remove 4 edible items. The result of applying the loot modifier will be to remove the 2 carrots and 2 out of the 3 potatoes, resulting in a final drop list of 1 iron ingot and 1 potato.
Returns: An ILootModifier that carries out the operation.
CommonLootModifiers.removeExactlyAll(myIIngredientWithAmount[]);Parameters:
targets: IIngredientWithAmount[] Type: IIngredientWithAmount[]
- The IIngredients to remove along with their quantity.
Return Type:
ILootModifier
IItemStacks with the replacement IItemStacks, 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 than
#replaceAllWith(Map), where a simpler approach is used.Returns: An ILootModifier that carries out the operation.
// CommonLootModifiers.replaceAllStacksWith(replacementMap as IItemStack[IIngredientWithAmount]) as ILootModifier;CommonLootModifiers.replaceAllStacksWith({ <item:minecraft:carrots> * 2 : <item:minecraft:potatoes> });Parameters:
replacementMap: IItemStack[IIngredientWithAmount] Type: IItemStack[IIngredientWithAmount]
- A map of key-value pairs dictating the target to replace along with their replacement.
Return Type:
ILootModifier
IIngredients with their corresponding replacement IItemStack.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 to
#replaceAllStacksWith(Map).Returns: An ILootModifier that carries out the operation.
CommonLootModifiers.replaceAllWith({ <tag:items:forge:gems/emerald> : <item:minecraft:emerald> });Parameters:
replacementMap: IItemStack[IIngredient] Type: IItemStack[IIngredient]
- A map of key-value pairs dictating the target to replace along with their replacement.
Return Type:
ILootModifier
IIngredientWithAmount with the replacement IItemStack, proportionally.As an example, if the loot drops 5 carrots and this loot modifier runs with 2 carrots as the
targetand 1 potato as the
replacement, 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 than
IItemStack), where a simpler approach is used.Returns: An ILootModifier that carries out the operation.
// CommonLootModifiers.replaceStackWith(target as IIngredientWithAmount, replacement as IItemStack) as ILootModifier;CommonLootModifiers.replaceStackWith(<item:minecraft:carrots> * 2, <item:minecraft:potatoes>);Parameters:
Return Type:
ILootModifier
IIngredient with the replacement IItemStack.In this case, a simple matching procedure is used, where every stack that matches the given
targetis replaced by the
replacement without considering stack size. If stack size is to be preserved, refer to IItemStack).Returns: An ILootModifier that carries out the operation.
// CommonLootModifiers.replaceWith(target as IIngredient, replacement as IItemStack) as ILootModifier;CommonLootModifiers.replaceWith(<tag:items:forge:ingots/iron>, <item:minecraft:iron_ingot>);Parameters:
Return Type:
ILootModifier