ExtendedAE

ExtendedAE

17M Downloads

[KubeJS] Unable to create custom infinity cells via any method ('Unknown type' and 'NoSuchMethodException')

Newuserupscale opened this issue ยท 1 comments

commented

Hello,

I'm trying to create a custom infinity cell using the KubeJS integration on Minecraft 1.20.1, but it's failing with different errors depending on the approach.

1. Using the 'custom_infinity_cell' builder type:

As described in the wiki, I used this script:

// #requires extendedae
StartupEvents.registry('item', event => {
    event.create('lava_cell', 'custom_infinity_cell')
         .fluidType('minecraft:lava');
});

This fails with java.lang.IllegalArgumentException: Unknown type 'custom_infinity_cell' for object 'lava_cell'. The #requires and // priority directives do not solve the issue. It seems the builder type is registered after KubeJS startup scripts are parsed.

  1. Using direct Java class instantiation:

To work around the first issue, I tried to create an item by directly instantiating the ItemInfinityCell class:

StartupEvents.registry('item', event => {
    const $ItemInfinityCell = Java.loadClass('com.glodblock.github.extendedae.common.items.ItemInfinityCell');
    const $AEFluidKey = Java.loadClass('appeng.api.stacks.AEFluidKey');
    const $Fluids = Java.loadClass('net.minecraft.world.level.material.Fluids');
    
    event.create('lava_infinity_cell').item(new $ItemInfinityCell(() => $AEFluidKey.of($Fluids.LAVA)));
});
This also fails, but with a different error: java.lang.NoSuchMethodException: com.glodblock.github.extendedae.common.items.ItemInfinityCell.<init>().

Diagnostic Test:

I created a diagnostic script to isolate the issue. It confirms that my KubeJS can create basic items and items from vanilla Java classes, but it specifically fails when trying to instantiate ItemInfinityCell.

Diagnostic Script:

StartupEvents.registry('item', event => {
    try {
        event.create('test_item_1'); // Step 1: Basic item
        console.log('KubeJS: Diagnostic Step 1 (basic item) SUCCEEDED.');
    } catch (e) {
        console.error('KubeJS: Diagnostic Step 1 (basic item) FAILED! Error: ' + e);
    }
    
    try {
        const $Item = Java.loadClass('net.minecraft.world.item.Item');
        const $ItemProperties = Java.loadClass('net.minecraft.world.item.Item$Properties');
        event.create('test_item_2').item(new $Item(new $ItemProperties())); // Step 2: Vanilla class item
        console.log('KubeJS: Diagnostic Step 2 (vanilla class) SUCCEEDED.');
    } catch (e) {
        console.error('KubeJS: Diagnostic Step 2 (vanilla class) FAILED! Error: ' + e);
    }

    try {
        const $ItemInfinityCell = Java.loadClass('com.glodblock.github.extendedae.common.items.ItemInfinityCell');
        const $AEItemKey = Java.loadClass('appeng.api.stacks.AEItemKey');
        const $Items = Java.loadClass('net.minecraft.world.item.Items');
        const $Supplier = Java.loadClass('java.util.function.Supplier');
        
        const testSupplier = new $Supplier({ get: () => $AEItemKey.of($Items.COBBLESTONE) });
        event.create('test_infinity_cell').item(new $ItemInfinityCell(testSupplier)); // Step 3: Mod class item
        console.log('KubeJS: Diagnostic Step 3 (ItemInfinityCell) SUCCEEDED.');
    } catch (e) {
        console.error('KubeJS: Diagnostic Step 3 (ItemInfinityCell) FAILED! Error: ' + e);
    }
});

Result in my log:

[KubeJS]: KubeJS: Diagnostic Step 1 (basic item) SUCCEEDED.
[KubeJS]: KubeJS: Diagnostic Step 2 (vanilla class) SUCCEEDED.
[KubeJS]: KubeJS: Diagnostic Step 3 (ItemInfinityCell) FAILED! Error: java.lang.RuntimeException: java.lang.NoSuchMethodException: com.glodblock.github.extendedae.common.items.ItemInfinityCell.<init>()

This seems to be an issue with how the ItemInfinityCell class is exposed or how it interacts with KubeJS's Rhino engine. Could you please look into this?

Thank you!

commented

The kjs support is only available in 1.21.1. You can add custom infinity cell in config in 1.20.1.

#ME Infinity Cell types (item or fluid's id)
types = ["minecraft:water", "minecraft:cobblestone"]