Skip to content

[1.21.1] NPE in KubeJS stationResearch/scannerResearch when no other condition was added first #5106

Description

@ascorblack

Checked for existing issues

  • I have checked for existing issues, and have found none.

Tested latest version

  • I have checked that this occurs on the latest version.

GregTech CEu Version

gtceu-1.21.1-8.0.0-SNAPSHOT+20260620-180128-b71dec5

Minecraft Version

1.21.1 NeoForge (21.1.235)

Recipe Viewer Installed

JEI

Environment

Singleplayer (also on Dedicated Server)

Cross-Mod Interaction

Yes — KubeJS 2101.7.2-build.368

Other Installed Mods

GTCEu + KubeJS + dependencies are sufficient to reproduce.

Expected Behavior

Calling .stationResearch(...) / .scannerResearch(...) on a KubeJS recipe registers the research condition (as in GTCEu 1.x).

Actual Behavior

java.lang.NullPointerException: Cannot invoke "java.util.List.stream()" because the return value of
"com.gregtechceu.gtceu.integration.kjs.recipe.GTRecipeSchema$GTKubeRecipe.getValue(dev.latvian.mods.kubejs.recipe.RecipeKey)" is null
	at ...GTRecipeSchema$GTKubeRecipe.applyResearchProperty(GTRecipeSchema.java:1085)
	at ...GTRecipeSchema$GTKubeRecipe.stationResearch(GTRecipeSchema.java:1150)

Steps to Reproduce

  1. machines.enableResearch = true (default).
  2. Server script:
ServerEvents.recipes(event => {
    event.recipes.gtceu.assembly_line('test:npe')
        .itemInputs('minecraft:iron_ingot')
        .itemOutputs('minecraft:gold_ingot')
        .duration(100)
        .EUt(30)
        .stationResearch(b => b.researchStack(Item.of('minecraft:diamond')).EUt(122880).CWUt(32))
})
  1. NPE — unless any other condition (e.g. .cleanroom(...)) was added before the research call.

Additional Information

Root cause: CONDITIONS is a defaultOptional() key. addCondition guards against null (if (getValue(CONDITIONS) == null) setValue(CONDITIONS, new ArrayList<>()), GTRecipeSchema.java:152), but applyResearchProperty calls this.getValue(CONDITIONS).stream() directly (line ~1085) and NPEs when no condition was added yet. Workaround: call .cleanroom(...) (or any condition) before .stationResearch(...).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions