mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-25 22:07:59 +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 net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
|
@ -279,22 +278,21 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
|
|||
}
|
||||
|
||||
public void reloadSkins() {
|
||||
Stream<NetworkPlayerInfo> playerList = Stream.empty();
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc.world != null) {
|
||||
playerList = mc.world.playerEntities.stream()
|
||||
.filter(AbstractClientPlayer.class::isInstance)
|
||||
.map(AbstractClientPlayer.class::cast)
|
||||
.map(PlayerUtil::getInfo);
|
||||
}
|
||||
|
||||
NetHandlerPlayClient playClient = mc.getConnection();
|
||||
if (playClient != null) {
|
||||
playerList = Stream.concat(playerList, playClient.getPlayerInfoMap().stream());
|
||||
}
|
||||
|
||||
playerList.filter(Objects::nonNull).distinct()
|
||||
Stream.concat(
|
||||
// in-world players (+NPCs)
|
||||
Streams.stream(Optional.ofNullable(mc.world))
|
||||
.flatMap(w -> w.playerEntities.stream())
|
||||
.filter(AbstractClientPlayer.class::isInstance)
|
||||
.map(p -> PlayerUtil.getInfo((AbstractClientPlayer) p)),
|
||||
// tab list players
|
||||
Streams.stream(Optional.ofNullable(mc.getConnection()))
|
||||
.flatMap(c -> c.getPlayerInfoMap().stream()))
|
||||
// filter nulls and clear skins
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.forEach(this::clearNetworkSkin);
|
||||
|
||||
clearListeners.removeIf(this::onSkinCacheCleared);
|
||||
|
|
Loading…
Reference in a new issue