Skip to content

Commit

Permalink
Fix rendering lag when skull's username is empty. (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZekerZhayard authored Jan 11, 2025
1 parent 4d0ebcc commit 8080aa7
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package customskinloader.fake.itf;

import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,14 @@ public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getText
String json = new String(Base64.decodeBase64(value), StandardCharsets.UTF_8);
MinecraftTexturesPayload result = GSON.fromJson(json, MinecraftTexturesPayload.class);

if (result == null || TextureUtil.AuthlibField.MINECRAFT_TEXTURES_PAYLOAD_TEXTURES.get(result) == null) {
if (result == null) {
return Maps.newHashMap();
}
return TextureUtil.AuthlibField.MINECRAFT_TEXTURES_PAYLOAD_TEXTURES.get(result);
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures = TextureUtil.AuthlibField.MINECRAFT_TEXTURES_PAYLOAD_TEXTURES.get(result);
if (textures == null) {
return Maps.newHashMap();
}
return textures;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> parseTextures(
MinecraftProfileTexture skin = textures.get(MinecraftProfileTexture.Type.SKIN);
String skinUrl = skin.getUrl();
if (!HttpUtil0.isLocal(skinUrl))
return textures;
// Wrap MinecraftProfileTexture to FakeMinecraftProfileTexture
return ModelManager0.fromUserProfile(ModelManager0.toUserProfile(textures));
File skinFile = new File(CustomSkinLoader.DATA_DIR, skinUrl);
if (!skinFile.isFile())
return Maps.newHashMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

public class TextureManager {
public ITextureObject getTexture(ResourceLocation location) { return null; }
public boolean loadTexture(ResourceLocation location, ITextureObject object) { return false; }
public void loadTexture(ResourceLocation location, AbstractTexture texture) {}
public boolean loadTexture(ResourceLocation location, ITextureObject texture) { return false; }
public void registerAndLoad(ResourceLocation resourceLocation, ReloadableTexture reloadableTexture) {}
}
1 change: 1 addition & 0 deletions Fabric/Fabric.tsrg
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ net/minecraft/client/renderer/texture/SimpleTexture net/minecraft/class_1049
net/minecraft/client/renderer/texture/TextureContents net/minecraft/class_10539
net/minecraft/client/renderer/texture/TextureManager net/minecraft/class_1060
getTexture (Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/texture/ITextureObject; method_4619
loadTexture (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/AbstractTexture;)V method_4616
loadTexture (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/ITextureObject;)Z method_4616
registerAndLoad (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/ReloadableTexture;)V method_65876
net/minecraft/client/resources/DefaultPlayerSkin net/minecraft/class_1068
Expand Down
1 change: 1 addition & 0 deletions Forge/V2/Forge.tsrg
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ net/minecraft/client/renderer/texture/SimpleTexture net/minecraft/client/rendere
net/minecraft/client/renderer/texture/TextureContents net/minecraft/client/renderer/texture/TextureContents
net/minecraft/client/renderer/texture/TextureManager net/minecraft/client/renderer/texture/TextureManager
getTexture (Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/texture/ITextureObject; func_110581_b
loadTexture (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/AbstractTexture;)V m_118495_
loadTexture (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/ITextureObject;)Z func_110579_a
registerAndLoad (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/ReloadableTexture;)V registerAndLoad
net/minecraft/client/resources/DefaultPlayerSkin net/minecraft/client/resources/DefaultPlayerSkin
Expand Down
1 change: 1 addition & 0 deletions Forge/V3/Forge.tsrg
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ net/minecraft/client/renderer/texture/SimpleTexture net/minecraft/client/rendere
net/minecraft/client/renderer/texture/TextureContents net/minecraft/client/renderer/texture/TextureContents
net/minecraft/client/renderer/texture/TextureManager net/minecraft/client/renderer/texture/TextureManager
getTexture (Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/texture/ITextureObject; getTexture
loadTexture (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/AbstractTexture;)V register
loadTexture (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/ITextureObject;)Z register
registerAndLoad (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/ReloadableTexture;)V registerAndLoad
net/minecraft/client/resources/DefaultPlayerSkin net/minecraft/client/resources/DefaultPlayerSkin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public abstract class MixinSkinTextureDownloader {
)
)
private static void redirect_lambda$registerTextureInManager$2(TextureManager manager, ResourceLocation location, AbstractTexture texture) {
manager.registerAndLoad(location, (ReloadableTexture) FakeInterfaceManager.ResourceLocation_getTexture(location));
Object texture0 = FakeInterfaceManager.ResourceLocation_getTexture(location);
if (texture0 != null) {
manager.registerAndLoad(location, (ReloadableTexture) texture0);
} else {
manager.loadTexture(location, texture);
}
}
}

0 comments on commit 8080aa7

Please sign in to comment.