From e8f1a68fa386042c411861b19041c5ed7744ef09 Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Wed, 27 Jan 2016 03:39:26 -0500 Subject: [PATCH] Don't load the skin when checking if it exists. --- .../voxelmodpack/hdskins/HDSkinManager.java | 22 ++++++++++--------- .../hdskins/mixin/MixinPlayerInfo.java | 4 ++-- .../hdskins/mixin/MixinSkullRenderer.java | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java b/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java index 18c59032..6f3e4eb5 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java @@ -46,22 +46,24 @@ public final class HDSkinManager { private HDSkinManager() {} - public static Optional getSkin(final GameProfile profile) { - return INSTANCE.getSkinLocation(profile); + public static Optional getSkin(GameProfile profile, boolean loadIfAbsent) { + return INSTANCE.getSkinLocation(profile, loadIfAbsent); } - private Optional getSkinLocation(final GameProfile profile) { + private Optional 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. absent() : Optional.of(skin); diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java index b926d4f1..a4da6d0b 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java @@ -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 ci) { - Optional skin = HDSkinManager.getSkin(gameProfile); + Optional skin = HDSkinManager.getSkin(gameProfile, true); if (skin.isPresent()) { // set the skin ci.setReturnValue(skin.get()); diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinSkullRenderer.java b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinSkullRenderer.java index 78523e87..48c0bdaa 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinSkullRenderer.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinSkullRenderer.java @@ -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 skin = HDSkinManager.getSkin(profile); + Optional skin = HDSkinManager.getSkin(profile, true); if (skin.isPresent()) // rebind bindTexture(skin.get());