Clear all skins and actually re-load them when clearing the cache.

This commit is contained in:
Matthew Messinger 2018-08-24 23:35:18 -04:00
parent c10c61b73b
commit ca48785add

View file

@ -21,17 +21,18 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Stream;
@Mixin(NetworkPlayerInfo.class) @Mixin(NetworkPlayerInfo.class)
public abstract class MixinPlayerInfo implements INetworkPlayerInfo { public abstract class MixinPlayerInfo implements INetworkPlayerInfo {
private Map<Type, ResourceLocation> customTextures = new HashMap<>(); private Map<Type, ResourceLocation> customTextures = new HashMap<>();
private Map<Type, MinecraftProfileTexture> customProfiles = new HashMap<>(); private Map<Type, MinecraftProfileTexture> customProfiles = new HashMap<>();
@Shadow @Final private GameProfile gameProfile; @Shadow @Final private GameProfile gameProfile;
@Shadow Map<Type, ResourceLocation> playerTextures;
@Shadow public abstract String getSkinType(); @Shadow private boolean playerTexturesLoaded;
@Shadow private String skinType;
@SuppressWarnings("InvalidMemberReference") // mc-dev bug? @SuppressWarnings("InvalidMemberReference") // mc-dev bug?
@Redirect( @Redirect(
@ -88,8 +89,14 @@ public abstract class MixinPlayerInfo implements INetworkPlayerInfo {
@Override @Override
public void deleteTextures() { public void deleteTextures() {
TextureManager tm = Minecraft.getMinecraft().getTextureManager(); TextureManager tm = Minecraft.getMinecraft().getTextureManager();
this.customTextures.values().forEach(tm::deleteTexture); Stream.concat(this.customTextures.values().stream(), this.playerTextures.values().stream())
.forEach(tm::deleteTexture);
this.customTextures.clear(); this.customTextures.clear();
this.customProfiles.clear(); this.customProfiles.clear();
this.playerTextures.clear();
this.skinType = null;
this.playerTexturesLoaded = false;
} }
} }