mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-26 06:18:00 +01:00
Improve the stream to reload skins.
Hopefully it's more readable this time.
This commit is contained in:
parent
d84a2051c8
commit
a308e0ce96
1 changed files with 12 additions and 14 deletions
|
@ -29,7 +29,6 @@ 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;
|
||||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
|
||||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||||
|
@ -279,22 +278,21 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadSkins() {
|
public void reloadSkins() {
|
||||||
Stream<NetworkPlayerInfo> playerList = Stream.empty();
|
|
||||||
|
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
if (mc.world != null) {
|
|
||||||
playerList = mc.world.playerEntities.stream()
|
Stream.concat(
|
||||||
|
// in-world players (+NPCs)
|
||||||
|
Streams.stream(Optional.ofNullable(mc.world))
|
||||||
|
.flatMap(w -> w.playerEntities.stream())
|
||||||
.filter(AbstractClientPlayer.class::isInstance)
|
.filter(AbstractClientPlayer.class::isInstance)
|
||||||
.map(AbstractClientPlayer.class::cast)
|
.map(p -> PlayerUtil.getInfo((AbstractClientPlayer) p)),
|
||||||
.map(PlayerUtil::getInfo);
|
// tab list players
|
||||||
}
|
Streams.stream(Optional.ofNullable(mc.getConnection()))
|
||||||
|
.flatMap(c -> c.getPlayerInfoMap().stream()))
|
||||||
NetHandlerPlayClient playClient = mc.getConnection();
|
// filter nulls and clear skins
|
||||||
if (playClient != null) {
|
.filter(Objects::nonNull)
|
||||||
playerList = Stream.concat(playerList, playClient.getPlayerInfoMap().stream());
|
.distinct()
|
||||||
}
|
|
||||||
|
|
||||||
playerList.filter(Objects::nonNull).distinct()
|
|
||||||
.forEach(this::clearNetworkSkin);
|
.forEach(this::clearNetworkSkin);
|
||||||
|
|
||||||
clearListeners.removeIf(this::onSkinCacheCleared);
|
clearListeners.removeIf(this::onSkinCacheCleared);
|
||||||
|
|
Loading…
Reference in a new issue