SimpleJsonVillagerTrades

SimpleJsonVillagerTrades

简单来说,就是一个可通过数据包修改、添加或移除村民交易的小型可编辑库。

基础库

Simple JSON Villager Trades

顾名思义,这是一个小巧的可 jij/独立库,用于通过数据包修改/添加商人交易。

面向数据包作者

你可以通过 data/<namespace>/trade_offers/ 目录中的 JSON 文件修改商人交易。 例如:

{
  "__COMMENT": "这会向制图师的交易中添加一张废弃传送门地图。",

  "profession": "minecraft:cartographer",
  "replace": false,
  "offers": {
    "apprentice": [
      {
        "type": "minecraft:sell_map",
        "price": 5,
        "name_key": "filled_map.ruined_portal",
        "feature_tag": "minecraft:ruined_portal",
        "icon": "target_x",
        "max_uses": 10,
        "experience": 2
      }
    ]
  }
}

有关修改商人交易的更多教程和更多信息,请参阅 the wiki。

兼容性

SJVT 使用 Minecraft 硬编码的交易表作为数据包构建的基础,因此它应该能与大多数模组兼容,即使是那些添加新村民职业的模组。 你还可以通过运行 sjvt:build 命令,将硬编码的交易表(包括非原生支持的模组)导出为数据包。

面向模组开发者

你可以在 build.gradle 中使用以下仓库和依赖项来包含本模组(其中 [TAG] 是最新版本):

repositories {
  maven {
    name = "Modrinth"
    url = "https://api.modrinth.com/maven"
    content {
      includeGroup "maven.modrinth"
    }
  }
}

dependencies {
  modImplementation include("maven.modrinth:sjvt:[TAG]") //To include (jij) in your mod
  modImplementation "maven.modrinth:sjvt:[TAG]" // To require the mod to be installed seperatly
}

自定义交易报价工厂

要创建交易报价工厂,请实现 SerializableTradeOfferFactory 接口。 然后将编解码器注册到 TradeOfferFactories.TRADE_OFFER_FACTORY_REGISTRY 注册表。 你还可以使用 CodecHelper 类中的方法和字段来协助创建编解码器。

然后参阅“面向数据包作者”部分