mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 12:37:59 +01:00
Don't load the skin when checking if it exists.
This commit is contained in:
parent
9e86a57360
commit
e8f1a68fa3
3 changed files with 15 additions and 13 deletions
|
@ -46,22 +46,24 @@ public final class HDSkinManager {
|
|||
|
||||
private HDSkinManager() {}
|
||||
|
||||
public static Optional<ResourceLocation> getSkin(final GameProfile profile) {
|
||||
return INSTANCE.getSkinLocation(profile);
|
||||
public static Optional<ResourceLocation> getSkin(GameProfile profile, boolean loadIfAbsent) {
|
||||
return INSTANCE.getSkinLocation(profile, loadIfAbsent);
|
||||
}
|
||||
|
||||
private Optional<ResourceLocation> getSkinLocation(final GameProfile profile) {
|
||||
private Optional<ResourceLocation> getSkinLocation(final GameProfile profile, boolean loadIfAbsent) {
|
||||
if (!enabled)
|
||||
return Optional.absent();
|
||||
ResourceLocation skin = skinCache.get(profile);
|
||||
if (skin == null) {
|
||||
skinCache.put(profile, LOADING);
|
||||
loadTexture(profile, Type.SKIN, new SkinAvailableCallback() {
|
||||
@Override
|
||||
public void skinAvailable(Type p_180521_1_, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
||||
skinCache.put(profile, location);
|
||||
}
|
||||
});
|
||||
if (loadIfAbsent) {
|
||||
skinCache.put(profile, LOADING);
|
||||
loadTexture(profile, Type.SKIN, new SkinAvailableCallback() {
|
||||
@Override
|
||||
public void skinAvailable(Type type, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
||||
skinCache.put(profile, location);
|
||||
}
|
||||
});
|
||||
}
|
||||
return Optional.absent();
|
||||
}
|
||||
return skin == LOADING ? Optional.<ResourceLocation> absent() : Optional.of(skin);
|
||||
|
|
|
@ -26,7 +26,7 @@ public abstract class MixinPlayerInfo {
|
|||
boolean has = ci.getReturnValueZ();
|
||||
if (!has) {
|
||||
// in case has no skin
|
||||
ci.setReturnValue(HDSkinManager.getSkin(gameProfile).isPresent());
|
||||
ci.setReturnValue(HDSkinManager.getSkin(gameProfile, false).isPresent());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public abstract class MixinPlayerInfo {
|
|||
cancellable = true,
|
||||
at = @At("RETURN") )
|
||||
private void getLocationSkin(CallbackInfoReturnable<ResourceLocation> ci) {
|
||||
Optional<ResourceLocation> skin = HDSkinManager.getSkin(gameProfile);
|
||||
Optional<ResourceLocation> skin = HDSkinManager.getSkin(gameProfile, true);
|
||||
if (skin.isPresent()) {
|
||||
// set the skin
|
||||
ci.setReturnValue(skin.get());
|
||||
|
|
|
@ -27,7 +27,7 @@ public abstract class MixinSkullRenderer extends TileEntitySpecialRenderer {
|
|||
private void onBindTexture(float x, float y, float z, EnumFacing facing, float rotation, int meta, GameProfile profile, int p_180543_8_,
|
||||
CallbackInfo ci) {
|
||||
if (profile != null) {
|
||||
Optional<ResourceLocation> skin = HDSkinManager.getSkin(profile);
|
||||
Optional<ResourceLocation> skin = HDSkinManager.getSkin(profile, true);
|
||||
if (skin.isPresent())
|
||||
// rebind
|
||||
bindTexture(skin.get());
|
||||
|
|
Loading…
Reference in a new issue