Skip to content

Commit 3a7db6d

Browse files
strad-devWilliam Tran
authored andcommitted
fix: custom skull textures in placedskull not rendering (1.21.11) (FirmamentMC#2268)
1 parent 46aba47 commit 3a7db6d

File tree

3 files changed

+35
-37
lines changed

3 files changed

+35
-37
lines changed

src/texturePacks/java/moe/nea/firmament/features/texturepack/CustomSkyBlockTextures.kt

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
package moe.nea.firmament.features.texturepack
22

3+
import com.mojang.authlib.GameProfile
34
import com.mojang.authlib.minecraft.MinecraftProfileTexture
45
import com.mojang.authlib.properties.Property
56
import java.util.Optional
67
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable
7-
import kotlin.jvm.optionals.getOrNull
88
import net.minecraft.client.Minecraft
99
import net.minecraft.client.renderer.rendertype.RenderType
1010
import net.minecraft.client.renderer.rendertype.RenderTypes
1111
import net.minecraft.resources.Identifier
1212
import net.minecraft.world.item.component.ResolvableProfile
13-
import net.minecraft.world.level.block.SkullBlock
1413
import moe.nea.firmament.annotations.Subscribe
1514
import moe.nea.firmament.events.CustomItemModelEvent
1615
import moe.nea.firmament.events.FinalizeResourceManagerEvent
@@ -103,16 +102,12 @@ object CustomSkyBlockTextures {
103102
return Identifier.fromNamespaceAndPath("firmskyblock", "textures/placedskull/$id.png")
104103
}
105104

106-
fun modifySkullTexture(
107-
type: SkullBlock.Type?,
108-
component: ResolvableProfile?,
109-
cir: CallbackInfoReturnable<RenderType>
110-
) {
111-
if (type != SkullBlock.Types.PLAYER) return
105+
fun modifyRenderInfoType(gameProfile: GameProfile, cir: CallbackInfoReturnable<RenderType>) {
112106
if (!TConfig.skullsEnabled) return
113-
if (component == null) return
114-
115-
val n = skullTextureCache.invoke(component).getOrNull() ?: return
116-
cir.returnValue = RenderTypes.entityTranslucent(n)
107+
val textureProperty = gameProfile.properties["textures"].firstOrNull() ?: return
108+
val id = getSkullId(textureProperty) ?: return
109+
val identifier = Identifier.fromNamespaceAndPath("firmskyblock", "textures/placedskull/$id.png")
110+
if (!Minecraft.getInstance().resourceManager.getResource(identifier).isPresent) return
111+
cir.returnValue = RenderTypes.entityTranslucent(identifier)
117112
}
118113
}

src/texturePacks/java/moe/nea/firmament/mixins/custommodels/CustomSkullTexturePatch.java

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package moe.nea.firmament.mixins.custommodels;
2+
3+
import com.mojang.authlib.GameProfile;
4+
import moe.nea.firmament.features.texturepack.CustomSkyBlockTextures;
5+
import net.minecraft.client.renderer.PlayerSkinRenderCache;
6+
import net.minecraft.client.renderer.rendertype.RenderType;
7+
import org.spongepowered.asm.mixin.Final;
8+
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.Shadow;
10+
import org.spongepowered.asm.mixin.injection.At;
11+
import org.spongepowered.asm.mixin.injection.Inject;
12+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
13+
14+
@Mixin(PlayerSkinRenderCache.RenderInfo.class)
15+
public class CustomSkullTextureRenderInfoPatch {
16+
@Final
17+
@Shadow
18+
private GameProfile gameProfile;
19+
20+
@Inject(
21+
method = "renderType",
22+
at = @At("HEAD"),
23+
cancellable = true
24+
)
25+
private void onGetRenderType(CallbackInfoReturnable<RenderType> cir) {
26+
CustomSkyBlockTextures.INSTANCE.modifyRenderInfoType(this.gameProfile, cir);
27+
}
28+
}

0 commit comments

Comments
 (0)