Added SkinProvider to provide loaded Skins for loaded Players in a Replay
Uses SkinProvider in GuiPlayerOverview instead of requesting the Skin from the Mojang API
This commit is contained in:
@@ -2,19 +2,17 @@ package eu.crushedpixel.replaymod.gui;
|
||||
|
||||
import com.mojang.realmsclient.util.Pair;
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.api.mojang.SkinDownloader;
|
||||
import eu.crushedpixel.replaymod.holders.PlayerVisibility;
|
||||
import eu.crushedpixel.replaymod.registry.PlayerHandler;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFile;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||
import eu.crushedpixel.replaymod.utils.SkinProvider;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EnumPlayerModelParts;
|
||||
@@ -38,7 +36,6 @@ public class GuiPlayerOverview extends GuiScreen {
|
||||
|
||||
private List<Pair<EntityPlayer, ResourceLocation>> players;
|
||||
private List<GuiCheckBox> checkBoxes;
|
||||
private List<Integer> loadedPlayers = new ArrayList<Integer>();
|
||||
|
||||
private GuiCheckBox hideAllBox, showAllBox;
|
||||
private GuiCheckBox rememberHidden;
|
||||
@@ -65,28 +62,8 @@ public class GuiPlayerOverview extends GuiScreen {
|
||||
this.checkBoxes = new ArrayList<GuiCheckBox>();
|
||||
|
||||
for(final EntityPlayer p : players) {
|
||||
final ResourceLocation loc = new ResourceLocation("/temp-skins/" + p.getGameProfile().getName());
|
||||
|
||||
final ResourceLocation loc = SkinProvider.getResourceLocationForPlayerUUID(p.getUniqueID());
|
||||
this.players.add(Pair.of(p, loc));
|
||||
|
||||
//mc.getTextureManager().loadTexture(loc, new SimpleTexture(DefaultPlayerSkin.getDefaultSkin(p.getUniqueID())));
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
final ITextureObject tex = SkinDownloader.getDownloadImageSkin(loc, p.getUniqueID());
|
||||
mc.addScheduledTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mc.getTextureManager().loadTexture(loc, tex);
|
||||
loadedPlayers.add(p.getEntityId());
|
||||
}
|
||||
});
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, "replaymod-skin-loader").start();
|
||||
}
|
||||
|
||||
playerCount = players.size();
|
||||
@@ -248,12 +225,7 @@ public class GuiPlayerOverview extends GuiScreen {
|
||||
this.drawString(fontRendererObj, p.first().getName(), k2 + 16 + 5, l2 + 8 - (fontRendererObj.FONT_HEIGHT / 2),
|
||||
spec ? Color.DARK_GRAY.getRGB() : Color.WHITE.getRGB());
|
||||
|
||||
if(loadedPlayers.contains(p.first().getEntityId())) {
|
||||
mc.getTextureManager().bindTexture(p.second());
|
||||
} else {
|
||||
mc.getTextureManager().bindTexture(DefaultPlayerSkin.getDefaultSkin(p.first().getUniqueID()));
|
||||
}
|
||||
|
||||
|
||||
drawScaledCustomSizeModalRect(k2, l2, 8.0F, 8.0F, 8, 8, 16, 16, 64.0F, 64.0F);
|
||||
if(p.first().func_175148_a(EnumPlayerModelParts.HAT))
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package eu.crushedpixel.replaymod.renderer;
|
||||
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.utils.SkinProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -9,7 +10,6 @@ import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -191,7 +191,6 @@ public class SpectatorRenderer {
|
||||
if (itemToRender.getItem() == Items.filled_map) {
|
||||
renderMapInHand(entityPlayer, f3, f1, f2);
|
||||
}
|
||||
//TODO check those
|
||||
else if (entityPlayer.getItemInUseCount() > 0)
|
||||
{
|
||||
EnumAction enumaction = itemToRender.getItemUseAction();
|
||||
@@ -386,10 +385,8 @@ public class SpectatorRenderer {
|
||||
}
|
||||
|
||||
private void bindPlayerTexture(EntityPlayer player) {
|
||||
//TODO: Get spectated player's skin
|
||||
//this.mc.getTextureManager().bindTexture(player.getLocationSkin());
|
||||
this.mc.getTextureManager().bindTexture(DefaultPlayerSkin.getDefaultSkin(player.getUniqueID()));
|
||||
|
||||
this.mc.getTextureManager().bindTexture(
|
||||
SkinProvider.getResourceLocationForPlayerUUID(player.getUniqueID()));
|
||||
}
|
||||
|
||||
public void func_178095_a(EntityPlayer p_178095_1_, float p_178095_2_, float p_178095_3_)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package eu.crushedpixel.replaymod.utils;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class SkinProvider {
|
||||
|
||||
public static ResourceLocation getResourceLocationForPlayerUUID(UUID uuid) {
|
||||
NetworkPlayerInfo info = Minecraft.getMinecraft().getNetHandler().getPlayerInfo(uuid);
|
||||
ResourceLocation skinLocation;
|
||||
if(info.hasLocationSkin()) {
|
||||
skinLocation = info.getLocationSkin();
|
||||
} else {
|
||||
skinLocation = DefaultPlayerSkin.getDefaultSkin(uuid);
|
||||
}
|
||||
return skinLocation;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user