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.

导入相关包

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.

import crafttweaker.api.loot.modifiers.CommonLootModifiers;

方法

add

Adds the given IItemStack to the drops.

Returns: An ILootModifier that carries out the operation. Return Type: ILootModifier

CommonLootModifiers.add(stack as IItemStack) as ILootModifier
参数类型描述
stackIItemStackThe stack to add

addAll

Adds all the given IItemStack to the drops.

Returns: An ILootModifier that carries out the operation. Return Type: ILootModifier

CommonLootModifiers.addAll(stacks as IItemStack[]) as ILootModifier
参数类型描述
stacksIItemStack[]The stacks to add

clearLoot

Clears the entire drop list.

Returns: An ILootModifier that carries out the operation. Return Type: ILootModifier

CommonLootModifiers.clearLoot() as ILootModifier
CommonLootModifiers.clearLoot();

remove

Removes every instance of the targeted IIngredient from the drops.

Returns: An ILootModifier that carries out the operation. Return Type: ILootModifier

CommonLootModifiers.remove(target as IIngredient) as ILootModifier
参数类型描述
target材料(IIngredient)The IIngredient to remove.

removeAll

Removes every instance of all the targeted IIngredients from the drops.

Returns: An ILootModifier that carries out the operation. Return Type: ILootModifier

CommonLootModifiers.removeAll(targets as IIngredient[]) as ILootModifier
参数类型描述
targetsIIngredient[]The IIngredients to remove.

replaceAllWith

Replaces every instance of the targeted IIngredients with their corresponding replacement IItemStack.

Returns: An ILootModifier that carries out the operation. Return Type: ILootModifier

CommonLootModifiers.replaceAllWith(replacementMap as IItemStack[IIngredient]) as ILootModifier
参数类型描述
replacementMapIItemStack[IIngredient]A map of key-value pairs dictating the target to replace along with their replacement.

replaceWith

Replaces every instance of the targeted IIngredient with the replacement IItemStack.

Returns: An ILootModifier that carries out the operation. Return Type: ILootModifier

CommonLootModifiers.replaceWith(target as IIngredient, replacement as IItemStack) as ILootModifier
参数类型描述
target材料(IIngredient)The target to replace.
replacementIItemStackThe replacement to use.