mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-23 23:27:09 +00:00
Fix #642 more validation in loot table preview
This commit is contained in:
@@ -271,7 +271,7 @@ function composeFunctions(functions: any[]): LootFunction {
|
||||
for (const fn of functions) {
|
||||
if (Array.isArray(fn)) {
|
||||
composeFunctions(fn)
|
||||
} else if (composeConditions(fn.conditions ?? [])(ctx)) {
|
||||
} else if (isObject(fn) && composeConditions(fn.conditions ?? [])(ctx)) {
|
||||
const type = fn.function?.replace(/^minecraft:/, '');
|
||||
(LootFunctions[type]?.(fn) ?? (i => i))(item, ctx)
|
||||
}
|
||||
@@ -403,6 +403,9 @@ function testCondition(condition: any, ctx: LootContext): boolean {
|
||||
if (Array.isArray(condition)) {
|
||||
return composeConditions(condition)(ctx)
|
||||
}
|
||||
if (!isObject(condition) || typeof condition.condition !== 'string') {
|
||||
return false
|
||||
}
|
||||
const type = condition.condition?.replace(/^minecraft:/, '')
|
||||
return (LootConditions[type]?.(condition) ?? (() => true))(ctx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user