Note: Use DeepL to translate to Simplified Chinese and use zhconvert to convert to Traditional Chinese
.
Message Links:
注:使用DeepL翻译成简体中文与使用繁化姬转换成繁体中文
信息连结:
Hey y'all! As KubeJS 6.1 for 1.19.2 is now shaping up for a full release, I've wanted to summarise the main important changes for both addon and script devs here, in order to let you prepare for this release before it's available for public use. Dev builds are available on https://kubejs.com/downloads/dev-builds and the Saps maven as usual, and we've already prepared some stuff for testing with certain pack dev teams, as well!
Because this is mostly a massive under the hood and API cleanup, I'll try to keep this user-facing changelog short and sweet, and focus on the addon relevant changes a little later. The most important changes you as a script developer might notice are as follows:
FluidAmounts
for… fluid amounts! This allows for better cross-loader script compatibility and provides some nice shortcuts for common fluid values like block, ingot and nugget!200 t
for tick durations as well) for their delays!NetworkEvents
have been merged into a single NetworkEvents.dataReceived
, which handles incoming data based on the script type.event.custom(T)
is now event.createCustom(() => T)
and takes in a supplier rather than an object referenceevent.cancel()
now immediately exits from the event, and custom event results (event.cancel()
, event.exit()
, event.success()
, as well as variants of those holding result values) have been introduced!player.notify
and the new Notification
binding to create custom vanilla-style toast notifications!Ingredient.of('2x thing')
is now InputItem.of('2x thing')
. If you use anything other than this syntax for ingredient stacks however, you'll be fine!And that's about it for all the user and dev facing changes I could think of! There's some other stuff I haven't listed here, and feel free to also check out our wiki for a more detailed 6.1 changelog at https://wiki.latvian.dev/books/kubejs/page/kubejs-61-update, which we will be updating as we go along and add some finishing touches to this release!
Now, onto the changelog for addon devs!
This is the big one. Recipe schemas completely change the way custom recipe handlers are registered in KubeJS, and should hopefully also mean a lot less boilerplate code down the line for you. Each recipe is now defined by a schema containing a set of recipe components, with those components acting as "codecs" for the underlying values. For you, this means the following:
dev.latvian.mods.kubejs.recipe.component
package, including blocks, items and fluids, generic group and logic components (array, map, pair, either, optional), and all kinds of primitives (including specialised ones such as number ranges and characters)constructor(factory, keys)
. Note that this will stop the default constructor from being generated, so if you want to keep that, you will have to define it yourself again.ShapedRecipeSchema
)event.smelting(...).xp(20).cookingTime(100)
), and you can add even more properties or do additional after-load validation by overriding the recipe factory entirely!Instead of augmenting vanilla classes to add functionality for ingredient stacks and chance items to recipes, we now use two entirely separate classes for this: InputItem
and OutputItem
. These classes have completely replaced Ingredient
and ItemStack
almost everywhere within recipes, and mostly just serve as simple wrappers for recipe schemas. (There are also recipe-aware methods in the schema which allow you to fine tune how item in-/outputs should be parsed!)
EventResult
. This is similar to the class of the same name in Architectury, or InteractionResult(Holder)
in vanilla, and you can use this to give users finer control over event return values.ScriptTypePredicate
, meaning you can use a single event handler for events that are fired on both sides (group.common
)! Events now also only fire for their relevant script type (though you can use ScriptTypePredicate.SERVER.negate()
to have something be fired for startup AND client)嗨,大家好! 由于1.19.2版本的KubeJS 6.1正在形成一个完整的版本,我想在这里总结一下插件和脚本开发者的主要重要变化,以便让你在这个版本可以公开使用之前做好准备。开发版本可以在https://kubejs.com/downloads/dev-builds和Saps maven上找到,而且我们已经准备了一些东西供某些包的开发团队测试!
因为这主要是一个大规模的后台和API清理,我将尽量使这个面向用户的变化日志简短而温馨,并在稍后关注与附加组件相关的变化。作为一个脚本开发者,你可能会注意到最重要的变化如下:
FluidAmounts
用于…液体数量 这允许更好的跨加载器脚本兼容性,并为常见的流体值提供了一些很好的快捷方式,如块状、锭状和金块状!200 t
,也可用于tick持续时间)!event.custom(T)
现在是event.createCustom(() => T)
,并且接收一个供应商,而不是一个对象引用。event.cancel()
现在立即从事件中退出,并且引入了自定义事件结果**(event.cancel()
、event.exit()
、event.success()
,以及那些持有结果值的变体player.notify
和新的Notification
绑定来创建自定义香草风格的敬酒通知!Ingredient.of('2x thing')
现在是InputItem.of('2x thing')
。如果你使用除此语法之外的任何其他语法*进行成分堆叠,你会没事的这就是我所能想到的所有用户和开发人员面临的变化! 还有一些其他的东西我没有在这里列出,请随时查看我们的维基,了解更详细的6.1变化日志https://wiki.latvian.dev/books/kubejs/page/kubejs-61-update,我们将在继续更新,为这个版本添加一些收尾工作!
现在,让我们来看看附加组件开发者的更新日志吧
这是个大问题。配方模式完全改变了自定义配方处理程序在KubeJS中的注册方式,希望这也意味着你可以减少很多模板代码。现在,每个配方都是由一个schema定义的,其中包含一组配方组件,这些组件作为基础值的 "编解码器 "发挥作用。对你来说,这意味着以下几点:
dev.latvian.mods.kubejs.recipe.component
包中提供了很多标准组件,包括块、项目和流体、通用组和逻辑组件(数组、地图、对、任一、可选),以及各种基元(包括数字范围和字符等专用的基元)。constructor(factory, keys)
自己定义一个构造函数来覆盖这一行为。请注意,这将阻止默认构造函数的生成,所以如果你想保留它,你必须再次自己定义它。event.smelting(..).xp(20).coatingTime(100)
),而且你可以通过完全覆盖配方工厂添加更多属性或进行额外的加载后验证!我们现在使用两个完全独立的类来实现这一功能,而不是通过增强香草类来为配方添加原料堆和机会项目的功能: InputItem
和OutputItem
。这些类已经完全取代了食谱中几乎所有的 "成分 "和 "物品堆",并且大部分只是作为食谱模式的简单包装物。(在模式中也有一些食谱感知方法,允许你微调项目的输入/输出应该如何被解析!)
EventResult
。这类似于Architectury中的同名类,或者vanilla中的InteractionResult(Holder)
,你可以用它来给用户提供对事件返回值更精细的控制。group.common')! 事件现在也只*为其相关的脚本类型触发(尽管你可以使用
ScriptTypePredicate.SERVER.negate()`来让某些东西为启动和客户端触发)。嗨,大家好! 由於1.19.2版本的KubeJS 6.1正在形成一個完整的版本,我想在這裡總結一下插件和腳本開發者的主要重要變化,以便讓你在這個版本可以公開使用之前做好準備。開發版本可以在https://kubejs.com/downloads/dev-builds和Saps maven上找到,而且我們已經準備了一些東西供某些包的開發團隊測試!
因為這主要是一個大規模的後台和API清理,我將盡量使這個面向用戶的變化日誌簡短而溫馨,並在稍後關注與附加組件相關的變化。作為一個腳本開發者,你可能會注意到最重要的變化如下:
FluidAmounts
用於…液體數量 這允許更好的跨載入器腳本相容性,並為常見的流體值提供了一些很好的捷徑,如塊狀、錠狀和金塊狀!200 t
,也可用於tick持續時間)!event.custom(T)
現在是event.createCustom(() => T)
,並且接收一個供應商,而不是一個對象引用。event.cancel()
現在立即從事件中退出,並且引入了自訂事件結果**(event.cancel()
、event.exit()
、event.success()
,以及那些持有結果值的變體player.notify
和新的Notification
綁定來創建自訂香草風格的敬酒通知!Ingredient.of('2x thing')
現在是InputItem.of('2x thing')
。如果你使用除此語法之外的任何其他語法*進行成分堆疊,你會沒事的這就是我所能想到的所有用戶和開發人員面臨的變化! 還有一些其他的東西我沒有在這裡列出,請隨時查看我們的維基,了解更詳細的6.1變化日誌https://wiki.latvian.dev/books/kubejs/page/kubejs-61-update,我們將在繼續更新,為這個版本添加一些收尾工作!
現在,讓我們來看看附加組件開發者的更新日誌吧
這是個大問題。配方模式完全改變了自訂配方處理程序在KubeJS中的註冊方式,希望這也意味著你可以減少很多模板代碼。現在,每個配方都是由一個schema定義的,其中包含一組配方組件,這些組件作為基礎值的 "編解碼器 "發揮作用。對你來說,這意味著以下幾點:
dev.latvian.mods.kubejs.recipe.component
包中提供了很多標準組件,包括塊、項目和流體、通用組和邏輯組件(數組、地圖、對、任一、可選),以及各種基元(包括數字範圍和字元等專用的基元)。constructor(factory, keys)
自己定義一個構造函數來覆蓋這一行為。請注意,這將阻止默認構造函數的生成,所以如果你想保留它,你必須再次自己定義它。event.smelting(..).xp(20).coatingTime(100)
),而且你可以通過完全覆蓋配方工廠添加更多屬性或進行額外的載入後驗證!我們現在使用兩個完全獨立的類來實現這一功能,而不是透過增強香草類來為配方添加原料堆和機會項目的功能: InputItem
和OutputItem
。這些類已經完全取代了食譜中幾乎所有的 "成分 "和 "物品堆",並且大部分只是作為食譜模式的簡單包裝物。(在模式中也有一些食譜感知方法,允許你微調項目的輸入/輸出應該如何被解析!)
EventResult
。這類似於Architectury中的同名類,或者vanilla中的InteractionResult(Holder)
,你可以用它來給用戶提供對事件返回值更精細的控制。group.common')! 事件現在也只*為其相關的腳本類型觸發(儘管你可以使用
ScriptTypePredicate.SERVER.negate()`來讓某些東西為啟動和用戶端觸發)。