Skip to content

Commit 4746e0d

Browse files
authored
Release (#454)
2 parents 5e447b4 + 10a8ef9 commit 4746e0d

16 files changed

Lines changed: 155 additions & 23 deletions
104 KB
Loading
124 KB
Loading
164 KB
Loading
109 KB
Loading
67.9 KB
Loading
45.7 KB
Loading

pnpm-lock.yaml

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

renderer/viewer/three/panorama.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import { EntityMesh } from './entity/EntityMesh'
1515
import { DocumentRenderer } from './documentRenderer'
1616
import { PANORAMA_VERSION } from './panoramaShared'
1717

18+
const date = new Date()
19+
const isChristmas = date.getMonth() === 11 && date.getDate() >= 24 && date.getDate() <= 26
20+
1821
const panoramaFiles = [
1922
'panorama_3.webp', // right (+x)
2023
'panorama_1.webp', // left (-x)
@@ -90,7 +93,7 @@ export class PanoramaRenderer {
9093

9194
for (const file of panoramaFiles) {
9295
const load = async () => {
93-
const { texture } = loadThreeJsTextureFromUrlSync(join('background', file))
96+
const { texture } = loadThreeJsTextureFromUrlSync(join('background', isChristmas ? 'christmas' : '', file))
9497

9598
// Instead of using repeat/offset to flip, we'll use the texture matrix
9699
texture.matrixAutoUpdate = false
@@ -139,17 +142,19 @@ export class PanoramaRenderer {
139142
const group = new THREE.Object3D()
140143
group.add(panoramaBox)
141144

142-
// Add squids
143-
for (let i = 0; i < 20; i++) {
144-
const m = new EntityMesh('1.16.4', 'squid').mesh
145-
m.position.set(Math.random() * 30 - 15, Math.random() * 20 - 10, Math.random() * 10 - 17)
146-
m.rotation.set(0, Math.PI + Math.random(), -Math.PI / 4, 'ZYX')
147-
const v = Math.random() * 0.01
148-
m.children[0].onBeforeRender = () => {
149-
m.rotation.y += v
150-
m.rotation.z = Math.cos(panoramaBox.rotation.y * 3) * Math.PI / 4 - Math.PI / 2
145+
if (!isChristmas) {
146+
// Add entities
147+
for (let i = 0; i < 20; i++) {
148+
const m = new EntityMesh('1.16.4', 'squid').mesh
149+
m.position.set(Math.random() * 30 - 15, Math.random() * 20 - 10, Math.random() * 10 - 17)
150+
m.rotation.set(0, Math.PI + Math.random(), -Math.PI / 4, 'ZYX')
151+
const v = Math.random() * 0.01
152+
m.children[0].onBeforeRender = () => {
153+
m.rotation.y += v
154+
m.rotation.z = Math.cos(panoramaBox.rotation.y * 3) * Math.PI / 4 - Math.PI / 2
155+
}
156+
group.add(m)
151157
}
152-
group.add(m)
153158
}
154159

155160
this.scene.add(group)

src/customChannels.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { getThreeJsRendererMethods } from 'renderer/viewer/three/threeJsMethods'
44
import { options } from './optionsStorage'
55
import { jeiCustomCategories } from './inventoryWindows'
66
import { registerIdeChannels } from './core/ideChannels'
7+
import { serverSafeSettings } from './defaultOptions'
78

89
export default () => {
910
customEvents.on('mineflayerBotCreated', async () => {
@@ -17,6 +18,7 @@ export default () => {
1718
registerWaypointChannels()
1819
registerFireworksChannels()
1920
registerIdeChannels()
21+
registerServerSettingsChannel()
2022
})
2123
})
2224
}
@@ -525,6 +527,67 @@ const addTestVideo = (rotation = 0 as 0 | 1 | 2 | 3, scale = 1, isImage = false)
525527
}
526528
window.addTestVideo = addTestVideo
527529

530+
const registerServerSettingsChannel = () => {
531+
const CHANNEL_NAME = 'minecraft-web-client:server-settings'
532+
const packetStructure = [
533+
'container',
534+
[
535+
{
536+
name: 'settingsJson',
537+
type: ['pstring', { countType: 'i16' }]
538+
},
539+
]
540+
]
541+
542+
registerChannel(CHANNEL_NAME, packetStructure, (data) => {
543+
try {
544+
const settings = JSON.parse(data.settingsJson)
545+
546+
if (typeof settings !== 'object' || settings === null || Array.isArray(settings)) {
547+
console.warn('Invalid settings format: expected an object')
548+
return
549+
}
550+
551+
let appliedCount = 0
552+
let skippedCount = 0
553+
554+
for (const [key, value] of Object.entries(settings)) {
555+
// Only apply settings that are in the safe list
556+
if (!(key in serverSafeSettings)) {
557+
console.warn(`Skipping unsafe setting: ${key}`)
558+
skippedCount++
559+
continue
560+
}
561+
562+
// Validate that the setting exists in options
563+
if (!(key in options)) {
564+
console.warn(`Setting does not exist: ${key}`)
565+
skippedCount++
566+
continue
567+
}
568+
569+
// Validate type matches
570+
const currentValue = options[key]
571+
572+
// For union types, check if value is valid
573+
if (Array.isArray(currentValue) && !Array.isArray(value)) {
574+
console.warn(`Type mismatch for setting ${key}: expected array`)
575+
skippedCount++
576+
continue
577+
}
578+
579+
// Apply the setting
580+
options[key] = value
581+
appliedCount++
582+
}
583+
584+
console.debug(`Applied ${appliedCount} server settings${skippedCount > 0 ? `, skipped ${skippedCount} unsafe/invalid settings` : ''}`)
585+
} catch (error) {
586+
console.error('Failed to parse or apply server settings:', error)
587+
}
588+
}, false) // Don't wait for world, settings can be applied before world loads
589+
}
590+
528591
function getCurrentTopDomain (): string {
529592
const { hostname } = location
530593
// Split hostname into parts

src/defaultOptions.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,46 @@ function getTouchControlsSize () {
158158
sneak: 36,
159159
}
160160
}
161+
162+
/**
163+
* Map of settings that are safe to change from the server.
164+
* These are rendering/display/input preferences that don't affect critical client functionality.
165+
* Settings like modsSupport, customChannels, or security-related options are excluded.
166+
*/
167+
export const serverSafeSettings: Partial<Record<keyof typeof defaultOptions, true>> = {
168+
renderEars: true,
169+
viewBobbing: true,
170+
mouseRawInput: true,
171+
preciseMouseInput: true,
172+
showHand: true,
173+
fov: true,
174+
defaultPerspective: true,
175+
volume: true,
176+
musicVolume: true,
177+
enableMusic: true,
178+
smoothLighting: true,
179+
starfieldRendering: true,
180+
defaultSkybox: true,
181+
dayCycleAndLighting: true,
182+
showChunkBorders: true,
183+
renderDebug: true,
184+
highlightBlockColor: true,
185+
displayBossBars: true,
186+
showMinimap: true,
187+
autoJump: true,
188+
chatVanillaRestrictions: true,
189+
chatPingExtension: true,
190+
chatSpellCheckEnabled: true,
191+
renderEntities: true,
192+
displayRecordButton: true,
193+
topRightTimeDisplay: true,
194+
guiScale: true,
195+
chatWidth: true,
196+
chatHeight: true,
197+
chatScale: true,
198+
loadPlayerSkins: true,
199+
disableBlockEntityTextures: true,
200+
neighborChunkUpdates: true,
201+
newVersionsLighting: true,
202+
showCursorBlockInSpectator: true,
203+
}

0 commit comments

Comments
 (0)