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(https://www.curseforge.com/minecraft/modpacks/enlightened-6-expert) .
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.
All Versions
+ Add Version- Parchment mapping support!
- Parchment is an open community-sourced modloader-neutral set of mappings of parameter names and javadocs, to augment the official names released by Mojang.
- In short, Parchment provides better parameter name (
x, y, zinstead ofint2, int3, int4) and builtin document for common classes - ProbeJS Legacy bundles a reprocessed mapping JSON file to provide Parchment mapping with no extra network requirement and minimum mod jar size increase
- fix null
ClassData.parentcausing NPE in dumping process - generic param for class (e.g.
$FoodBuilderin$Consumer<$FoodBuilder>) will now always be formatted as exact type - fix recursive declaration of generic default value
- remove VSCode config addition, there's no need for it now
- fix convertible type not generated for those with no
.assignType() - AutoParamRename is now always on
Types.and()for nothing now providesany
- Parchment mapping support!
- Parchment is an open community-sourced modloader-neutral set of mappings of parameter names and javadocs, to augment the official names released by Mojang.
- In short, Parchment provides better parameter name (
x, y, zinstead ofint2, int3, int4) and builtin document for common classes - ProbeJS Legacy bundles a reprocessed mapping JSON file to provide Parchment mapping with no extra network requirement and minimum mod jar size increase
- fix null
ClassData.parentcausing NPE in dumping process - generic param for class (e.g.
$FoodBuilderin$Consumer<$FoodBuilder>) will now always be formatted as exact type - fix recursive declaration of generic default value
- remove VSCode config addition, there's no need for it now
- fix convertible type not generated for those with no
.assignType() - AutoParamRename is now always on
Types.and()for nothing now providesany
- Fix import using
import { ... } from ...instead ofconst { ... } = require(...) - Formatted typing files can now be properly indented
- ProbeJS Legacy now provides a tree style output structure, just like ProbeJS 8. This can notably improve your KubeJS project init speed.
- Due to the new output structure, import path is also changed, but only if you use
require:const { $ArrayList } = require("java:java/util"); - This change will not affect JS users and plugin developers
- KubeJS (1.16.5):
const $ArrayList = java("java.util.ArrayList"); - KubeJS (1.20.1):
const $ArrayList = Java.loadClass("java.util.ArrayList"); - Developer API keeps the same
- Interfaces will now be referred to as an abstract class, to make its behavior closer to Java. Interface class itself will use
$XXX$$Staticname, and only used in classimplements - New config format that uses simple JSON + JSON schema, for less confusion. Old config file can be automatically upgraded to new one.
- Fix some problem during mod scanning
- Add
checkJSdefault value, for easier overwriting - Static field/method now appear before non-static one
- [1.20.1] Fix deprecation doc for
require - Restore Mixin refmap for dev environment
- Fix import using
import { ... } from ...instead ofconst { ... } = require(...) - Formatted typing files can now be properly indented
- ProbeJS Legacy now provides a tree style output structure, just like ProbeJS 8. This can notably improve your KubeJS project init speed.
- Due to the new output structure, import path is also changed, but only if you use
require:const { $ArrayList } = require("java:java/util"); - This change will not affect JS users and plugin developers
- KubeJS (1.16.5):
const $ArrayList = java("java.util.ArrayList"); - KubeJS (1.20.1):
const $ArrayList = Java.loadClass("java.util.ArrayList"); - Developer API keeps the same
- Interfaces will now be referred to as an abstract class, to make its behavior closer to Java. Interface class itself will use
$XXX$$Staticname, and only used in classimplements - New config format that uses simple JSON + JSON schema, for less confusion. Old config file can be automatically upgraded to new one.
- Fix some problem during mod scanning
- Add
checkJSdefault value, for easier overwriting - Static field/method now appear before non-static one
- [1.20.1] Fix deprecation doc for
require - Restore Mixin refmap for dev environment
- [1.20.1] fix recipe shortcuts like
event.shaped(...) - Fix some rare beaning name generation issue. Example:
.getRGB()will now generate.RGBbeaning instead of.rGB - Convertible type declaration with no modification is now moved to
shared. This can greatly decrease the amount of script-type specific files - The param name in setter is now the same as original method
- [1.20.1] remove invalid & duplicated assignment, better
TemporalAmount&Item&ItemStacksupport - JClass is now a type instead of class
- More precise check for functional interface
- Allow generic param in lambda. Do you know that
<K, V>(k: K, v: V) => voidis a valid type declaration?
- [1.20.1] fix recipe shortcuts like
event.shaped(...) - Fix some rare beaning name generation issue. Example:
.getRGB()will now generate.RGBbeaning instead of.rGB - Convertible type declaration with no modification is now moved to
shared. This can greatly decrease the amount of script-type specific files - The param name in setter is now the same as original method
- [1.20.1] remove invalid & duplicated assignment, better
TemporalAmount&Item&ItemStacksupport - JClass is now a type instead of class
- More precise check for functional interface
- Allow generic param in lambda. Do you know that
<K, V>(k: K, v: V) => voidis a valid type declaration?
running on TypeScript 6
- fix: issue when running on TypeScript 6
- fix: mod icon
- better handling for
o instanceof $SomeClass, with$SomeClassbeing an interface class - clearer naming for convertible type (
$Item$$Type->$Item_) - remove: special handling for
global
NOTE: change display name when updating
running on TypeScript 6
- fix: issue when running on TypeScript 6
- fix: mod icon
- better handling for
o instanceof $SomeClass, with$SomeClassbeing an interface class - clearer naming for convertible type (
$Item$$Type->$Item_) - remove: special handling for
global
NOTE: change display name when updating
probejs_legacy as mod id
- Add an icon to ProbeJS Legacy mod file
- For 1.20.1, the main mod id was accidentally set to
probejsduring 6.0.0 update, which has now been changed back toprobejs_legacy. For 1.16.5, you can use bothprobejsandprobejs_legacyto check ProbeJS Legacy - [1.20.1] Original ProbeJS will now be marked as incompatible
- [1.16.5] Fix KubeJS loading plugin multiple times when multiple mods are declared within one mod file
- In theory this should be done by KubeJS itself, but KubeJS for 1.16 has long been dead
- improve filtering for methods that override methods in parent classes
probejs_legacy as mod id
- Add an icon to ProbeJS Legacy mod file
- For 1.20.1, the main mod id was accidentally set to
probejsduring 6.0.0 update, which has now been changed back toprobejs_legacy. For 1.16.5, you can use bothprobejsandprobejs_legacyto check ProbeJS Legacy - [1.20.1] Original ProbeJS will now be marked as incompatible
- [1.16.5] Fix KubeJS loading plugin multiple times when multiple mods are declared within one mod file
- In theory this should be done by KubeJS itself, but KubeJS for 1.16 has long been dead
- improve filtering for methods that override methods in parent classes
Fix forge class scanner
- fix NPE due to
ClassData.parentbeingnull
Fix forge class scanner
- fix NPE due to
ClassData.parentbeingnull
Skip redundant classloading
- Anonymous classes will be skipped when scanning classes in Forge data and mod Jar
- fix some NPE issue
- NPE when there's no
java(...)/Java.loadClass(...)usage in a script type - NPE when a mod in
Mods with forced Full Scanningconfig provides no jar manifest - [1.16.5] make
BuiltinEventRecord.RECORDSa mutable map, to allow adding custom event record - [1.20.1] add type doc for
ReplacementMatch - [1.16.5] add
JSMemberType.Builder.literalMember(...)back for backward compat (mostly KesseractJS compat) - [1.16.5] remove duplicated event record
- [1.16.5] make
AccessClassDataa static util class
Skip redundant classloading
- Anonymous classes will be skipped when scanning classes in Forge data and mod Jar
- fix some NPE issue
- NPE when there's no
java(...)/Java.loadClass(...)usage in a script type - NPE when a mod in
Mods with forced Full Scanningconfig provides no jar manifest - [1.16.5] make
BuiltinEventRecord.RECORDSa mutable map, to allow adding custom event record - [1.20.1] add type doc for
ReplacementMatch - [1.16.5] add
JSMemberType.Builder.literalMember(...)back for backward compat (mostly KesseractJS compat) - [1.16.5] remove duplicated event record
- [1.16.5] make
AccessClassDataa static util class