up mc-assets to fix a few critical bugs
This commit is contained in:
parent
9f90d6a187
commit
34e02cfc1b
5 changed files with 30 additions and 18 deletions
|
|
@ -138,7 +138,7 @@
|
|||
"http-browserify": "^1.7.0",
|
||||
"http-server": "^14.1.1",
|
||||
"https-browserify": "^1.0.0",
|
||||
"mc-assets": "^0.2.5",
|
||||
"mc-assets": "^0.2.6",
|
||||
"minecraft-inventory-gui": "github:zardoy/minecraft-inventory-gui#next",
|
||||
"mineflayer": "github:zardoy/mineflayer",
|
||||
"mineflayer-pathfinder": "^2.4.4",
|
||||
|
|
|
|||
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
|
|
@ -335,8 +335,8 @@ importers:
|
|||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
mc-assets:
|
||||
specifier: ^0.2.5
|
||||
version: 0.2.5
|
||||
specifier: ^0.2.6
|
||||
version: 0.2.6
|
||||
minecraft-inventory-gui:
|
||||
specifier: github:zardoy/minecraft-inventory-gui#next
|
||||
version: https://codeload.github.com/zardoy/minecraft-inventory-gui/tar.gz/75e940a4cd50d89e0ba03db3733d5d704917a3c8(@types/react@18.2.20)(react@18.2.0)
|
||||
|
|
@ -6161,8 +6161,8 @@ packages:
|
|||
peerDependencies:
|
||||
react: ^18.2.0
|
||||
|
||||
mc-assets@0.2.5:
|
||||
resolution: {integrity: sha512-HZ4Q1zqbib2ySSorCb+vMkBZAGXTTZIlcSfGq/L15fkg+l+KKslLSivWfFlCXdg9bzGc0x5WeQN3kKWfZmyuFg==}
|
||||
mc-assets@0.2.6:
|
||||
resolution: {integrity: sha512-nGnnySeCPA514CA3WyTR5sz3vpUhUoB6pKL5qRemNaYkp5utbik7OkoW/44qrtuCFejQ1eMBvkRnDkSKLdzDdA==}
|
||||
engines: {node: '>=18.0.0'}
|
||||
|
||||
md5-file@4.0.0:
|
||||
|
|
@ -16288,7 +16288,7 @@ snapshots:
|
|||
dependencies:
|
||||
react: 18.2.0
|
||||
|
||||
mc-assets@0.2.5: {}
|
||||
mc-assets@0.2.6: {}
|
||||
|
||||
md5-file@4.0.0: {}
|
||||
|
||||
|
|
|
|||
|
|
@ -354,6 +354,7 @@ const invisibleBlocks = ['air', 'cave_air', 'void_air', 'barrier']
|
|||
const isBlockWaterlogged = (block: Block) => block.getProperties().waterlogged === true || block.getProperties().waterlogged === 'true'
|
||||
|
||||
let unknownBlockModel: BlockModelPartsResolved
|
||||
let erroredBlockModel: BlockModelPartsResolved
|
||||
export function getSectionGeometry (sx, sy, sz, world: World) {
|
||||
let delayedRender = [] as (() => void)[]
|
||||
|
||||
|
|
@ -372,7 +373,8 @@ export function getSectionGeometry (sx, sy, sz, world: World) {
|
|||
indices: [],
|
||||
tiles: {},
|
||||
// todo this can be removed here
|
||||
signs: {}
|
||||
signs: {},
|
||||
hadErrors: false
|
||||
} as Record<string, any>
|
||||
|
||||
const cursor = new Vec3(0, 0, 0)
|
||||
|
|
@ -437,7 +439,9 @@ export function getSectionGeometry (sx, sy, sz, world: World) {
|
|||
})!
|
||||
if (!models.length) models = null
|
||||
} catch (err) {
|
||||
models ??= erroredBlockModel
|
||||
console.error(`Critical assets error. Unable to get block model for ${block.name}[${JSON.stringify(block.getProperties())}]: ` + err.message, err.stack)
|
||||
attr.hadErrors = true
|
||||
}
|
||||
}
|
||||
block.models = models ?? null
|
||||
|
|
@ -526,6 +530,7 @@ export const setBlockStatesData = (blockstatesModels, blocksAtlas: any, _needTil
|
|||
globalThis.blockProvider = blockProvider
|
||||
if (useUnknownBlockModel) {
|
||||
unknownBlockModel = blockProvider.getAllResolvedModels0_1({ name: 'unknown', properties: {} })
|
||||
erroredBlockModel = blockProvider.getAllResolvedModels0_1({ name: 'errored', properties: {} })
|
||||
}
|
||||
|
||||
needTiles = _needTiles
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ export const setup = (version, initialBlocks: [number[], string][]) => {
|
|||
centerFaces,
|
||||
totalTiles,
|
||||
centerTileNeighbors,
|
||||
faces: sectionGeometry.tiles[`${pos.x},${pos.y},${pos.z}`]?.faces ?? []
|
||||
faces: sectionGeometry.tiles[`${pos.x},${pos.y},${pos.z}`]?.faces ?? [],
|
||||
attr: sectionGeometry
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ test('Known blocks are not rendered', () => {
|
|||
|
||||
let time = 0
|
||||
let times = 0
|
||||
const invalidBlocks = {}/* as {[number, number]} */
|
||||
const missingBlocks = {}/* as {[number, number]} */
|
||||
const erroredBlocks = {}/* as {[number, number]} */
|
||||
for (const block of mcData.blocksArray) {
|
||||
if (ignoreAsExpected.includes(block.name)) continue
|
||||
// if (block.maxStateId! - block.minStateId! > 100) continue
|
||||
|
|
@ -29,12 +30,13 @@ test('Known blocks are not rendered', () => {
|
|||
// if (block.transparent) continue
|
||||
mesherWorld.setBlockStateId(pos, i)
|
||||
const start = performance.now()
|
||||
const { centerFaces, totalTiles, centerTileNeighbors } = getGeometry()
|
||||
const { centerFaces, totalTiles, centerTileNeighbors, attr } = getGeometry()
|
||||
time += performance.now() - start
|
||||
times++
|
||||
if (centerFaces === 0) {
|
||||
if (invalidBlocks[block.name]) continue
|
||||
invalidBlocks[block.name] = true
|
||||
const objAdd = attr.hadErrors ? erroredBlocks : missingBlocks
|
||||
if (objAdd[block.name]) continue
|
||||
objAdd[block.name] = true
|
||||
// invalidBlocks[block.name] = [i - block.defaultState!, centerTileNeighbors]
|
||||
// console.log('INVALID', block.name, centerTileNeighbors, i - block.minStateId)
|
||||
}
|
||||
|
|
@ -42,15 +44,21 @@ test('Known blocks are not rendered', () => {
|
|||
}
|
||||
console.log('Average time', time / times)
|
||||
// should be fixed, but to avoid regressions & for visibility
|
||||
expect(invalidBlocks).toMatchInlineSnapshot(`
|
||||
expect(missingBlocks).toMatchInlineSnapshot(`
|
||||
{
|
||||
"bubble_column": true,
|
||||
"end_gateway": true,
|
||||
"end_portal": true,
|
||||
"structure_void": true,
|
||||
"trial_spawner": true,
|
||||
}
|
||||
`)
|
||||
expect(erroredBlocks).toMatchInlineSnapshot(`
|
||||
{
|
||||
"black_glazed_terracotta": true,
|
||||
"blue_glazed_terracotta": true,
|
||||
"brown_glazed_terracotta": true,
|
||||
"bubble_column": true,
|
||||
"cyan_glazed_terracotta": true,
|
||||
"end_gateway": true,
|
||||
"end_portal": true,
|
||||
"gray_glazed_terracotta": true,
|
||||
"green_glazed_terracotta": true,
|
||||
"light_blue_glazed_terracotta": true,
|
||||
|
|
@ -61,8 +69,6 @@ test('Known blocks are not rendered', () => {
|
|||
"pink_glazed_terracotta": true,
|
||||
"purple_glazed_terracotta": true,
|
||||
"red_glazed_terracotta": true,
|
||||
"structure_void": true,
|
||||
"trial_spawner": true,
|
||||
"white_glazed_terracotta": true,
|
||||
"yellow_glazed_terracotta": true,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue