本篇教程由作者设定使用 CC BY-NC-SA 协议。
基本指令
/ct loottables all
将所有战利品表储存到 版本名\dumps\loot_tables\ 目录下
/ct loottables byName <战利品表id>
示例 /ct loottables byName minecraft:chests/simple_dungeon
通过战利品表id将战利品表储存,路径同上
/ct loottables generate chest <战利品表id>
示例 /ct loottables generate chest minecraft:chests/simple_dungeon
在鼠标所指的位置生成一个使用指定战利品表id的箱子
/ct loottables generate entity <战利品表id> <实体id> [实体nbt]
示例 /ct loottables generate entity minecraft:chests/simple_dungeon minecraft:creeper
生成一个使用指定战利品表的指定实体甚至可以用箱子的战利品表
/ct loottables list
在消息栏列出所有战利品表
/ct loottables target
在消息栏显示鼠标指针所指的箱子(或实体)所使用的战利品表
zs编写
移除战利品
首先需要导包
import loottweaker.LootTweaker;
import loottweaker.LootTable;
import loottweaker.LootPool;
import loottweaker.Conditions;
import loottweaker.Functions;
之后就可以正式开始编写了
首先需要获取你要修改的战利品表名称
可以通过/ct loottable all将所有战利品表转储于版本名\dumps\loot_tables\目录下,找到你要修改的战利品表json文件,文件名就是战利品表名
一般来说,你找到的json文件是这样的
{
"pools":
[
{
"name": "main",
"entries":
[
{
"entryName": "minecraft:porkchop",
"weight": 1,
"quality": 0,
"type": "item",
"functions": [
{
"count": {
"min": 1.0,
"max": 3.0
},
"function": "minecraft:set_count"
},
{
"function": "minecraft:furnace_smelt",
"conditions": [
{
"properties": {
"minecraft:on_fire": true
},
"entity": "this",
"condition": "minecraft:entity_properties"
}
]
},
{
"count": {
"min": 0.0,
"max": 1.0
},
"function": "minecraft:looting_enchant"
}
],
"name": "minecraft:porkchop"
}
],
"rolls": 1.0
}
]
}你只需要关注其中几个关键的值,
一般来说只会有一个随机池,“name”后就是池名
首先通过getTable获取战利品表
val pig = LootTweaker.getTable("minecraft:entities/pig");之后,通过getPool获取随机池
val pigMain = pig.getPool("main")最后,移除指定战利品
pigMain.removeEntry("minecraft:porkchop");添加战利品
首先,根据上文方式获取战利品表与战利品池
之后,添加战利品
pigMain.addItemEntry(<minecraft:apple>, 5);
可用语句
newTable(String 战利品表id)
创建一个具有指定id的战利品表
getTable(String 战利品表id)
用于根据战利品表id获取战利品表
addPool(String 战利品随机池id, float 最小概率, float 最大概率, float 最小受幸运影响概率, float 最大受幸运影响概率)
用于为战利品表设立一个随机池并设定概率
removePool(String 战利品表随机池id)
用于根据随机池id为战利品表删除随机池
getPool(String poolName)
用于根据随机池id为战利品表获取随机池
removeEntry(String 物品id)
用于从随机池中删除物品
addItemEntry(IItemStack 物品id, int 权重, int 受幸运影响程度, LootFunction[] 战利品表函数, LootCondition[] 生成条件, String 名称)
用于向随机池中添加物品
战利品表函数和生成条件的写法在下文列出,也可以不填;名称要注意不能和池内现有的名称重复,可以不填
函数与生成条件的写法
函数
enchantRandomly(String[] 附魔id)
相当于minecraft:enchant_randomly
enchantWithLevels(int 最小等级, int 最大等级, boolean 是否为宝藏附魔)
相当于minecraft:enchant_with_levels
lootingEnchantBonus(int 最小等级, int 最大等级, int 总共最高等级)
相当于minecraft:looting_enchant
setCount(int 最小数量, int 最大数量)
相当于minecraft:set_count
setDamage(float 最小耐久, float 最大耐久)
相当于minecraft:set_damage,注意不能超过1
setMetadata(int 最小值, int 最大值)
相当于minecraft:set_data
setNBT(DataMap nbt数据)
相当于minecraft:set_nbt
条件
randomChance(float 概率)
相当于minecraft:random_chance
randomChanceWithLooting(float 概率, float 受战利品箱等级增加程度)
相当于minecraft:random_chance_with_looting
killedByPlayer()
相当于minecraft:killed_by_player
killedByNonPlayer()
与上一条相反
示例
import loottweaker.LootTweaker;
import loottweaker.LootTable;
import loottweaker.LootPool;
import loottweaker.Conditions;
import loottweaker.Functions;
//获取羊的战利品表
val sheep = LootTweaker.getTable("minecraft:entities/sheep");
//获取羊的随机池
val main = sheep.getPool("main");
//新建一个名叫“sweetloot”的随机池
val sweetLoot = sheep.addPool("sweetLoot", 1, 1, 1, 1);
//从随机池中删除战利品“minecraft:mutton”
main.removeEntry("minecraft:mutton");
//设置最小权重为3,最大权重为6
main.setRolls(3, 6);
//设置最小受幸运影响概率为0,最大受幸运影响概率为2
main.setBonusRolls(0, 2);
//当被玩家杀死时掉落三个苹果,权重为20,受幸运影响程度为1
sweetLoot.addItemEntry(<minecraft:apple> * 3, 20, 1, [], [Conditions.killedByPlayer()]);
//当被玩家杀死时杀死时掉落四个木棍,其余同上
sweetLoot.addItemEntry(<minecraft:stick> * 4, 20, 1, [], [{"condition": "killed_by_player"}]);
//当在火中被玩家杀死时掉落一个土豆,其余同上
sweetLoot.addItemEntry(<minecraft:potato>, 20, 1, [], [{"condition": "entity_properties", "entity": "this", "properties": {"on_fire": true}}, Conditions.killedByPlayer()]);
//掉落2-5个胡萝卜,其余同上
sweetLoot.addItemEntry(<minecraft:carrot>, 20, 1, [Functions.setCount(2, 5)], []);
//掉落3-9个红石,其余同上
sweetLoot.addItemEntry(<minecraft:redstone>, 20, 1, [{"count": {"min": 3.0, "max": 9.0}, "function": "minecraft:set_count"}], []);
//掉落1-3把剩余10%到15%耐久的铁剑
sweetLoot.addItemEntry(<minecraft:iron_sword>, 20, 1, [{"count": {"min": 1.0, "max": 3.0}, "function": "minecraft:set_count"}, Functions.setDamage(0.10, 0.15)], []);
//为羊新建新建一个随机池
val pigLoot = sheep.addPool("pigLoot", 1, 1, 1, 1);
//将这个随机池加入猪的战利品表
pigLoot.addLootTableEntry("minecraft:entities/pig", 40);
//让这个随机池使生物被非玩家杀死时才能触发
pigLoot.addConditions([Conditions.killedByNonPlayer()]);


