Skip to content

Commit

Permalink
23w42a
Browse files Browse the repository at this point in the history
  • Loading branch information
ZekerZhayard committed Dec 11, 2023
1 parent 009895c commit bc5bb49
Show file tree
Hide file tree
Showing 33 changed files with 283 additions and 290 deletions.
7 changes: 7 additions & 0 deletions Common/src/main/java/com/mojang/authlib/SignatureState.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.mojang.authlib;

public enum SignatureState {
UNSIGNED,
INVALID,
SIGNED
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.mojang.authlib.minecraft;

import com.mojang.authlib.SignatureState;

public class MinecraftProfileTextures {
public MinecraftProfileTextures(MinecraftProfileTexture skin, MinecraftProfileTexture cape, MinecraftProfileTexture elytra, SignatureState signatureState) {

}
}
12 changes: 6 additions & 6 deletions Common/src/main/java/customskinloader/CustomSkinLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,32 +70,32 @@ public static void loadProfileTextures(Runnable runnable) {
THREAD_POOL.execute(runnable);
}

public static Object loadProfileLazily(GameProfile gameProfile, Function<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>, ?> function) {
public static Object loadProfileLazily(GameProfile gameProfile, Function<UserProfile, ?> function) {
String username = gameProfile.getName();
String credential = MinecraftUtil.getCredential(gameProfile);
// Fix: http://hopper.minecraft.net/crashes/minecraft/MCX-2773713
if (username == null) {
logger.warning("Could not load profile: username is null.");
return function.apply(Maps.newHashMap());
return function.apply(null);
}
String tempName = Thread.currentThread().getName();
Thread.currentThread().setName(username); // Change Thread Name
if (profileCache.isLoading(credential)) {
profileCache.putLoader(credential, function);
Thread.currentThread().setName(tempName);
return function.apply(Maps.newHashMap());
return function.apply(null);
}
Object result = function.apply(loadProfile(gameProfile));
Thread.currentThread().setName(tempName);
Function<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>, ?> func = profileCache.getLastLoader(credential);
Function<UserProfile, ?> func = profileCache.getLastLoader(credential);
if (func != null) {
result = loadProfileLazily(gameProfile, func);
}
return result;
}

//For User Skin
public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadProfile(GameProfile gameProfile) {
public static UserProfile loadProfile(GameProfile gameProfile) {
String credential = MinecraftUtil.getCredential(gameProfile);
UserProfile profile;
if (profileCache.isReady(credential)) {
Expand All @@ -113,7 +113,7 @@ public static Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> loadPro
profileCache.setLoading(credential, true);
profile = loadProfile0(gameProfile, false);
}
return ModelManager0.fromUserProfile(profile);
return profile;
}

//Core
Expand Down
20 changes: 0 additions & 20 deletions Common/src/main/java/customskinloader/fake/FakeCapeBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import java.util.function.Predicate;

import customskinloader.fake.itf.FakeInterfaceManager;
import customskinloader.fake.texture.FakeBufferedImage;
import customskinloader.fake.texture.FakeImage;
import customskinloader.utils.MinecraftUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;

Expand Down Expand Up @@ -38,13 +36,8 @@ private static FakeImage loadElytra(FakeImage originalImage) {
private int loaded = 0;
private double ratioX = -1;
private double ratioY = -1;
private final ResourceLocation location;
private String type = null;

public FakeCapeBuffer(ResourceLocation location) {
this.location = location;
}

@Override
public FakeImage parseUserSkin(FakeImage image) {
if (image == null) return null;
Expand Down Expand Up @@ -74,9 +67,6 @@ public FakeImage parseUserSkin(FakeImage image) {
if ("cape".equals(this.type)) {
this.image = resetImageFormat(this.image, 0, 0, 22, 17);
this.attachElytra(elytraImage);
if (this.image instanceof FakeBufferedImage) { // before 1.12.2
this.refreshTexture((FakeBufferedImage) this.image);
}
}
}
return this.image;
Expand Down Expand Up @@ -156,16 +146,6 @@ private <R> R withElytraPixels(BiPredicate<Integer, Integer> predicate, R return
return defaultReturnValue;
}

// TextureID won't be regenerated when changing resource packs before 1.12.2
private void refreshTexture(FakeBufferedImage image) {
Object textureObj = MinecraftUtil.getTextureManager().getTexture(this.location);
if (textureObj != null) {
// NOTICE: OptiFine modified the upload process of the texture from ThreadDownloadImageData
// Therefore, it may not be correct to simply copy the vanilla behavior
FakeInterfaceManager.ThreadDownloadImageData_resetNewBufferedImage(textureObj, image.getImage());
}
}

// Some cape image doesn't support alpha channel, so reset image format to ARGB
private static FakeImage resetImageFormat(FakeImage image, int startX, int startY, int endX, int endY) {
if (image != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,44 @@

import java.io.File;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import customskinloader.utils.HttpTextureUtil;
import net.minecraft.util.ResourceLocation;

public class FakeMinecraftProfileTexture extends MinecraftProfileTexture {
private final static Map<String, String> MODEL_CACHE = new ConcurrentHashMap<>();

private final HttpTextureUtil.HttpTextureInfo info;
private final Map<String, String> metadata;
private ResourceLocation resourceLocation;

public FakeMinecraftProfileTexture(String url, Map<String, String> metadata) {
super(url, metadata);
this.info = HttpTextureUtil.toHttpTextureInfo(url);
this.metadata = metadata;
}

public void setResourceLocation(ResourceLocation resourceLocation) {
this.resourceLocation = resourceLocation;
}

public ResourceLocation getResourceLocation() {
return this.resourceLocation;
}

@Override
public String getUrl() {
return this.info.url;
}

public void setModule(String module) {
@Override
public String getMetadata(final String key) {
String value = super.getMetadata(key);
if ("model".equals(key) && "auto".equals(value)) {
String model = MODEL_CACHE.get(this.getHash());
if (model != null) {
return model;
}
}
return value;
}

public void setModel(String model) {
if (this.metadata != null) {
this.metadata.put("module", module);
MODEL_CACHE.put(this.getHash(), model);
this.metadata.put("model", model);
}
}

Expand Down
Loading

0 comments on commit bc5bb49

Please sign in to comment.