fix(regression): fix rendering almost all items in the game, like shield, banners, beds, filled maps, ...
This commit is contained in:
parent
e2f28e4975
commit
4fd290c636
4 changed files with 39 additions and 14 deletions
|
|
@ -150,7 +150,7 @@
|
|||
"http-browserify": "^1.7.0",
|
||||
"http-server": "^14.1.1",
|
||||
"https-browserify": "^1.0.0",
|
||||
"mc-assets": "^0.2.47",
|
||||
"mc-assets": "^0.2.48",
|
||||
"mineflayer-mouse": "^0.1.7",
|
||||
"minecraft-inventory-gui": "github:zardoy/minecraft-inventory-gui#next",
|
||||
"mineflayer": "github:zardoy/mineflayer",
|
||||
|
|
|
|||
43
pnpm-lock.yaml
generated
43
pnpm-lock.yaml
generated
|
|
@ -353,8 +353,8 @@ importers:
|
|||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
mc-assets:
|
||||
specifier: ^0.2.47
|
||||
version: 0.2.47
|
||||
specifier: ^0.2.48
|
||||
version: 0.2.48
|
||||
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)
|
||||
|
|
@ -5497,6 +5497,10 @@ packages:
|
|||
resolution: {integrity: sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
fresh@2.0.0:
|
||||
resolution: {integrity: sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
from@0.1.7:
|
||||
resolution: {integrity: sha512-twe20eF1OxVxp/ML/kq2p1uc6KvFK/+vs8WjEbeKmV2He22MKm7YF2ANIt+EOqhJ5L3K/SuuPhk0hWQDjOM23g==}
|
||||
|
||||
|
|
@ -6690,8 +6694,8 @@ packages:
|
|||
maxrects-packer@2.7.3:
|
||||
resolution: {integrity: sha512-bG6qXujJ1QgttZVIH4WDanhoJtvbud/xP/XPyf6A69C9RdA61BM4TomFALCq2nrTa+tARRIBB4LuIFsnUQU2wA==}
|
||||
|
||||
mc-assets@0.2.47:
|
||||
resolution: {integrity: sha512-L9tOcYctDGTUaG4QKJESw9uOiOMl8F2RZ3h0cF4NRCjBvd4c9GUrGDaaVdTaAByQZNNITXgGspmm9hNAFMWcKg==}
|
||||
mc-assets@0.2.48:
|
||||
resolution: {integrity: sha512-ixFBAkdWuluBZ3RhWXvD+KyLX5jKAK8ksXJamAuJxc7nXHP6xK5rEAR3qQ7JVYh27USl3mE+GWTFy/aF0CGRYg==}
|
||||
engines: {node: '>=18.0.0'}
|
||||
|
||||
mcraft-fun-mineflayer@0.1.14:
|
||||
|
|
@ -6861,10 +6865,18 @@ packages:
|
|||
resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
mime-db@1.54.0:
|
||||
resolution: {integrity: sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
mime-types@2.1.35:
|
||||
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
mime-types@3.0.1:
|
||||
resolution: {integrity: sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
mime@1.6.0:
|
||||
resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==}
|
||||
engines: {node: '>=4'}
|
||||
|
|
@ -8366,8 +8378,8 @@ packages:
|
|||
resolution: {integrity: sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==}
|
||||
engines: {node: '>= 0.8.0'}
|
||||
|
||||
send@1.1.0:
|
||||
resolution: {integrity: sha512-v67WcEouB5GxbTWL/4NeToqcZiAWEq90N888fczVArY8A79J0L4FD7vj5hm3eUMua5EpoQ59wa/oovY6TLvRUA==}
|
||||
send@1.2.0:
|
||||
resolution: {integrity: sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==}
|
||||
engines: {node: '>= 18'}
|
||||
|
||||
sentence-case@3.0.4:
|
||||
|
|
@ -16234,6 +16246,8 @@ snapshots:
|
|||
|
||||
fresh@0.5.2: {}
|
||||
|
||||
fresh@2.0.0: {}
|
||||
|
||||
from@0.1.7: {}
|
||||
|
||||
fs-constants@1.0.0: {}
|
||||
|
|
@ -17384,7 +17398,7 @@ snapshots:
|
|||
object-assign: 4.1.1
|
||||
opn: 6.0.0
|
||||
proxy-middleware: 0.15.0
|
||||
send: 1.1.0
|
||||
send: 1.2.0
|
||||
serve-index: 1.9.1
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
|
@ -17588,7 +17602,7 @@ snapshots:
|
|||
|
||||
maxrects-packer@2.7.3: {}
|
||||
|
||||
mc-assets@0.2.47:
|
||||
mc-assets@0.2.48:
|
||||
dependencies:
|
||||
maxrects-packer: 2.7.3
|
||||
zod: 3.24.1
|
||||
|
|
@ -17873,10 +17887,16 @@ snapshots:
|
|||
|
||||
mime-db@1.52.0: {}
|
||||
|
||||
mime-db@1.54.0: {}
|
||||
|
||||
mime-types@2.1.35:
|
||||
dependencies:
|
||||
mime-db: 1.52.0
|
||||
|
||||
mime-types@3.0.1:
|
||||
dependencies:
|
||||
mime-db: 1.54.0
|
||||
|
||||
mime@1.6.0: {}
|
||||
|
||||
mime@2.6.0: {}
|
||||
|
|
@ -19793,16 +19813,15 @@ snapshots:
|
|||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
send@1.1.0:
|
||||
send@1.2.0:
|
||||
dependencies:
|
||||
debug: 4.4.0(supports-color@8.1.1)
|
||||
destroy: 1.2.0
|
||||
encodeurl: 2.0.0
|
||||
escape-html: 1.0.3
|
||||
etag: 1.8.1
|
||||
fresh: 0.5.2
|
||||
fresh: 2.0.0
|
||||
http-errors: 2.0.0
|
||||
mime-types: 2.1.35
|
||||
mime-types: 3.0.1
|
||||
ms: 2.1.3
|
||||
on-finished: 2.4.1
|
||||
range-parser: 1.2.1
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ export const getNonFullBlocksModels = () => {
|
|||
if (!model?.elements?.length) return
|
||||
const isFullBlock = model.elements.length === 1 && arrEqual(model.elements[0].from, [0, 0, 0]) && arrEqual(model.elements[0].to, [16, 16, 16])
|
||||
if (isFullBlock) return
|
||||
const hasBetterPrerender = assetsParser.blockModelsStore.data.latest[`item/${name}`]?.textures?.['layer0']?.startsWith('invsprite_')
|
||||
if (hasBetterPrerender) return
|
||||
model['display'] ??= {}
|
||||
model['display']['gui'] ??= standardGuiDisplay
|
||||
blockModelsResolved[name] = model
|
||||
|
|
@ -144,6 +146,7 @@ const generateItemsGui = async (models: Record<string, BlockModelMcAssets>, isIt
|
|||
const PREVIEW_ID = Identifier.parse('preview:preview')
|
||||
const PREVIEW_DEFINITION = new BlockDefinition({ '': { model: PREVIEW_ID.toString() } }, undefined)
|
||||
|
||||
let textureWasRequested = false
|
||||
let modelData: any
|
||||
let currentModelName: string | undefined
|
||||
const resources: ItemRendererResources = {
|
||||
|
|
@ -154,6 +157,7 @@ const generateItemsGui = async (models: Record<string, BlockModelMcAssets>, isIt
|
|||
return null
|
||||
},
|
||||
getTextureUV (texture) {
|
||||
textureWasRequested = true
|
||||
return textureAtlas.getTextureUV(texture.toString().replace('minecraft:', '').replace('block/', '').replace('item/', '').replace('blocks/', '').replace('items/', '') as any)
|
||||
},
|
||||
getTextureAtlas () {
|
||||
|
|
@ -202,6 +206,7 @@ const generateItemsGui = async (models: Record<string, BlockModelMcAssets>, isIt
|
|||
const renderer = new ItemRenderer(gl, item, resources, { display_context: 'gui' })
|
||||
const missingTextures = new Set()
|
||||
for (const [modelName, model] of Object.entries(models)) {
|
||||
textureWasRequested = false
|
||||
if (includeOnly.length && !includeOnly.includes(modelName)) continue
|
||||
|
||||
const patchMissingTextures = () => {
|
||||
|
|
@ -223,6 +228,7 @@ const generateItemsGui = async (models: Record<string, BlockModelMcAssets>, isIt
|
|||
if (!modelData) continue
|
||||
renderer.setItem(item, { display_context: 'gui' })
|
||||
renderer.drawItem()
|
||||
if (!textureWasRequested) continue
|
||||
const url = canvas.toDataURL()
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const img = await getLoadedImage(url)
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ export const renderSlot = (model: ResolvedItemModelRender, debugIsQuickbar = fal
|
|||
if (!fullBlockModelSupport) {
|
||||
const atlas = activeGuiAtlas.atlas?.json
|
||||
// todo atlas holds all rendered blocks, not all possibly rendered item/block models, need to request this on demand instead (this is how vanilla works)
|
||||
const item = atlas?.textures[itemModelName.replace('minecraft:', '').replace('block/', '').replace('blocks/', '').replace('item/', '').replace('items/', '').replace('_inventory', '').replace('_bottom', '')]
|
||||
const item = atlas?.textures[itemModelName.replace('minecraft:', '').replace('block/', '').replace('blocks/', '').replace('item/', '').replace('items/', '').replace('_inventory', '').replace('_bottom', '').replace('_height2', '').replace('_stable', '').replace('_unstable', '')]
|
||||
if (item) {
|
||||
const x = item.u * atlas.width
|
||||
const y = item.v * atlas.height
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue