mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-25 22:07: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() {}
|
private HDSkinManager() {}
|
||||||
|
|
||||||
public static Optional<ResourceLocation> getSkin(final GameProfile profile) {
|
public static Optional<ResourceLocation> getSkin(GameProfile profile, boolean loadIfAbsent) {
|
||||||
return INSTANCE.getSkinLocation(profile);
|
return INSTANCE.getSkinLocation(profile, loadIfAbsent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<ResourceLocation> getSkinLocation(final GameProfile profile) {
|
private Optional<ResourceLocation> getSkinLocation(final GameProfile profile, boolean loadIfAbsent) {
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
return Optional.absent();
|
return Optional.absent();
|
||||||
ResourceLocation skin = skinCache.get(profile);
|
ResourceLocation skin = skinCache.get(profile);
|
||||||
if (skin == null) {
|
if (skin == null) {
|
||||||
|
if (loadIfAbsent) {
|
||||||
skinCache.put(profile, LOADING);
|
skinCache.put(profile, LOADING);
|
||||||
loadTexture(profile, Type.SKIN, new SkinAvailableCallback() {
|
loadTexture(profile, Type.SKIN, new SkinAvailableCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void skinAvailable(Type p_180521_1_, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
public void skinAvailable(Type type, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
||||||
skinCache.put(profile, location);
|
skinCache.put(profile, location);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return Optional.absent();
|
return Optional.absent();
|
||||||
}
|
}
|
||||||
return skin == LOADING ? Optional.<ResourceLocation> absent() : Optional.of(skin);
|
return skin == LOADING ? Optional.<ResourceLocation> absent() : Optional.of(skin);
|
||||||
|
|
|
@ -26,7 +26,7 @@ public abstract class MixinPlayerInfo {
|
||||||
boolean has = ci.getReturnValueZ();
|
boolean has = ci.getReturnValueZ();
|
||||||
if (!has) {
|
if (!has) {
|
||||||
// in case has no skin
|
// 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,
|
cancellable = true,
|
||||||
at = @At("RETURN") )
|
at = @At("RETURN") )
|
||||||
private void getLocationSkin(CallbackInfoReturnable<ResourceLocation> ci) {
|
private void getLocationSkin(CallbackInfoReturnable<ResourceLocation> ci) {
|
||||||
Optional<ResourceLocation> skin = HDSkinManager.getSkin(gameProfile);
|
Optional<ResourceLocation> skin = HDSkinManager.getSkin(gameProfile, true);
|
||||||
if (skin.isPresent()) {
|
if (skin.isPresent()) {
|
||||||
// set the skin
|
// set the skin
|
||||||
ci.setReturnValue(skin.get());
|
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_,
|
private void onBindTexture(float x, float y, float z, EnumFacing facing, float rotation, int meta, GameProfile profile, int p_180543_8_,
|
||||||
CallbackInfo ci) {
|
CallbackInfo ci) {
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
Optional<ResourceLocation> skin = HDSkinManager.getSkin(profile);
|
Optional<ResourceLocation> skin = HDSkinManager.getSkin(profile, true);
|
||||||
if (skin.isPresent())
|
if (skin.isPresent())
|
||||||
// rebind
|
// rebind
|
||||||
bindTexture(skin.get());
|
bindTexture(skin.get());
|
||||||
|
|
Loading…
Reference in a new issue