Catching of exceptions from RecipeComponent#read causes errors from StringComponent#DYNAMIC to be lost to scripters
ChiefArug opened this issue ยท 1 comments
Minecraft Version
1.20.1
KubeJS Version
kubejs-forge-2001.6.4-build.114.jar
Rhino Version
rhino-forge-2001.2.2-build.18.jar
Architectury Version
architectury-9.1.12-forge.jar
Forge/Fabric Version
47.2.17
Describe your issue
The try/catch here:
Instead an error like
! example.js#2: Failed to create recipe for type 'eidolon:worktable': Unable to cast 'reagents:string' value 'SBB' to 'string'!
shows up.
Test case (requires Eidolon: Rebrewed):
//type: startup
const $RecipeSchema = Java.loadClass('dev.latvian.mods.kubejs.recipe.schema.RecipeSchema')
const $ShapedRecipeSchema = Java.loadClass('dev.latvian.mods.kubejs.recipe.schema.minecraft.ShapedRecipeSchema')
StartupEvents.recipeSchemaRegistry(event => {
const Components = event.components
let worktableSchema = new $RecipeSchema(
$ShapedRecipeSchema.RESULT,
$ShapedRecipeSchema.PATTERN,
Components.get('filteredString')
({ error: "reagents must have a length of four", filter: s => s.length == 4})
.key('reagents'),
$ShapedRecipeSchema.KEY
)
event.register('eidolon:worktable', worktableSchema);
})
//type: server
ServerEvents.recipes(event => {
event.recipes.eidolon.worktable('apple', [
' R ',
'RPR',
' R '
], 'SBB', {
S: 'wheat_seeds',
B: 'bone_meal',
R: 'red_dye',
P: 'potato'
});
})
The error here is that the reagents string (the SBB in the middle) must be of length four, but it shows up as a 'cannot cast' error, not the custom error message.
Crash report/logs
No response