KubeJS (Old)

KubeJS (Old)

3M Downloads

ClientEvents.init() crashes the server due to undefined error

CelestialAbyss opened this issue ยท 1 comments

commented

Minecraft Version

1.19.2

KubeJS Version

1902.6.2-build.42

Rhino Version

1902.2.2-build.280

Architectury Version

6.5.85

Forge/Fabric Version

Forge 43.3.2

Describe your issue

In older KubeJS versions an if (Platform.isClientEnvironment()) check was not required and it would be ignored on its own.

A summary of the script file in question is as follows:

// priority: 1
// requires: create

const $ItemDescription = Java.loadClass('com.simibubi.create.foundation.item.ItemDescription$Modifier')
const $TooltipModifier = Java.loadClass('com.simibubi.create.foundation.item.TooltipModifier')
const $Palette = Java.loadClass('com.simibubi.create.foundation.item.TooltipHelper$Palette')

/**
 * 
 * @param {Internal.ItemStack} itemID 
 */
function STANDARD_PALETTE(itemID) {
    $TooltipModifier.REGISTRY.register(itemID, new $ItemDescription(itemID, $Palette.STANDARD_CREATE))
}

ClientEvents.init(event => {
    STANDARD_PALETTE_REGISTRY.forEach(item => {
        STANDARD_PALETTE(item)
    })
    // ...
})

Below are the startup log files from both versions.

The latest.log with KubeJS 1902.6.2-build.33 does not have any errors when the script is loaded, but with 1902.6.2-build.42 it has an error (see latest.log below)

Apologies if this was an intentional change that occurred between builds 33 and 42.

The expected outcome is that KubeJS would just not load it at all as seen from build 33.

Crash report/logs

latest.log with KubeJS 1902.6.2-build.42

commented

A temporary workaround for this is to wrap any events like that inside a check for Platform.isClientEnvironment() like so:

if (Platform.isClientEnvironment()) {
  ClientEvents.init(event => {
    event.doStuff()
  })
}