CommonLootModifiers
Link to commonlootmodifiers
Holds a set of implementations of 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.
导入类
Link to 导入类
It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.
ZenScript Copyimport crafttweaker.api.loot.modifiers.CommonLootModifiers;
Static Methods
Link to static-methods
Name: add
Adds the given IItemStack to the drops.
Returns: An ILootModifier that carries out the operation.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.add(stack as IItemStack) as ILootModifier
CommonLootModifiers.add(<item:minecraft:cobblestone>);
参数 | 类型 | 描述 |
---|---|---|
参数 堆叠 | 类型 IItemstack | 描述 The stack to add |
Name: addAll
Adds all the given IItemStack to the drops.
Returns: An ILootModifier that carries out the operation.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.addAll(stacks as IItemStack[]) as ILootModifier
CommonLootModifiers.addAll(<item:minecraft:iron_ingot>, <item:minecraft:iron_nugget> * 5);
参数 | 类型 | 描述 |
---|---|---|
参数 stacks | 类型 IItemStack[] | 描述 The stacks to add |
Name: addAllWithBinomialBonus
Adds the given IItemStacks to the drops, modifying their count based on the level of the given
MCEnchantment on the tool used, if available.
In case no tool is used to obtain the stack, then this loot modifier behaves exactly like
this#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.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.addAllWithBinomialBonus(enchantment as MCEnchantment, 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);
参数 | 类型 | 描述 |
---|---|---|
参数 enchantment | 类型 MCEnchantment | 描述 The enchantment to check for. |
参数 extra | 类型 int | 描述 An extra value that will be added to the tool's enchantment level. |
参数 p | 类型 float | 描述 The probability of the binomial distribution, between 0.0 and 1.0 (both exclusive). |
参数 stacks | 类型 IItemStack[] | 描述 The stacks to add. |
Name: addAllWithChance
Adds the given MCWeightedItemStacks 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.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.addAllWithChance(stacks as MCWeightedItemStack[]) as ILootModifier
CommonLootModifiers.addAllWithChance(<item:minecraft:honey_bottle> % 50, <item:minecraft:dried_kelp> % 13);
参数 | 类型 | 描述 |
---|---|---|
参数 stacks | 类型 MCWeightedItemStack[] | 描述 The stacks to add. |
Name: addAllWithOreDropsBonus
Adds the given IItemStacks to the drops, modifying their count based on the level of the given
MCEnchantment on the tool used, if available.
In case no tool is used to obtain the stack, then this loot modifier behaves exactly like
this#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.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.addAllWithOreDropsBonus(enchantment as MCEnchantment, stacks as IItemStack[]) as ILootModifier
CommonLootModifiers.addAllWithOreDropsBonus(<enchantment:minecraft:fortune>, <item:minecraft:coal>, <item:minecraft:diamond>);
参数 | 类型 | 描述 |
---|---|---|
参数 enchantment | 类型 MCEnchantment | 描述 The enchantment to check for. |
参数 stacks | 类型 IItemStack[] | 描述 The stacks to add. |
Name: addAllWithUniformBonus
Adds the given IItemStacks to the drops, modifying their count based on the level of the given
MCEnchantment on the tool used, if available.
In case no tool is used to obtain the stack, then this loot modifier behaves exactly like
this#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.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.addAllWithUniformBonus(enchantment as MCEnchantment, multiplier as int, stacks as IItemStack[]) as ILootModifier
CommonLootModifiers.addAllWithUniformBonus(<enchantment:minecraft:fortune>, 1, <item:minecraft:glowstone_dust>, <item:minecraft:prismarine_crystals>);
参数 | 类型 | 描述 |
---|---|---|
参数 enchantment | 类型 MCEnchantment | 描述 The enchantment to check for. |
参数 multiplier | 类型 int | 描述 A multiplier that will be used in conjunction with the enchantment's level. |
参数 stacks | 类型 IItemStack[] | 描述 The stacks to add. |
Name: addWithBinomialBonus
Adds the given IItemStack to the drops, modifying its count based on the level of the given
MCEnchantment on the tool used, if available.
In case no tool is used to obtain the stack, then this loot modifier behaves exactly like
this#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.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.addWithBinomialBonus(enchantment as MCEnchantment, extra as int, p as float, stack as IItemStack) as ILootModifier
CommonLootModifiers.addWithBinomialBonus(<enchantment:minecraft:fortune>, 3, 0.5714286, <item:minecraft:wheat_seeds>);
参数 | 类型 | 描述 |
---|---|---|
参数 enchantment | 类型 MCEnchantment | 描述 The enchantment to check for. |
参数 extra | 类型 int | 描述 An extra value that will be added to the tool's enchantment level. |
参数 p | 类型 float | 描述 The probability of the binomial distribution, between 0.0 and 1.0 (both exclusive). |
参数 堆叠 | 类型 IItemstack | 描述 The stack to add. |
Name: addWithChance
Adds the given MCWeightedItemStack 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.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.addWithChance(stack as MCWeightedItemStack) as ILootModifier
CommonLootModifiers.addWithChance(<item:minecraft:gilded_blackstone> % 50);
参数 | 类型 | 描述 |
---|---|---|
参数 堆叠 | 类型 MCWeightedItemStack | 描述 The stack to add. |
Name: addWithOreDropsBonus
Adds the given IItemStack to the drops, modifying its count based on the level of the given
MCEnchantment on the tool used, if available.
In case no tool is used to obtain the stack, then this loot modifier behaves exactly like
this#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.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.addWithOreDropsBonus(enchantment as MCEnchantment, stack as IItemStack) as ILootModifier
CommonLootModifiers.addWithOreDropsBonus(<enchantment:minecraft:fortune>, <item:minecraft:coal>);
参数 | 类型 | 描述 |
---|---|---|
参数 enchantment | 类型 MCEnchantment | 描述 The enchantment to check for. |
参数 堆叠 | 类型 IItemstack | 描述 The stack to add. |
Name: addWithRandomAmount
Adds the given 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.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.addWithRandomAmount(stack as IItemStack, min as int, max as int) as ILootModifier
CommonLootModifiers.addWithRandomAmount(<item:minecraft:conduit>, 2, 9);
参数 | 类型 | 描述 |
---|---|---|
参数 堆叠 | 类型 IItemstack | 描述 The stack to add. |
参数 min | 类型 int | 描述 The minimum amount that this stack can be. |
参数 max | 类型 int | 描述 The maximum amount that this stack can be. |
Name: addWithUniformBonus
Adds the given IItemStack to the drops, modifying its count based on the level of the given
MCEnchantment on the tool used, if available.
In case no tool is used to obtain the stack, then this loot modifier behaves exactly like
this#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.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.addWithUniformBonus(enchantment as MCEnchantment, multiplier as int, stack as IItemStack) as ILootModifier
CommonLootModifiers.addWithUniformBonus(<enchantment:minecraft:fortune>, 1, <item:minecraft:glowstone_dust>);
参数 | 类型 | 描述 |
---|---|---|
参数 enchantment | 类型 MCEnchantment | 描述 The enchantment to check for. |
参数 multiplier | 类型 int | 描述 A multiplier that will be used in conjunction with the enchantment's level. |
参数 堆叠 | 类型 IItemstack | 描述 The stack to add. |
Name: chaining
Chains the given list of ILootModifiers to be executed one after the other.
Returns: An ILootModifier that carries out the operation.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.chaining(modifiers as ILootModifier[]) as ILootModifier
CommonLootModifiers.chaining(CommonLootModifiers.clearLoot(), CommonLootModifiers.add(<item:minecraft:warped_hyphae>));
参数 | 类型 | 描述 |
---|---|---|
参数 modifiers | 类型 ILootModifier[] | 描述 The modifier list. |
Name: clearLoot
Clears the entire drop list.
Returns: An ILootModifier that carries out the operation.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.clearLoot() as ILootModifier
CommonLootModifiers.clearLoot();
Name: clearing
Chains the given list of ILootModifiers together after having cleaned the original loot.
Returns: An ILootModifier that carries out the operation.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.clearing(modifiers as ILootModifier[]) as ILootModifier
CommonLootModifiers.clearing(CommonLootModifiers.add(<item:minecraft:warped_hyphae>));
参数 | 类型 | 描述 |
---|---|---|
参数 modifiers | 类型 ILootModifier[] | 描述 The modifier list. |
Name: remove
Removes every instance of the targeted IIngredient from the drops.
Returns: An ILootModifier that carries out the operation.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.remove(target as IIngredient) as ILootModifier
CommonLootModifiers.remove(<tag:items:minecraft:creeper_drop_music_discs>);
参数 | 类型 | 描述 |
---|---|---|
参数 target | 类型 材料(IIngredient) | 描述 The IIngredient to remove. |
Name: removeAll
Removes every instance of all the targeted IIngredients from the drops.
Returns: An ILootModifier that carries out the operation.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.removeAll(targets as IIngredient[]) as ILootModifier
CommonLootModifiers.removeAll(<item:minecraft:bell>, <tag:items:minecraft:rails>);
参数 | 类型 | 描述 |
---|---|---|
参数 targets | 类型 IIngredient[] | 描述 The IIngredients to remove. |
Name: replaceAllStacksWith
Replaces every instance of the targeted 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 this#replaceAllWith(Map), where a simpler approach is used.
Returns: An ILootModifier that carries out the operation.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.replaceAllStacksWith(replacementMap as IItemStack[IItemStack]) as ILootModifier
CommonLootModifiers.replaceAllStacksWith({ <item:minecraft:carrots> * 2 : <item:minecraft:potatoes> });
参数 | 类型 | 描述 |
---|---|---|
参数 replacementMap | 类型 IItemStack[IItemStack] | 描述 A map of key-value pairs dictating the target to replace along with their replacement. |
Name: replaceAllWith
Replaces every instance of the targeted 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
this#replaceAllStacksWith(Map).
Returns: An ILootModifier that carries out the operation.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.replaceAllWith(replacementMap as IItemStack[IIngredient]) as ILootModifier
CommonLootModifiers.replaceAllWith({ <tag:items:forge:gems/emerald> : <item:minecraft:emerald> });
参数 | 类型 | 描述 |
---|---|---|
参数 replacementMap | 类型 IItemStack[IIngredient] | 描述 A map of key-value pairs dictating the target to replace along with their replacement. |
Name: replaceStackWith
Replaces every instance of the targeted IItemStack with the replacement IItemStack,
proportionally.
As an example, if the loot drops 5 carrots and this loot modifier runs with 2 carrots as the target
and 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 this#replaceWith(IIngredient, IItemStack), where a simpler approach
is used.
Returns: An ILootModifier that carries out the operation.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.replaceStackWith(target as IItemStack, replacement as IItemStack) as ILootModifier
CommonLootModifiers.replaceStackWith(<item:minecraft:carrots> * 2, <item:minecraft:potatoes>);
参数 | 类型 | 描述 |
---|---|---|
参数 target | 类型 IItemstack | 描述 The target to replace. |
参数 replacement | 类型 IItemstack | 描述 The replacement to use. |
Name: replaceWith
Replaces every instance of the targeted IIngredient with the replacement IItemStack.
In this case, a simple matching procedure is used, where every stack that matches the given target
is replaced by the replacement
without considering stack size. If stack size is to be preserved,
refer to this#replaceStackWith(IItemStack, IItemStack).
Returns: An ILootModifier that carries out the operation.
Return Type: ILootModifier
ZenScript Copy// CommonLootModifiers.replaceWith(target as IIngredient, replacement as IItemStack) as ILootModifier
CommonLootModifiers.replaceWith(<tag:items:forge:ingots/iron>, <item:minecraft:iron_ingot>);
参数 | 类型 | 描述 |
---|---|---|
参数 target | 类型 材料(IIngredient) | 描述 The target to replace. |
参数 replacement | 类型 IItemstack | 描述 The replacement to use. |