Skip to content

Commit 34eecc1

Browse files
committed
feat: rework singleplayer generators types. now any generator can be used internally. add a few
1 parent fec887c commit 34eecc1

File tree

6 files changed

+11
-47
lines changed

6 files changed

+11
-47
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"esbuild-plugin-polyfill-node": "^0.3.0",
7777
"express": "^4.18.2",
7878
"filesize": "^10.0.12",
79-
"flying-squid": "npm:@zardoy/flying-squid@^0.0.59",
79+
"flying-squid": "npm:@zardoy/flying-squid@^0.0.62",
8080
"framer-motion": "^12.9.2",
8181
"fs-extra": "^11.1.1",
8282
"google-drive-browserfs": "github:zardoy/browserfs#google-drive",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/loadSave.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ export const loadSave = async (root = '/world', connectOptions?: Partial<Connect
8585
}
8686

8787
let version: string | undefined | null
88-
let isFlat = false
8988
if (levelDat) {
9089
version = appQueryParams.mapVersion ?? levelDat.Version?.Name
9190
if (!version) {
@@ -103,21 +102,6 @@ export const loadSave = async (root = '/world', connectOptions?: Partial<Connect
103102
version = prompt(`Version ${version} is not supported, supported versions are ${supportedVersions.join(', ')}, what try to use instead?`, lowerBound ? firstSupportedVersion : lastSupportedVersion)
104103
if (!version) return
105104
}
106-
if (levelDat.WorldGenSettings) {
107-
for (const [key, value] of Object.entries(levelDat.WorldGenSettings.dimensions)) {
108-
if (key.slice(10) === 'overworld') {
109-
if (value.generator.type === 'flat') isFlat = true
110-
break
111-
}
112-
}
113-
}
114-
115-
if (levelDat.generatorName) {
116-
isFlat = levelDat.generatorName === 'flat'
117-
}
118-
if (!isFlat && levelDat.generatorName !== 'default' && levelDat.generatorName !== 'customized') {
119-
// warnings.push(`Generator ${levelDat.generatorName} may not be supported yet, be careful of new chunks writes`)
120-
}
121105

122106
const playerUuid = nameToMcOfflineUUID(options.localUsername)
123107
const playerDatPath = `${root}/playerdata/${playerUuid}.dat`
@@ -188,11 +172,6 @@ export const loadSave = async (root = '/world', connectOptions?: Partial<Connect
188172
// todo check gamemode level.dat data etc
189173
detail: {
190174
version,
191-
...isFlat ? {
192-
generation: {
193-
name: 'superflat'
194-
}
195-
} : {},
196175
...root === '/world' ? {} : {
197176
'worldFolder': root
198177
},

src/react/CreateWorld.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import styles from './createWorld.module.css'
1111
import { InputOption, showInputsModal, showOptionsModal } from './SelectOption'
1212

1313
// const worldTypes = ['default', 'flat', 'largeBiomes', 'amplified', 'customized', 'buffet', 'debug_all_block_states']
14-
const worldTypes = ['default', 'flat'/* , 'void' */]
14+
const worldTypes = ['default', 'flat', 'empty', 'nether', 'all_the_blocks']
1515
const gameModes = ['survival', 'creative'/* , 'adventure', 'spectator' */]
1616

1717
export const creatingWorldState = proxy({

src/react/CreateWorldProvider.tsx

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,14 @@ export default () => {
3232
const savePath = await uniqueFileNameFromWorldName(title, getWorldsPath())
3333
await mkdirRecursive(savePath)
3434
await loadPluginsIntoWorld(savePath, plugins)
35-
let generation
36-
if (type === 'flat') {
37-
generation = {
38-
name: 'superflat',
39-
}
40-
}
41-
if (type === 'void') {
42-
generation = {
43-
name: 'superflat',
44-
layers: [],
45-
noDefaults: true
46-
}
47-
}
48-
if (type === 'nether') {
49-
generation = {
50-
name: 'nether'
51-
}
52-
}
5335
hideCurrentModal()
5436
window.dispatchEvent(new CustomEvent('singleplayer', {
5537
detail: {
5638
levelName: title,
5739
version,
58-
generation,
40+
generation: {
41+
name: type
42+
},
5943
'worldFolder': savePath,
6044
gameMode: gameMode === 'survival' ? 0 : 1,
6145
},

src/sounds/botSoundSystem.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ subscribeKey(miscUiState, 'gameLoaded', async () => {
136136
let lastStepSound = 0
137137
const movementHappening = async () => {
138138
if (!bot.entity || !soundMap) return // no info yet
139+
if (appViewer.playerState.reactive.gameMode === 'spectator') return // Don't play step sounds in spectator mode
139140
const VELOCITY_THRESHOLD = 0.1
140141
const RUN_THRESHOLD = 0.15
141142
const { x, z, y } = bot.entity.velocity

0 commit comments

Comments
 (0)