mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-24 23:56:51 +00:00
Add noise caves to preview
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { DataModel, Path } from '@mcschema/core'
|
||||
import type { NoiseOctaves } from 'deepslate'
|
||||
import type { NoiseParameters } from 'deepslate'
|
||||
import { NoiseGeneratorSettings, TerrainShaper } from 'deepslate'
|
||||
import { useEffect, useRef, useState } from 'preact/hooks'
|
||||
import type { PreviewProps } from '.'
|
||||
@@ -103,11 +103,11 @@ export const BiomeSourcePreview = ({ model, data, shown, version }: PreviewProps
|
||||
</>
|
||||
}
|
||||
|
||||
function calculateState(data: any, octaves: NoiseOctaves, shaper: TerrainShaper) {
|
||||
function calculateState(data: any, octaves: Record<string, NoiseParameters>, shaper: TerrainShaper) {
|
||||
return JSON.stringify([data, octaves, shaper.toJson()])
|
||||
}
|
||||
|
||||
export function getOctaves(obj: any): NoiseOctaves {
|
||||
export function getOctaves(obj: any): Record<string, NoiseParameters> {
|
||||
if (typeof obj !== 'string') {
|
||||
const settings = NoiseGeneratorSettings.fromJson(DataModel.unwrapLists(obj))
|
||||
obj = settings.legacyRandomSource ? 'minecraft:nether' : 'minecraft:overworld'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DataModel } from '@mcschema/core'
|
||||
import type { NoiseOctaves } from 'deepslate'
|
||||
import type { NoiseParameters } from 'deepslate'
|
||||
import { FixedBiome, LegacyRandom, NormalNoise, TerrainShaper } from 'deepslate'
|
||||
import init, { biome_parameters, climate_noise, climate_sampler, multi_noise } from 'deepslate-rs'
|
||||
// @ts-expect-error
|
||||
@@ -30,7 +30,7 @@ const LAYERS = {
|
||||
type Triple = [number, number, number]
|
||||
type BiomeColors = Record<string, Triple>
|
||||
type BiomeSourceOptions = {
|
||||
octaves: NoiseOctaves,
|
||||
octaves: Record<string, NoiseParameters>,
|
||||
shaper: TerrainShaper,
|
||||
biomeColors: BiomeColors,
|
||||
offset: [number, number],
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { DataModel } from '@mcschema/core'
|
||||
import type { BlockState } from 'deepslate'
|
||||
import { BlockPos, Chunk, ChunkPos, FixedBiome, NoiseChunkGenerator, NoiseGeneratorSettings } from 'deepslate'
|
||||
import { getOctaves } from '../components'
|
||||
import type { VersionId } from '../services'
|
||||
import { checkVersion } from '../services'
|
||||
import { deepClone, deepEqual } from '../Utils'
|
||||
@@ -91,7 +90,6 @@ export function getNoiseBlock(x: number, y: number) {
|
||||
|
||||
function getCached(state: unknown, options: NoiseSettingsOptions) {
|
||||
const settings = NoiseGeneratorSettings.fromJson(DataModel.unwrapLists(state))
|
||||
settings.octaves = getOctaves(settings)
|
||||
|
||||
const newState = [state, `${options.seed}`, options.biome]
|
||||
if (!deepEqual(newState, cacheState)) {
|
||||
|
||||
Reference in New Issue
Block a user