ProbeJS Legacy
是官方 ProbeJS 放弃维护的 KubeJS 版本的一个非官方延续项目。
使用方法
- 你当然需要安装 ProbeJS Legacy。
- 进入单人世界。使用
/probejs dump导出由 ProbeJS Legacy 收集的数据。对于首次用户,在你加入世界时将自动完成此操作。 - 使用 VSCode 打开你的游戏实例文件夹。
- 尽情享受吧!
注意0:输入 @item 或 @block_tag 可查看生成的代码片段。
注意1:游戏实例文件夹是指你可以直接看到 kubejs 文件夹的位置。
注意2:其他支持 TypeScript 类型定义(.d.ts)的 IDE 也应该可以正常工作。
新功能
(与 ProbeJS 相比)
-
模拟
Internal- ProbeJS Legacy 现在会生成一个
Internal命名空间,允许用户轻松地从 ProbeJS 6 或 ProbeJS Legacy 3 迁移。 - 示例:
Internal.ItemStack和Internal.ItemStack_
- ProbeJS Legacy 现在会生成一个
-
更好的参数命名
- 与 TypeScript 冲突的参数名现在会以更好的方式进行重命名。
- 如果方法/构造函数中的参数名采用
arg123格式,它们将被重命名为根据其类型生成的新名称。
示例:
"mayUseItemAt"(arg0: $BlockPos$$Type, arg1: $Direction$$Type, arg2: $ItemStack$$Type): boolean
将重命名为
"mayUseItemAt"(blockPos0: $BlockPos$$Type, direction1: $Direction$$Type, itemStack2: $ItemStack$$Type): boolean
-
改进的
$Class<T>- ProbeJS 会将
$Class<T>转换为typeof T,但忽略了本不应这样做的许多情况。ProbeJS Legacy 使其更加正确。 - 一些基本类,例如
java.lang.String和java.lang.Character,现在可以被导出。 $Class<T>中的T现在实际上可用于类型提示。
- ProbeJS 会将
-
更好的
instanceof- ProbeJS Legacy 现在可以正确支持
obj instanceof $SomeClass,其中$SomeClass是通过java(...)或Java.loadClass(...)加载的类。
- ProbeJS Legacy 现在可以正确支持
示例:
const $BoatItem = java("some.path.to.BoatItem")
let item = Item.of("boat").item; // 这里 `item` 的类型是 `$Item`
if (item instanceof $BoatItem) {
// 这里 `item` 的类型可以推断为 `$BoatItem`
}
-
字段 Bean 化
- 某些字段将被转换为 getter+setter,以便为 TypeWrapper 提供更好的支持
- 考虑一个具有如下字段的
obj:block: $Block,而在 KubeJS 中obj.block = "minecraft:stone"是有效的语法。此前没有类型支持,但现在 ProbeJS Legacy 可以正确地支持它。
-
类型文件的共享
- 通过提取转储类中的公共部分,总类型文件的大小可以比之前小得多。
- 另一个好处是 TS 服务器现在可以在 3 种脚本类型之间重用公共类型定义,从而提升 IDE 性能。
-
更好的注释格式化
- 前后空白行现在将被忽略
- 如果只有一行有效内容,注释将格式化为单行
-
仅客户端/服务端方法(由
@OnlyIn标记)将带有注释说明其为仅服务端或仅客户端。 -
包含过多模块的
xxx.d.ts文件现在会自动拆分为较小的文件,以提供更好的 IDE 性能。 -
声明文件中的方法/字段现在按自然顺序排序。
-
global解析:现在可以解析你放入global的值。通过'global' Resolving Depth配置项设置解析深度。 -
以及许多内部更改。如果我全部写下来,这个 Readme 肯定会太长。
收集数据
KubeJS 事件
对于 1.16.5,ProbeJS Legacy 会记录所有已发布的事件。如果你找不到某些常用事件,请在转储数据之前尝试触发它们。例如:block.place 事件是在放置方块时触发的。
对于 1.20.1,所有注册的 KJS 事件都会自动转储,无需手动触发。
Forge 事件
ProbeJS Legacy 会记录所有 Forge 事件,无论它们是否已被发布。此行为可以通过 Class Scanner(类扫描器)配置进行修改。
Java 类
ProbeJS Legacy 将使用多种方法来收集 Java 类。
这些类将被记录:
-
手动加载的类,即通过
java(...)或Java.loadClass(...)加载的类。 -
JS 绑定引用的类,例如
AABB和Text。 -
已知类引用的类,例如
ItemStack.class引用了Item.class。 -
注册表对象,例如原版船只的
BoatItem。默认情况下会跳过非原版的对象,可以通过Registry Object Filter(注册表对象过滤器)配置进行修改。 -
来自某些模组的类。参见
Mods with forced Full Scanning(强制全扫描模组)配置。 -
从缓存文件读取的类。该缓存文件保存至
<你的实例文件夹>/.probe/classes.txt。 -
通过类扫描器找到的类。详见
Class Scanner配置。
为什么
起初,我只想找一份 KubeJS 脚本编写的文档或辅助工具,这样我在开发 Enlightend6Expert()时就不必再经历那种痛苦了。
但在研究之后,我意识到尽管 1.16.5 是最热门的模组版本之一,它甚至没有一个合适的 KubeJS 辅助模组。
于是就有了这个为 1.16.5 制作的 ProbeJS 分支。
这是我的第一个 Java 项目,也是我的第一个 Minecraft 模组项目。说实话,ProbeJS 对我来说这样的编程新手来说太难了。不过幸运的是,我成功了。
本项目采用与原始 ProbeJS 相同的 LGPLv3 许可证。
ProbeJS Legacy
is an unofficial continuation of ProbeJS for KubeJS versions abandoned by official ProbeJS.
Usage
- You need to install ProbeJS Legacy, obviously.
- Enter a singleplayer world. Use
/probejs dumpto export datas gathered by ProbeJS Legacy. For first-time users, this will be done automatically when you join the world. - Open your game instance folder using VSCode.
- Enjoy!
Note0: type @item or @block_tag to see snippets generated.
Note1: game instance folder is where you can see the kubejs folder directly.
Note2: Other IDEs with support for TypeScript typing (.d.ts) should also work.
New Features
(Compared to ProbeJS)
-
Simulated
Internal- ProbeJS Legacy will now generate a
Internalnamespace, allowing users to migrate from ProbeJS 6 or ProbeJS Legacy 3 easily. - Example:
Internal.ItemStackandInternal.ItemStack_
- ProbeJS Legacy will now generate a
-
Better Param Naming
- Param names that conflict with TypeScript will now be renamed in a better way.
- Param names in Method/Constructor, if in
arg123format, will be renamed to a new name generated from its type.
Example:
"mayUseItemAt"(arg0: $BlockPos$$Type, arg1: $Direction$$Type, arg2: $ItemStack$$Type): boolean
will be renamed to
"mayUseItemAt"(blockPos0: $BlockPos$$Type, direction1: $Direction$$Type, itemStack2: $ItemStack$$Type): boolean
-
Better
$Class<T>- ProbeJS will transform
$Class<T>intotypeof T, but ignoring many conditions where this should not be done. ProbeJS Legacy makes it more correct. - Some basic classes, for example
java.lang.Stringandjava.lang.Character. can now be dumped. - The
Tin$Class<T>is now actually usable for type hint.
- ProbeJS will transform
-
better
instanceof- ProbeJS Legacy can now properly support
obj instanceof $SomeClass, where$SomeClassis a class loaded viajava(...)orJava.loadClass(...).
- ProbeJS Legacy can now properly support
Example:
const $BoatItem = java("some.path.to.BoatItem")
let item = Item.of("boat").item; // here the type of `item` is `$Item`
if (item instanceof $BoatItem) {
// here the type of `item` can be inferred to `$BoatItem`
}
-
Field Beaning
- Some fields will be transformed into getter+setter, in order to provide better support for TypeWrapper
- Consider a
objwith a field like this:block: $Block, andobj.block = "minecraft:stone"is a valid syntax in KubeJS. This had no typing support before, but now ProbeJS Legacy can support it properly.
-
Typing files sharing
- By extracting common parts in dumped classes, the total typing files size can be much smaller than before.
- Another benefits is that TS server can now reuse common typings between 3 script types, improving IDE performance.
-
Better comment formatting
- blank lines at the front/back will now be ignored
- comments will be formatted as one line if there's only one valid line
-
Side only methods (marked by
@OnlyIn) will have comments telling you that it's server-only or client-only. -
xxx.d.tsfile with too many modules in it will now be split into smaller files automatically, providing better IDE performance -
Method/Field in declaration files are now naturally sorted.
-
gloablresolving: values you put intoglobalcan be resolved now. Configure resolving depth via'global' Resolving Depthconfig. -
And many internal changes. This Readme will certainly be too long if I write them all down.
Collecting data
KubeJS Event
For 1.16.5, ProbeJS Legacy will record all posted event. If you're unable to find some common events, try triggering it before dumping data. Example: block.place event is triggered by placing a block.
For 1.20.1, all registered KJS events will be dumped automatically, no need for triggering.
Forge Event
ProbeJS Legacy will record all Forge events, regardless of whether they have been posted or not. This behaviour can be altered via Class Scanner config.
Java Classes
ProbeJS Legacy will use multiple approaches for collecting Java classes.
These classes will be recorded:
- Classes loaded manually, aka those loaded via
java(...)orJava.loadClass(...) - Classes referenced by JS bindings, for example
AABBandText. - Classes references by known classes, for example
Item.classreferenced byItemStack.class. - Registry objects, for example
BoatItemfor vanilla boats. By default this will skip non-vanilla objects, and can be altered viaRegistry Object Filterconfig. - Classes from certain mods. See
Mods with forced Full Scanningconfig. - Classes read from cache file. The cache file is saved to
<your instance folder>/.probe/classes.txt. - Classes found by class scanner. See
Class Scannerconfig.
Why
Initially, all I want to do is just find some sort of doc or helper for KubeJS script writing, so that I won't need to feel such pain in the arse when developing Enlightend6Expert() .
But after some research, I realized that 1.16.5, despite being one of the hottest modded versions, didn't even have a proper KubeJS helper mod.
So there it is, a ProbeJS fork for 1.16.5.
This is my first Java project and first Minecraft Mod project, and to be honest, ProbeJS is too tough for a coding noob like me. Thankfully I made it.
This project is licensed under LGPLv3, the same as the original ProbeJS.
下载 ProbeJS Legacy
下载 ProbeJS Legacy
下载 ProbeJS Legacy
下载 ProbeJS Legacy
下载 ProbeJS Legacy
下载 ProbeJS Legacy
下载 ProbeJS Legacy
下载 ProbeJS Legacy
下载 ProbeJS Legacy
下载 ProbeJS Legacy
ProbeJS Legacy 6.2.0 -> 6.3.0
新增
- Parchment 映射现在是可选的,可以按需下载
- 通过
Parchment Mapping配置项或转储界面中的Enable Parchment复选框进行切换
- 通过
- 用于在游戏内编辑选项的配置界面。
- 已移除用于切换选项的命令,请使用
/probejs config打开配置界面
- 已移除用于切换选项的命令,请使用
- 用于可视化转储进度的新界面
- 现在可以通过使用
/probejs打开转储界面来启动转储 - 转储进度现在将显示为条目列表,每个条目可视化一个步骤
- 现在可以通过使用
- 接口的可转换类型现在使用 TS 接口类型,改进了对
JavaAdapter的支持 $XXX$$Static重命名为$XXX$$Interface
修复
- 字段到 Bean 的转换可能会破坏针对字段的文档修饰符
- 某些配方类型的可选字段在其名称中包含可选标记。例如
mod?而不是mod - 由于存在错误,已移除映射的
[x in K]: V语法 - [1.16.5] 未使用事件缓存
- 非参数化类型上的
@Generics注解被忽略
ProbeJS Legacy 6.1.0 -> 6.2.0
- 支持 Parchment 映射!
- Parchment 是一个由社区贡献的、与加载器无关的参数名称和 Javadoc 映射集,用于增强 Mojang 发布的官方名称。
- 简而言之,Parchment 提供了更好的参数名称(如
x, y, z而非int2, int3, int4)以及常用类的内置文档。 - ProbeJS Legacy 捆绑了一个重新处理的映射 JSON 文件,以便在无需额外网络请求且最小化模组 jar 包体积增加的情况下提供 Parchment 映射支持。
- 修复了在转储过程中因空
ClassData.parent导致的 NPE(空指针异常) - 类的泛型参数(例如
$Consumer<$FoodBuilder>中的$FoodBuilder)现在将始终格式化为确切类型 - 修复了泛型默认值的递归声明问题
- 移除了 VSCode 配置添加功能,因为现在已不再需要
- 修复了那些没有
.assignType()的类型未生成可转换类型的问题 - AutoParamRename 现在始终启用
- 当无参数时,
Types.and()现返回any
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
一个用于收集生物掉落物的多区块模组。
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
查看物品与配方
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
AE2:一款流行的自动化与存储模组
评论 0
登录后参与评分
还没有评论,来抢沙发吧