mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-23 07:10:41 +00:00
Fix #176 switching between choices
This commit is contained in:
14
package-lock.json
generated
14
package-lock.json
generated
@@ -9,7 +9,7 @@
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@mcschema/core": "^0.12.10",
|
||||
"@mcschema/core": "^0.12.11",
|
||||
"@mcschema/java-1.15": "^0.2.2",
|
||||
"@mcschema/java-1.16": "^0.6.5",
|
||||
"@mcschema/java-1.17": "^0.2.24",
|
||||
@@ -316,9 +316,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@mcschema/core": {
|
||||
"version": "0.12.10",
|
||||
"resolved": "https://registry.npmjs.org/@mcschema/core/-/core-0.12.10.tgz",
|
||||
"integrity": "sha512-uPP6iiVaml5MUBbcu5tnl3atadAwdQOpXBZdpoDMjLX+7nUUUAjiynHpbwXVeqTgO473j4QI2EQv2NqPH+wCSw=="
|
||||
"version": "0.12.11",
|
||||
"resolved": "https://registry.npmjs.org/@mcschema/core/-/core-0.12.11.tgz",
|
||||
"integrity": "sha512-YNB9aUr7szseHfMxL/XJaAObMOZ94sXBmgu+miqdNHUSWgVMKLYBv1LJ2r5p8EY3EtULjq8YXxRxC8NYUJCEig=="
|
||||
},
|
||||
"node_modules/@mcschema/java-1.15": {
|
||||
"version": "0.2.2",
|
||||
@@ -2913,9 +2913,9 @@
|
||||
}
|
||||
},
|
||||
"@mcschema/core": {
|
||||
"version": "0.12.10",
|
||||
"resolved": "https://registry.npmjs.org/@mcschema/core/-/core-0.12.10.tgz",
|
||||
"integrity": "sha512-uPP6iiVaml5MUBbcu5tnl3atadAwdQOpXBZdpoDMjLX+7nUUUAjiynHpbwXVeqTgO473j4QI2EQv2NqPH+wCSw=="
|
||||
"version": "0.12.11",
|
||||
"resolved": "https://registry.npmjs.org/@mcschema/core/-/core-0.12.11.tgz",
|
||||
"integrity": "sha512-YNB9aUr7szseHfMxL/XJaAObMOZ94sXBmgu+miqdNHUSWgVMKLYBv1LJ2r5p8EY3EtULjq8YXxRxC8NYUJCEig=="
|
||||
},
|
||||
"@mcschema/java-1.15": {
|
||||
"version": "0.2.2",
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"author": "Misode",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@mcschema/core": "^0.12.10",
|
||||
"@mcschema/core": "^0.12.11",
|
||||
"@mcschema/java-1.15": "^0.2.2",
|
||||
"@mcschema/java-1.16": "^0.6.5",
|
||||
"@mcschema/java-1.17": "^0.2.24",
|
||||
|
||||
@@ -140,17 +140,3 @@ export function deepEqual(a: any, b: any) {
|
||||
}
|
||||
return a !== a && b !== b
|
||||
}
|
||||
|
||||
export function unwrapLists(value: any): any {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(v => unwrapLists(v.node))
|
||||
} else if (typeof value === 'object' && value !== null) {
|
||||
const res: Record<string, any> = {}
|
||||
Object.entries(value).map(([k, v]) => {
|
||||
res[k] = unwrapLists(v)
|
||||
})
|
||||
return res
|
||||
} else {
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { DataModel } from '@mcschema/core'
|
||||
import type { BiomeSource, Climate, NoiseOctaves } from 'deepslate'
|
||||
import { FixedBiome, MultiNoise, NoiseGeneratorSettings, NoiseSampler, NormalNoise, Random } from 'deepslate'
|
||||
import { fetchPreset } from '../DataFetcher'
|
||||
import type { VersionId } from '../Schemas'
|
||||
import { clamp, deepClone, deepEqual, square, stringToColor, unwrapLists } from '../Utils'
|
||||
import { clamp, deepClone, deepEqual, square, stringToColor } from '../Utils'
|
||||
|
||||
type BiomeColors = Record<string, number[]>
|
||||
type BiomeSourceOptions = {
|
||||
@@ -90,7 +91,7 @@ async function getBiomeSource(state: any, options: BiomeSourceOptions): Promise<
|
||||
state = options.version === '1.18' ? await OverworldPreset18() : state
|
||||
break
|
||||
}
|
||||
state = unwrapLists(state)
|
||||
state = DataModel.unwrapLists(state)
|
||||
if (options.version === '1.18') {
|
||||
return MultiNoise.fromJson(state)
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { DataModel } from '@mcschema/core'
|
||||
import { PerlinNoise, Random } from 'deepslate'
|
||||
import type { VersionId } from '../Schemas'
|
||||
import { clamp, stringToColor, unwrapLists } from '../Utils'
|
||||
import { clamp, stringToColor } from '../Utils'
|
||||
|
||||
type BlockPos = [number, number, number]
|
||||
type Placement = [BlockPos, number]
|
||||
@@ -49,7 +50,7 @@ export function decorator(state: any, img: ImageData, options: DecoratorOptions)
|
||||
|
||||
for (let x = 0; x < options.size[0] / 16; x += 1) {
|
||||
for (let z = 0; z < options.size[2] / 16; z += 1) {
|
||||
getPlacements([x * 16, 0, z * 16], unwrapLists(state), ctx)
|
||||
getPlacements([x * 16, 0, z * 16], DataModel.unwrapLists(state), ctx)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { DataModel } from '@mcschema/core'
|
||||
import type { BlockPos, BlockState } from 'deepslate'
|
||||
import { Chunk, ChunkPos, FixedBiome, NoiseChunkGenerator, NoiseGeneratorSettings } from 'deepslate'
|
||||
import type { VersionId } from '../Schemas'
|
||||
import { checkVersion } from '../Schemas'
|
||||
import { deepClone, deepEqual, unwrapLists } from '../Utils'
|
||||
import { deepClone, deepEqual } from '../Utils'
|
||||
import { NoiseChunkGenerator as OldNoiseChunkGenerator } from './noise/NoiseChunkGenerator'
|
||||
|
||||
export type NoiseSettingsOptions = {
|
||||
@@ -70,7 +71,7 @@ export function noiseSettings(state: any, img: ImageData, options: NoiseSettings
|
||||
}
|
||||
|
||||
function getCached(state: unknown, options: NoiseSettingsOptions) {
|
||||
const settings = NoiseGeneratorSettings.fromJson(unwrapLists(state))
|
||||
const settings = NoiseGeneratorSettings.fromJson(DataModel.unwrapLists(state))
|
||||
// Temporary fix for slides
|
||||
settings.noise.bottomSlide.target *= 128
|
||||
settings.noise.topSlide.target *= 128
|
||||
|
||||
@@ -65,12 +65,12 @@ const renderHtml: RenderHook = {
|
||||
return [prefix, suffix, body]
|
||||
}
|
||||
const choiceContextPath = config?.choiceContext ? new Path([], [config.choiceContext]) : config?.context ? new Path([], [config.context]) : path
|
||||
const set = (value: string) => {
|
||||
const c = choices.find(c => c.type === value) ?? choice
|
||||
const set = (type: string) => {
|
||||
const c = choices.find(c => c.type === type) ?? choice
|
||||
const newValue = c.change
|
||||
? c.change(value, { wrapLists: true })
|
||||
: DataModel.wrapLists(config.choiceContext === 'feature' ? c.node.default()?.config?.feature : c.node.default())
|
||||
path.model.set(path, newValue)
|
||||
? c.change(DataModel.unwrapLists(value))
|
||||
: config.choiceContext === 'feature' ? c.node.default()?.config?.feature : c.node.default()
|
||||
path.model.set(path, DataModel.wrapLists(newValue))
|
||||
}
|
||||
const inject = <select value={choice.type} onChange={(e) => set((e.target as HTMLSelectElement).value)}>
|
||||
{choices.map(c => <option value={c.type}>
|
||||
|
||||
Reference in New Issue
Block a user