This commit is contained in:
Saturn5Vfive 2022-03-13 16:52:38 -05:00
commit 5581369514

View file

@ -26,6 +26,7 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import java.io.InputStreamReader;
import java.net.URL;
@ -40,65 +41,65 @@ public class PlayerSkinMixin {
@Final
private MinecraftSessionService sessionService;
//I cant even launch mc with this! it doesnt work
//@Inject(method = "method_4653", at = @At(
// value = "INVOKE",
// target = "Lnet/minecraft/client/MinecraftClient;execute(Ljava/lang/Runnable;)V",
// shift = At.Shift.BEFORE
//), remap = false, locals = LocalCapture.CAPTURE_FAILEXCEPTION)
//void real(GameProfile gameProfile, boolean bl, PlayerSkinProvider.SkinTextureAvailableCallback skinTextureAvailableCallback, CallbackInfo ci, Map<Type, MinecraftProfileTexture> map) {
// addCape(gameProfile, map);
//}
@Inject(at = {@At("HEAD")},
method = {
"loadSkin(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/texture/PlayerSkinProvider$SkinTextureAvailableCallback;Z)V"},
cancellable = true)
private void onLoadSkin(GameProfile profile,
PlayerSkinProvider.SkinTextureAvailableCallback callback,
boolean requireSecure, CallbackInfo ci) {
Runnable runnable = () -> {
HashMap<MinecraftProfileTexture.Type, MinecraftProfileTexture> map =
Maps.newHashMap();
try {
map.putAll(sessionService.getTextures(profile, requireSecure));
} catch (InsecureTextureException ignored) {
}
if (map.isEmpty()) {
profile.getProperties().clear();
if (profile.getId().equals(MinecraftClient.getInstance()
.getSession().getProfile().getId())) {
profile.getProperties().putAll(
MinecraftClient.getInstance().getSessionProperties());
map.putAll(sessionService.getTextures(profile, false));
} else {
sessionService.fillProfileProperties(profile,
requireSecure);
try {
map.putAll(
sessionService.getTextures(profile, requireSecure));
} catch (InsecureTextureException ignored) {
}
}
}
addCape(profile, map);
MinecraftClient.getInstance().execute(() -> RenderSystem.recordRenderCall(() -> ImmutableList.of(Type.SKIN, Type.CAPE).forEach((type) -> {
if (map.containsKey(type))
loadSkin(map.get(type), type, callback);
})));
};
Util.getMainWorkerExecutor().execute(runnable);
ci.cancel();
@Inject(method = "method_4653", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/MinecraftClient;execute(Ljava/lang/Runnable;)V",
shift = At.Shift.BEFORE
), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
void real(GameProfile gameProfile, boolean bl, PlayerSkinProvider.SkinTextureAvailableCallback skinTextureAvailableCallback, CallbackInfo ci, Map<Type, MinecraftProfileTexture> map) {
addCape(gameProfile, map);
}
// @Inject(at = {@At("HEAD")},
// method = {
// "loadSkin(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/texture/PlayerSkinProvider$SkinTextureAvailableCallback;Z)V"},
// cancellable = true)
// private void onLoadSkin(GameProfile profile,
// PlayerSkinProvider.SkinTextureAvailableCallback callback,
// boolean requireSecure, CallbackInfo ci) {
//
// Runnable runnable = () -> {
// HashMap<MinecraftProfileTexture.Type, MinecraftProfileTexture> map =
// Maps.newHashMap();
//
// try {
// map.putAll(sessionService.getTextures(profile, requireSecure));
// } catch (InsecureTextureException ignored) {
//
// }
//
// if (map.isEmpty()) {
// profile.getProperties().clear();
// if (profile.getId().equals(MinecraftClient.getInstance()
// .getSession().getProfile().getId())) {
// profile.getProperties().putAll(
// MinecraftClient.getInstance().getSessionProperties());
// map.putAll(sessionService.getTextures(profile, false));
// } else {
// sessionService.fillProfileProperties(profile,
// requireSecure);
//
// try {
// map.putAll(
// sessionService.getTextures(profile, requireSecure));
// } catch (InsecureTextureException ignored) {
//
// }
// }
// }
//
// addCape(profile, map);
//
// MinecraftClient.getInstance().execute(() -> RenderSystem.recordRenderCall(() -> ImmutableList.of(Type.SKIN, Type.CAPE).forEach((type) -> {
// if (map.containsKey(type))
// loadSkin(map.get(type), type, callback);
// })));
// };
// Util.getMainWorkerExecutor().execute(runnable);
//
// ci.cancel();
// }
private void addCape(GameProfile profile,
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map) {
String name = profile.getName();