mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 16:24:23 +01:00
Don't clear the skins when reloading the textures.
All that really needs to be done is reparse.
This commit is contained in:
parent
b8cc905868
commit
5851b1b46f
3 changed files with 10 additions and 14 deletions
|
@ -26,7 +26,6 @@ import com.voxelmodpack.hdskins.skins.ServerType;
|
||||||
import com.voxelmodpack.hdskins.skins.SkinServer;
|
import com.voxelmodpack.hdskins.skins.SkinServer;
|
||||||
import com.voxelmodpack.hdskins.skins.ValhallaSkinServer;
|
import com.voxelmodpack.hdskins.skins.ValhallaSkinServer;
|
||||||
import com.voxelmodpack.hdskins.util.CallableFutures;
|
import com.voxelmodpack.hdskins.util.CallableFutures;
|
||||||
import com.voxelmodpack.hdskins.util.Flow;
|
|
||||||
import com.voxelmodpack.hdskins.util.PlayerUtil;
|
import com.voxelmodpack.hdskins.util.PlayerUtil;
|
||||||
import com.voxelmodpack.hdskins.util.ProfileTextureUtil;
|
import com.voxelmodpack.hdskins.util.ProfileTextureUtil;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -39,7 +38,6 @@ import net.minecraft.client.resources.IResourceManager;
|
||||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||||
import net.minecraft.client.resources.SkinManager;
|
import net.minecraft.client.resources.SkinManager;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
|
@ -65,7 +63,6 @@ import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public final class HDSkinManager implements IResourceManagerReloadListener {
|
public final class HDSkinManager implements IResourceManagerReloadListener {
|
||||||
|
@ -243,8 +240,8 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
|
||||||
FileUtils.deleteQuietly(new File(LiteLoader.getAssetsDirectory(), "hd"));
|
FileUtils.deleteQuietly(new File(LiteLoader.getAssetsDirectory(), "hd"));
|
||||||
|
|
||||||
skins.invalidateAll();
|
skins.invalidateAll();
|
||||||
reloadSkins();
|
parseSkins();
|
||||||
|
clearListeners.removeIf(this::onSkinCacheCleared);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onSkinCacheCleared(ISkinCacheClearListener callback) {
|
private boolean onSkinCacheCleared(ISkinCacheClearListener callback) {
|
||||||
|
@ -275,7 +272,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadSkins() {
|
public void parseSkins() {
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
||||||
Streams.concat(getNPCs(mc), getPlayers(mc))
|
Streams.concat(getNPCs(mc), getPlayers(mc))
|
||||||
|
@ -288,11 +285,10 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
|
||||||
// and clear skins
|
// and clear skins
|
||||||
.forEach(INetworkPlayerInfo::reloadTextures);
|
.forEach(INetworkPlayerInfo::reloadTextures);
|
||||||
|
|
||||||
clearListeners.removeIf(this::onSkinCacheCleared);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Stream<NetworkPlayerInfo> getNPCs(Minecraft mc) {
|
private Stream<NetworkPlayerInfo> getNPCs(Minecraft mc) {
|
||||||
return Flow.from(mc.world)
|
return nullableStream(mc.world)
|
||||||
.flatMap(w -> w.playerEntities.stream())
|
.flatMap(w -> w.playerEntities.stream())
|
||||||
.filter(AbstractClientPlayer.class::isInstance)
|
.filter(AbstractClientPlayer.class::isInstance)
|
||||||
.map(AbstractClientPlayer.class::cast)
|
.map(AbstractClientPlayer.class::cast)
|
||||||
|
@ -300,10 +296,14 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Stream<NetworkPlayerInfo> getPlayers(Minecraft mc) {
|
private Stream<NetworkPlayerInfo> getPlayers(Minecraft mc) {
|
||||||
return Flow.from(mc.getConnection())
|
return nullableStream(mc.getConnection())
|
||||||
.flatMap(a -> a.getPlayerInfoMap().stream());
|
.flatMap(a -> a.getPlayerInfoMap().stream());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static <T> Stream<T> nullableStream(@Nullable T t) {
|
||||||
|
return t == null ? Stream.empty() : Stream.of(t);
|
||||||
|
}
|
||||||
|
|
||||||
public void parseSkin(GameProfile profile, Type type, ResourceLocation resource, MinecraftProfileTexture texture) {
|
public void parseSkin(GameProfile profile, Type type, ResourceLocation resource, MinecraftProfileTexture texture) {
|
||||||
|
|
||||||
CallableFutures.scheduleTask(() -> {
|
CallableFutures.scheduleTask(() -> {
|
||||||
|
|
|
@ -84,10 +84,6 @@ public abstract class MixinNetworkPlayerInfo implements INetworkPlayerInfo {
|
||||||
@Override
|
@Override
|
||||||
public void reloadTextures() {
|
public void reloadTextures() {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
this.playerTextures.clear();
|
|
||||||
this.customProfiles.clear();
|
|
||||||
this.customTextures.clear();
|
|
||||||
this.skinType = null;
|
|
||||||
this.playerTexturesLoaded = false;
|
this.playerTexturesLoaded = false;
|
||||||
if (this.gameProfile.getId().equals(Minecraft.getMinecraft().getSession().getProfile().getId())) {
|
if (this.gameProfile.getId().equals(Minecraft.getMinecraft().getSession().getProfile().getId())) {
|
||||||
// local client skin doesn't have a signature.
|
// local client skin doesn't have a signature.
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class PonyConfig extends SensibleConfig implements Exposable {
|
||||||
// only trigger reloads when the value actually changes
|
// only trigger reloads when the value actually changes
|
||||||
if (ponylevel != this.ponylevel) {
|
if (ponylevel != this.ponylevel) {
|
||||||
this.ponylevel = ponylevel;
|
this.ponylevel = ponylevel;
|
||||||
HDSkinManager.INSTANCE.reloadSkins();
|
HDSkinManager.INSTANCE.parseSkins();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue