Fix skin in Player Overview and first person on 1.8.9 (fixes #749)

No clue why `getResourceLocationForPlayerUUID` was implemented the way it was,
that commit dates back to 2015 (332c36a), but if the skin isn't loaded yet, it
won't load it, so sometimes it just won't show properly in first person and in
the Player Overview.
This commit just calls `AbstractClientPlayer.getSkinTexture` instead.

Unclear which MC versions are affected. At some point before 1.16.4 something
else was introduced which loads the skin for us, hence why modern versions were
not affected.
This commit is contained in:
Jonas Herzig
2022-07-17 16:02:41 +02:00
parent 3526ec526c
commit 42aef017c1
3 changed files with 5 additions and 34 deletions

View File

@@ -1,7 +1,6 @@
package com.replaymod.core.utils;
import com.google.common.base.Throwables;
import com.google.common.collect.Iterables;
import com.google.common.net.PercentEscaper;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
@@ -27,7 +26,6 @@ import de.johni0702.minecraft.gui.versions.Image;
import de.johni0702.minecraft.gui.versions.MCVer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.util.crash.CrashReport;
import net.minecraft.util.Identifier;
import org.apache.commons.io.Charsets;
import org.apache.commons.io.FilenameUtils;
import org.apache.logging.log4j.LogManager;
@@ -38,15 +36,6 @@ import org.apache.logging.log4j.Logger;
//$$ import org.lwjgl.input.Keyboard;
//#endif
//#if MC>=10800
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.client.util.DefaultSkinHelper;
//#else
//$$ import net.minecraft.client.Minecraft;
//$$ import net.minecraft.client.entity.AbstractClientPlayer;
//$$ import net.minecraft.entity.player.EntityPlayer;
//#endif
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.net.ssl.SSLContext;
@@ -233,25 +222,6 @@ public class Utils {
}
}
public static Identifier getResourceLocationForPlayerUUID(UUID uuid) {
//#if MC>=10800
PlayerListEntry info = getMinecraft().getNetworkHandler().getPlayerListEntry(uuid);
Identifier skinLocation;
if (info != null && info.hasSkinTexture()) {
skinLocation = info.getSkinTexture();
} else {
skinLocation = DefaultSkinHelper.getTexture(uuid);
}
return skinLocation;
//#else
//$$ EntityPlayer player = Minecraft.getMinecraft().theWorld.getPlayerEntityByUUID(uuid);
//$$ if (player != null || !(player instanceof AbstractClientPlayer)) {
//$$ return AbstractClientPlayer.locationStevePng;
//$$ }
//$$ return ((AbstractClientPlayer) player).getLocationSkin();
//#endif
}
public static boolean isCtrlDown() {
//#if MC>=11400
return Screen.hasControlDown();

View File

@@ -1,6 +1,5 @@
package com.replaymod.extras.playeroverview;
import com.replaymod.core.utils.Utils;
import com.replaymod.replay.ReplayModReplay;
import de.johni0702.minecraft.gui.GuiRenderer;
import de.johni0702.minecraft.gui.RenderInfo;
@@ -20,6 +19,7 @@ import de.johni0702.minecraft.gui.layout.HorizontalLayout;
import de.johni0702.minecraft.gui.utils.Colors;
import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;
@@ -94,7 +94,8 @@ public class PlayerOverviewGui extends GuiScreen implements Closeable {
Collections.sort(players, new PlayerComparator()); // Sort by name, spectators last
for (final PlayerEntity p : players) {
final Identifier texture = Utils.getResourceLocationForPlayerUUID(p.getUuid());
if (!(p instanceof AbstractClientPlayerEntity)) continue;
final Identifier texture = ((AbstractClientPlayerEntity) p).getSkinTexture();
final GuiClickable panel = new GuiClickable().setLayout(new HorizontalLayout().setSpacing(2)).addElements(
new HorizontalLayout.Data(0.5), new GuiImage() {
@Override

View File

@@ -472,8 +472,8 @@ public class CameraEntity
@Override
public Identifier getSkinTexture() {
Entity view = this.client.getCameraEntity();
if (view != this && view instanceof PlayerEntity) {
return Utils.getResourceLocationForPlayerUUID(view.getUuid());
if (view != this && view instanceof AbstractClientPlayerEntity) {
return ((AbstractClientPlayerEntity) view).getSkinTexture();
}
return super.getSkinTexture();
}