import crafttweaker.api.loot.modifiers.CommonLootModifiers;import crafttweaker.api.loot.modifiers.ILootModifier;// 返回给战利品表抽奖结果添加一个指定物品的修饰器// CommonLootModifiers.add(stack as IItemStack) as ILootModifierval addIronIngot as ILootModifier = CommonLootModifiers.add(<item:minecraft:iron_ingot>);// 返回给战利品表抽奖结果有几率添加一个指定物品的修饰器// CommonLootModifiers.addWithChance(stack as MCWeightedItemStack) as ILootModifier// 物品 % 几率val addIronIngotHalfChance = CommonLootModifiers.addWithChance(<item:minecraft:iron_ingot>%50);// 返回给战利品表抽奖结果添加多种指定物品的修饰器// CommonLootModifiers.addAll(stack as IItemStack[]) as ILootModifier// 返回给战利品表抽奖结果添加多种指定物品与概率的修饰器// CommonLootModifiers.addAllWithChance(stacks as MCWeightedItemStack[]) as ILootModifierval foo = CommonLootModifiers.addAllWithChance([<item:minecraft:honey_bottle>%50, <item:minecraft:dried_kelp>%13]);// 添加物品,数量为两个值之间,均匀分布// CommonLootModifiers.addWithRandomAmount(stack as IItemStack, min as int, max as int) as ILootModifierval abc = CommonLootModifiers.addWithRandomAmount(<item:minecraft:conduit>, 2, 9);// 添加物品,但根据特定附魔等级,会额外再多掉落一些物品。如果你需要支持时运什么的,请用这个// 物品数量与附魔等级的关系有三种算法// 二项分布,原版用于煤矿石和红石矿石等// 额外掉落数量为 附魔等级 + extra 和 p 的二项分布。// CommonLootModifiers.addWithBinomialBonus(enchantment as MCEnchantment, extra as int, p as float, stack as IItemStack) as ILootModifier
val bar = CommonLootModifiers.addWithBinomialBonus(<enchantment:minecraft:fortune>, 3, 0.5714286, <item:minecraft:wheat_seeds>);
// 均匀分布// 额外掉落数量为 0 至 附魔等级 × Multiplier 的均匀分布。// CommonLootModifiers.addWithUniformBonus(enchantment as MCEnchantment, multiplier as int, stack as IItemStack) as ILootModifier
val xyz = CommonLootModifiers.addWithUniformBonus(<enchantment:minecraft:fortune>, 1, <item:minecraft:glowstone_dust>);// 原版默认矿物掉落的分布,原版用于钻石矿石等// 即有1/(附魔等级+2)几率数量改为原来的×(2至(附魔等级+1)),有2/(魔咒等级+2)几率不变。val moreCoal = CommonLootModifiers.addWithOreDropsBonus(<enchantment:minecraft:fortune>, <item:minecraft:coal>);val addIronIngotAndApple as ILootModifier = CommonLootModifiers.add([<item:minecraft:iron_ingot>, <item:minecraft:apple>]);
// 和上面的相同,只不过可以一次添加多种物品// CommonLootModifiers.addAllWithBinomialBonus(enchantment as MCEnchantment, extra as int, p as float, stacks as IItemStack[]) as ILootModifier
// CommonLootModifiers.addAllWithOreDropsBonus(enchantment as MCEnchantment, stacks as IItemStack[]) as ILootModifier// CommonLootModifiers.addAllWithUniformBonus(enchantment as MCEnchantment, multiplier as int, stacks as IItemStack[]) as ILootModifier
// 返回删除所有战利品表抽奖结果的修饰器// CommonLootModifiers.clearLoot() as ILootModifierval clearLoot as ILootModifier = CommonLootModifiers.clearLoot();// 返回删除指定物品的修饰器// CommonLootModifiers.remove(target as IIngredient) as ILootModifier)// 参数为 IIngredient,所以我们可以填物品标签进去val removeRedstone as ILootModifier = CommonLootModifiers.remove(<tag:items:forge:dusts/redstone>);// 返回删除多种物品的修饰器// CommonLootModifiers.removeAll(targets as IIngredient[]) as ILootModifierval removeIronIngotAndPoppy as ILootModifier = CommonLootModifiers.removeAll([<tag:items:forge:ingots/iron>, <item:minecraft:poppy>]);
// 返回将一种物品替换为另一种物品的修饰器// 该修饰器会对物品数量进行匹配// 对于将两个胡萝卜替换成一个马铃薯的修饰器,当它作用于结果为五个胡萝卜的战利品表,替换结果为// 两个马铃薯和一个胡萝卜。// 因为每两个胡萝卜被替换为一个马铃薯,剩余一个胡萝卜则没有替换// CommonLootModifiers.replaceStackWith(target as IItemStack, replacement as IItemStack) as ILootModifierval replaceTwoCarrotsWithOnePotato as ILootModifier = CommonLootModifiers.replaceStackWith(<item:minecraft:carrot> * 2, <item:minecraft:potato>);
// 返回将一种物品替换为另一种物品的修饰器// 由于该修饰器使用 IIngredient,所以我们可以使用物品标签,但也没有了数量的指定,只会一换一//CommonLootModifiers.replaceWith(target as IIngredient, replacement as IItemStack) as ILootModifierval replaceCarrotWithPotato as ILootModifier = CommonLootModifiers.replaceWith(<item:minecraft:carrot>, <item:minecraft:potato>);
// 与前面的同名的方法功能一样,只不过参数是映射,表示了多个替换规则// CommonLootModifiers.replaceAllStacksWith(replacementMap as IItemStack[IItemStack]) as ILootModifier// CommonLootModifiers.replaceAllWith(replacementMap as IItemStack[IIngredient]) as ILootModifier// 将多个修饰器连接起来组成一个新的修饰器// CommonLootModifiers.chaining(modifiers as ILootModifier[]) as ILootModifier// 例子调用了前面定义的修饰器,则为先删除全部再加个铁锭val clearThenAddIronIngot as ILootModifier = CommonLootModifiers.chaining([clearLoot, addIronIngot]);// 连接一个或多个修饰器,不过第一个已经确定好是清除原有物品的修饰器了// CommonLootModifiers.clearing(modifiers as ILootModifier[]) as ILootModifier// 这个和上面一个例子是等价的val clearThenAddIronIngot2 as ILootModifier = CommonLootModifiers.clearing(addIronIngot);