@@ -276,6 +276,7 @@ export class Entities {
276276
277277 void this . updatePlayerSkin ( playerData . id , playerData . username , playerData . uuid ?? undefined , stevePngUrl )
278278 }
279+ this . playerEntity . originalEntity = { ...playerData , name : 'player' } as SceneEntity [ 'originalEntity' ]
279280
280281 // Update position and rotation
281282 if ( playerData . position ) {
@@ -294,6 +295,7 @@ export class Entities {
294295 disposeObject ( mesh )
295296 }
296297 this . entities = { }
298+ this . currentSkinUrls = { }
297299
298300 // Clean up player entity
299301 if ( this . playerEntity ) {
@@ -481,6 +483,7 @@ export class Entities {
481483 }
482484
483485 uuidPerSkinUrlsCache = { } as Record < string , { skinUrl ?: string , capeUrl ?: string } >
486+ currentSkinUrls = { } as Record < string , string >
484487
485488 private isCanvasBlank ( canvas : HTMLCanvasElement ) : boolean {
486489 return ! canvas . getContext ( '2d' )
@@ -517,6 +520,25 @@ export class Entities {
517520 }
518521
519522 if ( typeof skinUrl !== 'string' ) throw new Error ( 'Invalid skin url' )
523+
524+ // Skip if same skin URL is already loaded for this entity
525+ if ( this . currentSkinUrls [ String ( entityId ) ] === skinUrl ) {
526+ // Still handle cape if needed
527+ if ( capeUrl ) {
528+ if ( capeUrl === true && username ) {
529+ const newCapeUrl = await loadSkinFromUsername ( username , 'cape' )
530+ if ( ! this . getPlayerObject ( entityId ) ) return
531+ if ( ! newCapeUrl ) return
532+ capeUrl = newCapeUrl
533+ }
534+ if ( typeof capeUrl === 'string' ) {
535+ void this . loadAndApplyCape ( entityId , capeUrl )
536+ }
537+ }
538+ return
539+ }
540+
541+ this . currentSkinUrls [ String ( entityId ) ] = skinUrl
520542 const renderEars = this . worldRenderer . worldRendererConfig . renderEars || username === 'deadmau5'
521543 void this . loadAndApplySkin ( entityId , skinUrl , renderEars ) . then ( async ( ) => {
522544 if ( capeUrl ) {
@@ -1155,6 +1177,7 @@ export class Entities {
11551177 playerPerAnimation = { } as Record < number , string >
11561178 onRemoveEntity ( entity : import ( 'prismarine-entity' ) . Entity ) {
11571179 this . loadedSkinEntityIds . delete ( entity . id . toString ( ) )
1180+ delete this . currentSkinUrls [ entity . id . toString ( ) ]
11581181 }
11591182
11601183 updateMap ( mapNumber : string | number , data : string ) {
0 commit comments