Logo
MINECRAFTBIBLE
Items
Items

All game items

Blocks
Blocks

Building blocks

Mobs
Mobs

Creatures & monsters

Biomes
Biomes

World biomes

Structures
Structures

Generated structures

Recipes
Recipes

Crafting guides

Advancements
Advancements

Achievements

Loot Tables
Loot Tables

Drop rates

Tags
Tags

Item groupings

All Versions
View all data →
Capes
Cape ArchiveNEW

Browse rare Minecon capes, OptiFine capes, and custom capes from players worldwide

Browse

Player Database
Player DatabasePopular

Search any player

Skin Browser
Skin Browser

Browse & download skins

Cape Gallery
Cape GalleryNEW

Minecon & OptiFine capes

Seed Vault
Seed Vault

Curated seeds

Learn

Guides
GuidesNew

Tutorials & tips

Blog
Blog

News & updates

Community

Community Hub
Community HubHub

Posts, discussions & more

All Versions
View community →
Seed Analyzer
Seed Analyzer

World seed analysis

Loot Explorer
Loot Explorer

Drop rates

Crafting Calculator
Crafting Calculator

Material planning

Enchant Calculator
Enchant Calculator

Probability math

Redstone Lab
Redstone Lab

Signal timing

Trading Profit
Trading Profit

Villager ROI

All Versions
View all tools →
Mods
Mods

Browse all mods

Plugins
Plugins

Server plugins

Resource Packs
Resource Packs

Textures & sounds

Shaders
Shaders

Visual enhancements

Datapacks
Datapacks

World logic

Scanner
Mod Intelligence

Scan & analyze any mod

All Versions
View all mods →
Loading...
IntroductionIntroductionVersion HistoryVersion HistoryGuidesGuidesBlog & NewsBlog & News
ItemsItemsBlocksBlocksMobsMobsRecipesRecipesBiomesBiomesStructuresStructuresAdvancementsAdvancementsLoot TablesLoot TablesTagsTags
ModsModsPluginsPluginsResource PacksResource PacksShadersShadersDatapacksDatapacks

MinecraftBible

The Ultimate Wiki

Logo
MINECRAFTBIBLE

The ultimate Minecraft reference. Every item, block, mob, and recipe documented with precision.

Community

  • Skin Browser
  • Cape Gallery
  • Seed Vault
  • Blog
  • Guides

Database

  • Items
  • Blocks
  • Mobs
  • Recipes
  • Biomes
  • Structures

Tools

  • Seed Analyzer
  • Mod Intelligence
  • Crafting Calculator
  • Enchant Calculator

Mods & Packs

  • Mods
  • Plugins
  • Resource Packs
  • Shaders
  • Datapacks

Site & Legal

  • About
  • Authors
  • Editorial Policy
  • Corrections
  • Contact
  • Privacy Policy
  • Terms of Service
  • DMCA
  • Sitemap

© 2026 MinecraftBible. Not affiliated with Mojang or Microsoft.

PrivacyTermsContact
ClassJS
ModMIT

ClassJS

A KubeJS addon to create Java classes

213
Downloads
1
Followers
5 months ago
Updated
📦
6
Versions
forge
Download Latestv0.1-alpha.6View on Modrinth

📖About ClassJS

ClassJS is a mod to create Java classes in KubeJS.

Basic Example

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.

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());

Equivalent Java code:

public class ExampleClass {

    public ExampleClass() {
        super();
    }

    public String exampleMethod() {
        return "Hello, ClassJS!";
    }

}

Code in JavaScript

If you do not want to learn Java byte code, you can create methods using JavaScript functions.

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

Equivalent Java code:

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;
    }

}

Load a Created Class

Classes can be only defined in startup scripts.
If you want to use them in other scripts, you can use ClassJSUtils.loadClass method.

ClassCreator.create("SomeClass")
    /** Do some operations to add content to this class */
    .defineClass();

// In other scripts:

let SomeClass = ClassJSUtils.loadClass("SomeClass");
// Then you can use `SomeClass`

👥 Team & Contributors

Pelemenguin
PelemenguinOwner

⚙️ Compatibility

Environment
✅ Client & Server
Loaders
forge
Minecraft Versions
1.20.1

🔗 Links

Modrinth Page