diff --git a/src/app/components/generator/McdocRenderer.tsx b/src/app/components/generator/McdocRenderer.tsx
index 2fda1131..78a2c8e2 100644
--- a/src/app/components/generator/McdocRenderer.tsx
+++ b/src/app/components/generator/McdocRenderer.tsx
@@ -17,6 +17,13 @@ import { ItemDisplay } from '../ItemDisplay.jsx'
import { Octicon } from '../Octicon.jsx'
const SPECIAL_UNSET = '__unset__'
+const ANY_TYPES: SimplifiedMcdocType[] = [
+ { kind: 'boolean' },
+ { kind: 'double' },
+ { kind: 'string' },
+ { kind: 'list', item: { kind: 'any' } },
+ { kind: 'struct', fields: [ { kind: 'pair', key: { kind: 'string' }, type: { kind: 'any' } }] },
+]
export interface McdocContext extends core.CheckerContext {}
@@ -77,6 +84,9 @@ function Head({ type, optional, node, makeEdit, ctx }: Props) {
if (type.kind === 'literal') {
return
}
+ if (type.kind === 'any' || type.kind === 'unsafe') {
+ return
+ }
return <>>
}
@@ -424,6 +434,32 @@ function LiteralHead({ type }: Props) {
return
}
+function AnyHead({ optional, node, makeEdit, ctx }: Props) {
+ const { locale } = useLocale()
+
+ const selectedType = findSelectedAnyType(node)
+
+ const onSelect = useCallback((newValue: string) => {
+ makeEdit((range) => {
+ const newSelected = ANY_TYPES.find(t => t.kind === newValue)
+ if (!newSelected) {
+ return undefined
+ }
+ return getDefault(newSelected, range, ctx)
+ })
+ }, [makeEdit, ctx])
+
+ return <>
+
+ {selectedType && }
+ >
+}
+
function Body({ type, optional, node, makeEdit, ctx }: Props) {
if (type.kind === 'union') {
return
@@ -457,6 +493,9 @@ function Body({ type, optional, node, makeEdit, ctx }: Props
}
+ if (type.kind === 'any' || type.kind === 'unsafe') {
+ return
+ }
return <>>
}
@@ -802,6 +841,16 @@ function TupleBody({ type, node, makeEdit, ctx }: Props) {
>
}
+function AnyBody({ optional, node, makeEdit, ctx }: Props) {
+ const selectedType = findSelectedAnyType(node)
+
+ if (!selectedType) {
+ return <>>
+ }
+
+ return
+}
+
interface ErrorsProps {
type: SimplifiedMcdocType
node: JsonNode | undefined
@@ -1133,7 +1182,7 @@ function quickEqualTypes(a: SimplifiedMcdocType, b: SimplifiedMcdocType) {
function findSelectedMember(_union: UnionType, node: JsonNode | undefined) {
const selectedType = node?.typeDef
- if (!selectedType) {
+ if (!selectedType || selectedType.kind === 'any' || selectedType.kind === 'unsafe') {
return undefined
}
if (selectedType.kind === 'union') {
@@ -1143,3 +1192,14 @@ function findSelectedMember(_union: UnionType, node:
}
return selectedType
}
+
+function findSelectedAnyType(node: JsonNode | undefined) {
+ switch (node?.type) {
+ case 'json:boolean': return ANY_TYPES[0]
+ case 'json:number': return ANY_TYPES[1]
+ case 'json:string': return ANY_TYPES[2]
+ case 'json:array': return ANY_TYPES[3]
+ case 'json:object': return ANY_TYPES[4]
+ default: return undefined
+ }
+}
diff --git a/src/app/services/Spyglass.ts b/src/app/services/Spyglass.ts
index 6d1e0116..a9f5b628 100644
--- a/src/app/services/Spyglass.ts
+++ b/src/app/services/Spyglass.ts
@@ -27,9 +27,12 @@ use ::java::data::worldgen::dimension::Dimension
dispatch minecraft:resource[text_component] to Text
dispatch minecraft:resource[world] to struct WorldSettings {
- generate_features: boolean,
- bonus_chest: boolean,
seed: #[random] long,
+ /// Defaults to \`true\`.
+ generate_features?: boolean,
+ /// Defaults to \`false\`.
+ bonus_chest?: boolean,
+ legacy_custom_options?: string,
dimensions: struct {
[#[id="dimension"] string]: Dimension,
},