@@ -159,7 +159,9 @@ const getImage = ({ path = undefined as string | undefined, texture = undefined
159
159
if ( image ) {
160
160
return image
161
161
}
162
- if ( ! path && ! texture ) throw new Error ( 'Either pass path or texture' )
162
+ if ( ! path && ! texture ) {
163
+ throw new Error ( 'Either pass path or texture' )
164
+ }
163
165
const loadPath = ( blockData ? 'blocks' : path ?? texture ) !
164
166
if ( loadedImagesCache . has ( loadPath ) ) {
165
167
onLoad ( )
@@ -201,6 +203,11 @@ const itemToVisualKey = (slot: RenderItem | Item | null) => {
201
203
] . join ( '|' )
202
204
return keys
203
205
}
206
+ const validateSlot = ( slot : any , index : number ) => {
207
+ if ( ! slot . texture ) {
208
+ throw new Error ( `Slot has no texture: ${ index } ${ slot . name } ` )
209
+ }
210
+ }
204
211
const mapSlots = ( slots : Array < RenderItem | Item | null > , isJei = false ) => {
205
212
const newSlots = slots . map ( ( slot , i ) => {
206
213
if ( ! slot ) return null
@@ -210,6 +217,7 @@ const mapSlots = (slots: Array<RenderItem | Item | null>, isJei = false) => {
210
217
const newKey = itemToVisualKey ( slot )
211
218
slot [ 'cacheKey' ] = i + '|' + newKey
212
219
if ( oldKey && oldKey === newKey ) {
220
+ validateSlot ( lastMappedSlots [ i ] , i )
213
221
return lastMappedSlots [ i ]
214
222
}
215
223
}
@@ -228,12 +236,13 @@ const mapSlots = (slots: Array<RenderItem | Item | null>, isJei = false) => {
228
236
const { icon, ...rest } = slot
229
237
return rest
230
238
}
239
+ validateSlot ( slot , i )
231
240
} catch ( err ) {
232
241
inGameError ( err )
233
242
}
234
243
return slot
235
244
} )
236
- lastMappedSlots = newSlots
245
+ lastMappedSlots = JSON . parse ( JSON . stringify ( newSlots ) )
237
246
return newSlots
238
247
}
239
248
0 commit comments