@@ -50,12 +50,41 @@ type textureCacheLookupDetail struct {
5050 StableKey string
5151}
5252
53+ func isGenericPackedSkullTexture (input ItemTextureInput , texture AppliedItemTexture ) bool {
54+ id := normalizeMinecraftItemID (input .ID )
55+ if id == "" {
56+ id = normalizeMinecraftItemID (input .ItemModel )
57+ }
58+ if skullIdentityFromInput (input ) == "" && ! isVanillaSkullItemID (id ) {
59+ return false
60+ }
61+
62+ texturePath := strings .ToLower (strings .ReplaceAll (strings .TrimSpace (texture .Texture ), "\\ " , "/" ))
63+ return strings .Contains (texturePath , "model=minecraft_item_template_skull" ) &&
64+ strings .Contains (texturePath , "tex1=block_soul_sand" )
65+ }
66+
67+ func isVanillaSkullItemID (id string ) bool {
68+ switch normalizeMinecraftItemID (id ) {
69+ case "minecraft:player_head" ,
70+ "minecraft:zombie_head" ,
71+ "minecraft:skeleton_skull" ,
72+ "minecraft:wither_skeleton_skull" ,
73+ "minecraft:creeper_head" ,
74+ "minecraft:dragon_head" ,
75+ "minecraft:piglin_head" :
76+ return true
77+ default :
78+ return false
79+ }
80+ }
81+
5382func cachedTextureForInputDetailed (input ItemTextureInput , textureCtx TextureApplyContext ) (AppliedItemTexture , bool , textureCacheLookupDetail ) {
5483 skyblockID := strings .TrimSpace (input .SkyBlockID )
5584 hasItemModel := normalizeMinecraftItemID (input .ItemModel ) != ""
5685 hasSkullIdentity := skullIdentityFromInput (input ) != ""
5786 if ! hasItemModel || hasSkullIdentity {
58- if texture , ok := cachedStableSkyBlockTexture (skyblockID , textureCtx ); ok {
87+ if texture , ok := cachedStableSkyBlockTexture (skyblockID , textureCtx ); ok && ! isGenericPackedSkullTexture ( input , texture ) {
5988 return texture , true , textureCacheLookupDetail {
6089 Reason : "stable_skyblock_cache" ,
6190 StableKey : "skyblock:" + skyblockID ,
@@ -67,15 +96,15 @@ func cachedTextureForInputDetailed(input ItemTextureInput, textureCtx TextureApp
6796 if skyblockID != "" && stableKey == "skyblock:" + skyblockID {
6897 continue
6998 }
70- if texture , ok := cachedTextureForStableKey (stableKey , textureCtx .PackSignature , textureCtx .EnabledPackIDs , textureCtx .EnabledPackSet ); ok {
99+ if texture , ok := cachedTextureForStableKey (stableKey , textureCtx .PackSignature , textureCtx .EnabledPackIDs , textureCtx .EnabledPackSet ); ok && ! isGenericPackedSkullTexture ( input , texture ) {
71100 return texture , true , textureCacheLookupDetail {
72101 Reason : "stable_key_cache" ,
73102 StableKey : stableKey ,
74103 }
75104 }
76105 }
77106 if skyblockID != "" && ! hasSkullIdentity && ! hasItemModel {
78- if texture , ok := cachedItemTexture (skyblockID , textureCtx ); ok {
107+ if texture , ok := cachedItemTexture (skyblockID , textureCtx ); ok && ! isGenericPackedSkullTexture ( input , texture ) {
79108 return texture , true , textureCacheLookupDetail {
80109 Reason : "legacy_skyblock_cache" ,
81110 StableKey : skyblockID ,
@@ -464,11 +493,13 @@ func ApplyTextureInput(input ItemTextureInput, textureCtx TextureApplyContext) A
464493 Texture : publicCacheTextureURL (customTexture .Path ),
465494 TexturePack : customTexture .TexturePackID ,
466495 }
467- if stats != nil {
468- stats .RenderHits ++
496+ if ! isGenericPackedSkullTexture (input , outputTexture ) {
497+ if stats != nil {
498+ stats .RenderHits ++
499+ }
500+ setCachedTextureForInput (input , textureCtx , outputTexture )
501+ return finishFallback ("runtime_render_hit" , "" , outputTexture )
469502 }
470- setCachedTextureForInput (input , textureCtx , outputTexture )
471- return finishFallback ("runtime_render_hit" , "" , outputTexture )
472503 }
473504
474505 if renderErr != nil && id != "" && vanillaItemResourceExists (id ) {
@@ -491,11 +522,13 @@ func ApplyTextureInput(input ItemTextureInput, textureCtx TextureApplyContext) A
491522 Texture : publicCacheTextureURL (customTexture .Path ),
492523 TexturePack : customTexture .TexturePackID ,
493524 }
494- if stats != nil {
495- stats .RenderHits ++
525+ if ! isGenericPackedSkullTexture (input , outputTexture ) {
526+ if stats != nil {
527+ stats .RenderHits ++
528+ }
529+ setCachedTextureForInput (input , textureCtx , outputTexture )
530+ return finishFallback ("runtime_vanilla_render_hit" , "" , outputTexture )
496531 }
497- setCachedTextureForInput (input , textureCtx , outputTexture )
498- return finishFallback ("runtime_vanilla_render_hit" , "" , outputTexture )
499532 }
500533 }
501534 }
@@ -556,19 +589,19 @@ func ApplyTextureInput(input ItemTextureInput, textureCtx TextureApplyContext) A
556589 }
557590 return finishFallback ("vanilla_texture_fallback" , "" , vanillaTexture )
558591 }
559- if vanillaTexture := vanillaModelTextureURL (id ); vanillaTexture .Texture != "" {
592+ if vanillaTexture := vanillaSpecialHeadTextureURL (id ); vanillaTexture .Texture != "" {
560593 if stats != nil {
561594 stats .VanillaFallbacks ++
562595 stats .VanillaModelFallbacks ++
563596 }
564- return finishFallback ("vanilla_model_fallback " , "" , vanillaTexture )
597+ return finishFallback ("vanilla_special_head_fallback " , "" , vanillaTexture )
565598 }
566- if vanillaTexture := vanillaSpecialHeadTextureURL (id ); vanillaTexture .Texture != "" {
599+ if vanillaTexture := vanillaModelTextureURL (id ); vanillaTexture .Texture != "" {
567600 if stats != nil {
568601 stats .VanillaFallbacks ++
569602 stats .VanillaModelFallbacks ++
570603 }
571- return finishFallback ("vanilla_special_head_fallback " , "" , vanillaTexture )
604+ return finishFallback ("vanilla_model_fallback " , "" , vanillaTexture )
572605 }
573606
574607 if renderErr != nil {
0 commit comments