Skip to content

Commit

Permalink
chore: up mc-data, fix cam reset
Browse files Browse the repository at this point in the history
fix: hide add server UI after adding a server
  • Loading branch information
zardoy committed May 5, 2024
1 parent d1d47b3 commit 3696233
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 47 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"jszip": "^3.10.1",
"lodash-es": "^4.17.21",
"minecraft-assets": "^1.12.2",
"minecraft-data": "3.62.0",
"minecraft-data": "3.65.0",
"net-browserify": "github:zardoy/prismarinejs-net-browserify",
"node-gzip": "^1.1.2",
"peerjs": "^1.5.0",
Expand Down Expand Up @@ -154,7 +154,7 @@
"diamond-square": "github:zardoy/diamond-square",
"prismarine-block": "github:zardoy/prismarine-block#next-era",
"prismarine-world": "github:zardoy/prismarine-world#next-era",
"minecraft-data": "3.62.0",
"minecraft-data": "3.65.0",
"prismarine-provider-anvil": "github:zardoy/prismarine-provider-anvil#everything",
"minecraft-protocol": "github:zardoy/minecraft-protocol#everything",
"react": "^18.2.0",
Expand Down
60 changes: 30 additions & 30 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions prismarine-viewer/viewer/lib/mesher/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,7 @@ function renderElement (world: World, cursor: Vec3, element, doAO: boolean, attr

const aos: number[] = []
const neighborPos = position.plus(new Vec3(...dir))
let baseLightLevel = world.getLight(neighborPos)
const baseLight = baseLightLevel / 15
const baseLight = world.getLight(neighborPos) / 15
for (const pos of corners) {
let vertex = [
(pos[0] ? maxx : minx),
Expand Down Expand Up @@ -418,6 +417,7 @@ function renderElement (world: World, cursor: Vec3, element, doAO: boolean, attr
attr.tiles[`${cursor.x},${cursor.y},${cursor.z}`].faces.push({
face,
neighbor: `${neighborPos.x},${neighborPos.y},${neighborPos.z}`,
light: baseLight
// texture: eFace.texture.name,
})
}
Expand Down
15 changes: 11 additions & 4 deletions prismarine-viewer/viewer/lib/mesher/test/mesherTester.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { setBlockStatesData, getSectionGeometry } from '../models'
import { World as MesherWorld } from '../world'
import ChunkLoader from 'prismarine-chunk'
import ChunkLoader, { PCChunk } from 'prismarine-chunk'
import { Vec3 } from 'vec3'
import MinecraftData from 'minecraft-data'

Expand All @@ -26,18 +26,25 @@ export const setup = (version, initialBlocks: [number[], string][]) => {
return {
centerFaces,
totalTiles,
centerTileNeighbors
centerTileNeighbors,
faces: sectionGeometry.tiles[`${pos.x},${pos.y},${pos.z}`]?.faces ?? []
}
}

setBlockStatesData(blockStates, true)
mesherWorld.addColumn(0, 0, chunk1.toJson())
const reload = () => {
mesherWorld.removeColumn(0, 0)
mesherWorld.addColumn(0, 0, chunk1.toJson())
}
reload()

return {
mesherWorld,
getGeometry,
pos,
mcData
mcData,
reload,
chunk: chunk1 as PCChunk
}
}

Expand Down
4 changes: 2 additions & 2 deletions prismarine-viewer/viewer/lib/viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ export class Viewer {

this.scene = new THREE.Scene()
this.scene.matrixAutoUpdate = false // for perf
this.resetScene()
this.threeJsWorld = new WorldRendererThree(this.scene, this.renderer, this.camera, worldConfig)
this.threeJsWorld = new WorldRendererThree(this.scene, this.renderer, worldConfig)
this.setWorld()
this.resetScene()
this.entities = new Entities(this.scene)
// this.primitives = new Primitives(this.scene, this.camera)

Expand Down
2 changes: 1 addition & 1 deletion prismarine-viewer/viewer/lib/worldrendererThree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class WorldRendererThree extends WorldRendererCommon {
return Object.values(this.sectionObjects).reduce((acc, obj) => acc + (obj as any).tilesCount, 0)
}

constructor(public scene: THREE.Scene, public renderer: THREE.WebGLRenderer, public camera: THREE.PerspectiveCamera, public config: WorldRendererConfig) {
constructor(public scene: THREE.Scene, public renderer: THREE.WebGLRenderer, public config: WorldRendererConfig) {
super(config)
}

Expand Down
9 changes: 3 additions & 6 deletions src/react/ServersListProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,13 @@ const Inner = () => {

const isEditScreenModal = useIsModalActive('editServer')

useEffect(() => {
if (!isEditScreenModal) {
setServerEditScreen(null)
}
}, [isEditScreenModal])

useEffect(() => {
if (serverEditScreen && !isEditScreenModal) {
showModal({ reactType: 'editServer' })
}
if (!serverEditScreen && isEditScreenModal) {
hideCurrentModal()
}
}, [serverEditScreen])

if (isEditScreenModal) {
Expand Down

0 comments on commit 3696233

Please sign in to comment.