
Что это
A KubeJS addon to create Java classes
- Тип: мод
- Загрузчик: forge
- Версии Minecraft: 1.20.1
- Скачиваний на Modrinth: 1 441
Подробно
ClassJS is a mod to create Java classes in KubeJS.
You may operate Java byte code to build your own methods.
Note: Some instructions that interacts with classes (getstatic, invokestatic, new, etc.) is protected under KubeJS's class filters. You may not use them to access classes that is not allowed by KubeJS or its other addons. Neither can you extend or implement them.
javascript let ExampleClass = ClassCreator.create("ExampleClass") .toPublic() // Set the class to public .defaultConstructor() // Add a default constructor .createMethod("exampleMethod", [], "java.lang.String") // Method name, parameter types, and return type .toPublic() .code(builder => { builder.pushString("Hello, ClassJS!") // Push a string reference to the operand stack .returnObject(); // Returns the string }) .defineClass(); // Define the class
console.info((new ExampleClass()).exampleMethod());
public String exampleMethod() { return "Hello, ClassJS!"; }
If you do not want to learn Java byte code, you can create methods using JavaScript functions.
javascript let ExampleClass = ClassCreator.create("ExampleClass") .toPublic() .createMethod("exampleMethod", ["int", "int"], "int") .toPublic().toStatic() .codeJS((num1, num2) => { return num1 + num2; }) .defineClass();
console.info(ExampleClass.exampleMethod(1, 2)); // Output in startup.log // 3.0
java public ExampleClass { // Note: This class do not even have a constructor, // as the JavaScript above did not call defaultConstructor, // neither did it created any other constructors.
public static int exampleMethod(int i1, int i2) { return i1 + i2; }
Classes can be only defined in startup scripts. If you want to use them in other scripts, you can use ClassJSUtils.loadClass method.
javascript ClassCreator.create("SomeClass") / Do some operations to add content to this class / .defineClass();
let SomeClass = ClassJSUtils.loadClass("SomeClass"); // Then you can use SomeClass
Как установить
Скачайте файл на официальной странице ниже и положите его в папку mods (для модов) или plugins (для плагинов) вашего сервера или клиента. Для модов нужен совместимый загрузчик. Версия должна совпадать с версией Minecraft.
Текст подготовлен автоматически из описания на Modrinth и ждёт проверки редакцией.
Комментарии 0
Комментарии к этому материалу отключены.
Читайте также
MSW Compat
Spell Power x Marium's Soulslike Weaponry 05.12.2026
TradeShop
A simple, no-nonsense item trade chest shop plugin. 05.12.2026
Backport Gamerules
Backporting new gamerules to the older versions 05.12.2026
MusicPlayerMod
A sleek, modern music player overlay for Minecraft that displays your currently playing media from Spotify, YouTube Music, and other… 05.12.2026
Deferred Registries
Register things in ease 05.12.2026
EnemyIndicator
EnemyIndicator makes your crosshair display differently when it is possible to hit an enemy. 05.12.2026