Skip to content

Commit

Permalink
fix: restore item models
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Jul 20, 2024
1 parent 316b11d commit 2529d61
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/genBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { makeTextureAtlas } from './atlasNode'
import { join } from 'path'

const rawData = JSON.parse(fs.readFileSync('./data/data-paths.json', 'utf8'))
const blockstatesModels = JSON.parse(fs.readFileSync('./temp/blockStatesModels.json', 'utf8'))
const blockstatesModels = JSON.parse(
fs.existsSync('./dist/blockStatesModels.json')
? fs.readFileSync('./dist/blockStatesModels.json', 'utf8')
: fs.readFileSync('./temp/blockStatesModels.json', 'utf8')
)

blockstatesModels.blockstates.latest['unknown'] = {
variants: {
Expand All @@ -23,20 +27,20 @@ blockstatesModels.models.latest['block/unknown'] = {
}
}

for (const [name, {textures = {}}] of Object.entries(blockstatesModels.models.latest)) {
for (const [name, { textures = {} }] of Object.entries(blockstatesModels.models.latest)) {
for (const texture of Object.values(textures as Record<string, string>)) {
const textureNameClean = texture.replace('block/', '');
const textureNamePath = textureNameClean+'.png';
const textureNameClean = texture.replace('block/', '')
const textureNamePath = textureNameClean + '.png'
if (!textureNamePath.startsWith('entity/')) continue
const texturePath = rawData.latest['textures/'][textureNamePath];
const texturePath = rawData.latest['textures/'][textureNamePath]
if (!texturePath) throw new Error(`Missing texture ${textureNamePath}: ${texture}`)
texturesAddLast[textureNameClean] = texturePath
}
}

const makeAtlas = (name, textures) => {
const { image, json } = makeTextureAtlas(Object.keys(textures), (name) => {
const texPath = textures[name]!;
const texPath = textures[name]!
const contents = `data:image/png;base64,${fs.readFileSync(join('data', `${texPath}`), 'base64')}`
return {
contents,
Expand Down

0 comments on commit 2529d61

Please sign in to comment.