mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-25 04:04:25 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5807acb34a | ||
|
|
f319d535ae | ||
|
|
f669d095b6 | ||
|
|
ca8b0ba185 | ||
|
|
7acef4d987 | ||
|
|
79404f659c | ||
|
|
85c86ff375 | ||
|
|
f4030701ee | ||
|
|
a36eca2a53 | ||
|
|
6ffdf2aafb | ||
|
|
fba9f7ca28 | ||
|
|
2d157e3d5b | ||
|
|
055aef17db | ||
|
|
622e834d26 | ||
|
|
469c8b62a9 | ||
|
|
1558ec819a | ||
|
|
883e7b45fc | ||
|
|
f30d3319b0 | ||
|
|
58276a7a0c | ||
|
|
883fb39380 | ||
|
|
1358a99f51 | ||
|
|
47ea01dc39 | ||
|
|
ee36f2f42a |
No files matched your search
+9
-3
@@ -1,3 +1,4 @@
|
|||||||
|
# Java
|
||||||
*.class
|
*.class
|
||||||
|
|
||||||
# Mobile Tools for Java (J2ME)
|
# Mobile Tools for Java (J2ME)
|
||||||
@@ -11,16 +12,21 @@
|
|||||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
|
|
||||||
#VSCode
|
# VSCode
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
#eclipse
|
# eclipse
|
||||||
*/.classpath
|
*/.classpath
|
||||||
.classpath
|
.classpath
|
||||||
*/.project
|
*/.project
|
||||||
.project
|
.project
|
||||||
.settings/
|
.settings/
|
||||||
|
|
||||||
#gradle
|
# gradle
|
||||||
.gradle/
|
.gradle/
|
||||||
build/
|
build/
|
||||||
|
|
||||||
|
# IDEA
|
||||||
|
.idea/
|
||||||
|
*.iml
|
||||||
|
out/
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
/build/
|
|
||||||
/src/main/
|
|
||||||
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
minecraft_version=1.12
|
|
||||||
minecraft_full_versions=1.12
|
|
||||||
#forge gradle needs forge version
|
|
||||||
forge_mc_version=1.12
|
|
||||||
forge_version=14.21.1.2387
|
|
||||||
mappings_version=snapshot_20180203
|
|
||||||
@@ -1,402 +0,0 @@
|
|||||||
package net.minecraft.client.gui;
|
|
||||||
|
|
||||||
import com.google.common.collect.ComparisonChain;
|
|
||||||
import com.google.common.collect.Ordering;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
|
||||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.entity.player.EnumPlayerModelParts;
|
|
||||||
import net.minecraft.scoreboard.IScoreCriteria;
|
|
||||||
import net.minecraft.scoreboard.ScoreObjective;
|
|
||||||
import net.minecraft.scoreboard.ScorePlayerTeam;
|
|
||||||
import net.minecraft.scoreboard.Scoreboard;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
import net.minecraft.world.GameType;
|
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class GuiPlayerTabOverlay extends Gui
|
|
||||||
{
|
|
||||||
private static final Ordering<NetworkPlayerInfo> ENTRY_ORDERING = Ordering.from(new GuiPlayerTabOverlay.PlayerComparator());
|
|
||||||
private final Minecraft mc;
|
|
||||||
private final GuiIngame guiIngame;
|
|
||||||
private ITextComponent footer;
|
|
||||||
private ITextComponent header;
|
|
||||||
/** The last time the playerlist was opened (went from not being renderd, to being rendered) */
|
|
||||||
private long lastTimeOpened;
|
|
||||||
/** Weither or not the playerlist is currently being rendered */
|
|
||||||
private boolean isBeingRendered;
|
|
||||||
|
|
||||||
public GuiPlayerTabOverlay(Minecraft mcIn, GuiIngame guiIngameIn)
|
|
||||||
{
|
|
||||||
this.mc = mcIn;
|
|
||||||
this.guiIngame = guiIngameIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the name that should be renderd for the player supplied
|
|
||||||
*/
|
|
||||||
public String getPlayerName(NetworkPlayerInfo networkPlayerInfoIn)
|
|
||||||
{
|
|
||||||
return networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by GuiIngame to update the information stored in the playerlist, does not actually render the list,
|
|
||||||
* however.
|
|
||||||
*/
|
|
||||||
public void updatePlayerList(boolean willBeRendered)
|
|
||||||
{
|
|
||||||
if (willBeRendered && !this.isBeingRendered)
|
|
||||||
{
|
|
||||||
this.lastTimeOpened = Minecraft.getSystemTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.isBeingRendered = willBeRendered;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renders the playerlist, its background, headers and footers.
|
|
||||||
*/
|
|
||||||
public void renderPlayerlist(int width, Scoreboard scoreboardIn, @Nullable ScoreObjective scoreObjectiveIn)
|
|
||||||
{
|
|
||||||
NetHandlerPlayClient nethandlerplayclient = this.mc.player.connection;
|
|
||||||
List<NetworkPlayerInfo> list = ENTRY_ORDERING.<NetworkPlayerInfo>sortedCopy(nethandlerplayclient.getPlayerInfoMap());
|
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
|
|
||||||
for (NetworkPlayerInfo networkplayerinfo : list)
|
|
||||||
{
|
|
||||||
int k = this.mc.fontRenderer.getStringWidth(this.getPlayerName(networkplayerinfo));
|
|
||||||
i = Math.max(i, k);
|
|
||||||
|
|
||||||
if (scoreObjectiveIn != null && scoreObjectiveIn.getRenderType() != IScoreCriteria.EnumRenderType.HEARTS)
|
|
||||||
{
|
|
||||||
k = this.mc.fontRenderer.getStringWidth(" " + scoreboardIn.getOrCreateScore(networkplayerinfo.getGameProfile().getName(), scoreObjectiveIn).getScorePoints());
|
|
||||||
j = Math.max(j, k);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
list = list.subList(0, Math.min(list.size(), 80));
|
|
||||||
int l3 = list.size();
|
|
||||||
int i4 = l3;
|
|
||||||
int j4;
|
|
||||||
|
|
||||||
for (j4 = 1; i4 > 20; i4 = (l3 + j4 - 1) / j4)
|
|
||||||
{
|
|
||||||
++j4;
|
|
||||||
}
|
|
||||||
|
|
||||||
//boolean flag = this.mc.isIntegratedServerRunning() || this.mc.getConnection().getNetworkManager().isEncrypted();
|
|
||||||
boolean flag = true;//Modified
|
|
||||||
int l;
|
|
||||||
|
|
||||||
if (scoreObjectiveIn != null)
|
|
||||||
{
|
|
||||||
if (scoreObjectiveIn.getRenderType() == IScoreCriteria.EnumRenderType.HEARTS)
|
|
||||||
{
|
|
||||||
l = 90;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
l = j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
l = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int i1 = Math.min(j4 * ((flag ? 9 : 0) + i + l + 13), width - 50) / j4;
|
|
||||||
int j1 = width / 2 - (i1 * j4 + (j4 - 1) * 5) / 2;
|
|
||||||
int k1 = 10;
|
|
||||||
int l1 = i1 * j4 + (j4 - 1) * 5;
|
|
||||||
List<String> list1 = null;
|
|
||||||
|
|
||||||
if (this.header != null)
|
|
||||||
{
|
|
||||||
list1 = this.mc.fontRenderer.listFormattedStringToWidth(this.header.getFormattedText(), width - 50);
|
|
||||||
|
|
||||||
for (String s : list1)
|
|
||||||
{
|
|
||||||
l1 = Math.max(l1, this.mc.fontRenderer.getStringWidth(s));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> list2 = null;
|
|
||||||
|
|
||||||
if (this.footer != null)
|
|
||||||
{
|
|
||||||
list2 = this.mc.fontRenderer.listFormattedStringToWidth(this.footer.getFormattedText(), width - 50);
|
|
||||||
|
|
||||||
for (String s1 : list2)
|
|
||||||
{
|
|
||||||
l1 = Math.max(l1, this.mc.fontRenderer.getStringWidth(s1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (list1 != null)
|
|
||||||
{
|
|
||||||
drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + list1.size() * this.mc.fontRenderer.FONT_HEIGHT, Integer.MIN_VALUE);
|
|
||||||
|
|
||||||
for (String s2 : list1)
|
|
||||||
{
|
|
||||||
int i2 = this.mc.fontRenderer.getStringWidth(s2);
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s2, (float)(width / 2 - i2 / 2), (float)k1, -1);
|
|
||||||
k1 += this.mc.fontRenderer.FONT_HEIGHT;
|
|
||||||
}
|
|
||||||
|
|
||||||
++k1;
|
|
||||||
}
|
|
||||||
|
|
||||||
drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + i4 * 9, Integer.MIN_VALUE);
|
|
||||||
|
|
||||||
for (int k4 = 0; k4 < l3; ++k4)
|
|
||||||
{
|
|
||||||
int l4 = k4 / i4;
|
|
||||||
int i5 = k4 % i4;
|
|
||||||
int j2 = j1 + l4 * i1 + l4 * 5;
|
|
||||||
int k2 = k1 + i5 * 9;
|
|
||||||
drawRect(j2, k2, j2 + i1, k2 + 8, 553648127);
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
GlStateManager.enableAlpha();
|
|
||||||
GlStateManager.enableBlend();
|
|
||||||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
|
||||||
|
|
||||||
if (k4 < list.size())
|
|
||||||
{
|
|
||||||
NetworkPlayerInfo networkplayerinfo1 = list.get(k4);
|
|
||||||
GameProfile gameprofile = networkplayerinfo1.getGameProfile();
|
|
||||||
|
|
||||||
if (flag)
|
|
||||||
{
|
|
||||||
EntityPlayer entityplayer = ((net.minecraft.world.World)this.mc.world).getPlayerEntityByUUID(gameprofile.getId());//Modified
|
|
||||||
boolean flag1 = entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.CAPE) && ("Dinnerbone".equals(gameprofile.getName()) || "Grumm".equals(gameprofile.getName()));
|
|
||||||
this.mc.getTextureManager().bindTexture(networkplayerinfo1.getLocationSkin());
|
|
||||||
int l2 = 8 + (flag1 ? 8 : 0);
|
|
||||||
int i3 = 8 * (flag1 ? -1 : 1);
|
|
||||||
Gui.drawScaledCustomSizeModalRect(j2, k2, 8.0F, (float)l2, 8, i3, 8, 8, 64.0F, 64.0F);
|
|
||||||
|
|
||||||
if (entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.HAT))
|
|
||||||
{
|
|
||||||
int j3 = 8 + (flag1 ? 8 : 0);
|
|
||||||
int k3 = 8 * (flag1 ? -1 : 1);
|
|
||||||
Gui.drawScaledCustomSizeModalRect(j2, k2, 40.0F, (float)j3, 8, k3, 8, 8, 64.0F, 64.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
j2 += 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
String s4 = this.getPlayerName(networkplayerinfo1);
|
|
||||||
|
|
||||||
if (networkplayerinfo1.getGameType() == GameType.SPECTATOR)
|
|
||||||
{
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(TextFormatting.ITALIC + s4, (float)j2, (float)k2, -1862270977);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s4, (float)j2, (float)k2, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scoreObjectiveIn != null && networkplayerinfo1.getGameType() != GameType.SPECTATOR)
|
|
||||||
{
|
|
||||||
int k5 = j2 + i + 1;
|
|
||||||
int l5 = k5 + l;
|
|
||||||
|
|
||||||
if (l5 - k5 > 5)
|
|
||||||
{
|
|
||||||
this.drawScoreboardValues(scoreObjectiveIn, k2, gameprofile.getName(), k5, l5, networkplayerinfo1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.drawPing(i1, j2 - (flag ? 9 : 0), k2, networkplayerinfo1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (list2 != null)
|
|
||||||
{
|
|
||||||
k1 = k1 + i4 * 9 + 1;
|
|
||||||
drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + list2.size() * this.mc.fontRenderer.FONT_HEIGHT, Integer.MIN_VALUE);
|
|
||||||
|
|
||||||
for (String s3 : list2)
|
|
||||||
{
|
|
||||||
int j5 = this.mc.fontRenderer.getStringWidth(s3);
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s3, (float)(width / 2 - j5 / 2), (float)k1, -1);
|
|
||||||
k1 += this.mc.fontRenderer.FONT_HEIGHT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void drawPing(int p_175245_1_, int p_175245_2_, int p_175245_3_, NetworkPlayerInfo networkPlayerInfoIn)
|
|
||||||
{
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
this.mc.getTextureManager().bindTexture(ICONS);
|
|
||||||
int i = 0;
|
|
||||||
int j;
|
|
||||||
|
|
||||||
if (networkPlayerInfoIn.getResponseTime() < 0)
|
|
||||||
{
|
|
||||||
j = 5;
|
|
||||||
}
|
|
||||||
else if (networkPlayerInfoIn.getResponseTime() < 150)
|
|
||||||
{
|
|
||||||
j = 0;
|
|
||||||
}
|
|
||||||
else if (networkPlayerInfoIn.getResponseTime() < 300)
|
|
||||||
{
|
|
||||||
j = 1;
|
|
||||||
}
|
|
||||||
else if (networkPlayerInfoIn.getResponseTime() < 600)
|
|
||||||
{
|
|
||||||
j = 2;
|
|
||||||
}
|
|
||||||
else if (networkPlayerInfoIn.getResponseTime() < 1000)
|
|
||||||
{
|
|
||||||
j = 3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
j = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.zLevel += 100.0F;
|
|
||||||
this.drawTexturedModalRect(p_175245_2_ + p_175245_1_ - 11, p_175245_3_, 0, 176 + j * 8, 10, 8);
|
|
||||||
this.zLevel -= 100.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawScoreboardValues(ScoreObjective objective, int p_175247_2_, String name, int p_175247_4_, int p_175247_5_, NetworkPlayerInfo info)
|
|
||||||
{
|
|
||||||
int i = objective.getScoreboard().getOrCreateScore(name, objective).getScorePoints();
|
|
||||||
|
|
||||||
if (objective.getRenderType() == IScoreCriteria.EnumRenderType.HEARTS)
|
|
||||||
{
|
|
||||||
this.mc.getTextureManager().bindTexture(ICONS);
|
|
||||||
|
|
||||||
if (this.lastTimeOpened == info.getRenderVisibilityId())
|
|
||||||
{
|
|
||||||
if (i < info.getLastHealth())
|
|
||||||
{
|
|
||||||
info.setLastHealthTime(Minecraft.getSystemTime());
|
|
||||||
info.setHealthBlinkTime((long)(this.guiIngame.getUpdateCounter() + 20));
|
|
||||||
}
|
|
||||||
else if (i > info.getLastHealth())
|
|
||||||
{
|
|
||||||
info.setLastHealthTime(Minecraft.getSystemTime());
|
|
||||||
info.setHealthBlinkTime((long)(this.guiIngame.getUpdateCounter() + 10));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Minecraft.getSystemTime() - info.getLastHealthTime() > 1000L || this.lastTimeOpened != info.getRenderVisibilityId())
|
|
||||||
{
|
|
||||||
info.setLastHealth(i);
|
|
||||||
info.setDisplayHealth(i);
|
|
||||||
info.setLastHealthTime(Minecraft.getSystemTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
info.setRenderVisibilityId(this.lastTimeOpened);
|
|
||||||
info.setLastHealth(i);
|
|
||||||
int j = MathHelper.ceil((float)Math.max(i, info.getDisplayHealth()) / 2.0F);
|
|
||||||
int k = Math.max(MathHelper.ceil((float)(i / 2)), Math.max(MathHelper.ceil((float)(info.getDisplayHealth() / 2)), 10));
|
|
||||||
boolean flag = info.getHealthBlinkTime() > (long)this.guiIngame.getUpdateCounter() && (info.getHealthBlinkTime() - (long)this.guiIngame.getUpdateCounter()) / 3L % 2L == 1L;
|
|
||||||
|
|
||||||
if (j > 0)
|
|
||||||
{
|
|
||||||
float f = Math.min((float)(p_175247_5_ - p_175247_4_ - 4) / (float)k, 9.0F);
|
|
||||||
|
|
||||||
if (f > 3.0F)
|
|
||||||
{
|
|
||||||
for (int l = j; l < k; ++l)
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)l * f, (float)p_175247_2_, flag ? 25 : 16, 0, 9, 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j1 = 0; j1 < j; ++j1)
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, flag ? 25 : 16, 0, 9, 9);
|
|
||||||
|
|
||||||
if (flag)
|
|
||||||
{
|
|
||||||
if (j1 * 2 + 1 < info.getDisplayHealth())
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, 70, 0, 9, 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j1 * 2 + 1 == info.getDisplayHealth())
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, 79, 0, 9, 9);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j1 * 2 + 1 < i)
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, j1 >= 10 ? 160 : 52, 0, 9, 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j1 * 2 + 1 == i)
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, j1 >= 10 ? 169 : 61, 0, 9, 9);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
float f1 = MathHelper.clamp((float)i / 20.0F, 0.0F, 1.0F);
|
|
||||||
int i1 = (int)((1.0F - f1) * 255.0F) << 16 | (int)(f1 * 255.0F) << 8;
|
|
||||||
String s = "" + (float)i / 2.0F;
|
|
||||||
|
|
||||||
if (p_175247_5_ - this.mc.fontRenderer.getStringWidth(s + "hp") >= p_175247_4_)
|
|
||||||
{
|
|
||||||
s = s + "hp";
|
|
||||||
}
|
|
||||||
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s, (float)((p_175247_5_ + p_175247_4_) / 2 - this.mc.fontRenderer.getStringWidth(s) / 2), (float)p_175247_2_, i1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
String s1 = TextFormatting.YELLOW + "" + i;
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s1, (float)(p_175247_5_ - this.mc.fontRenderer.getStringWidth(s1)), (float)p_175247_2_, 16777215);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFooter(@Nullable ITextComponent footerIn)
|
|
||||||
{
|
|
||||||
this.footer = footerIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHeader(@Nullable ITextComponent headerIn)
|
|
||||||
{
|
|
||||||
this.header = headerIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetFooterHeader()
|
|
||||||
{
|
|
||||||
this.header = null;
|
|
||||||
this.footer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
static class PlayerComparator implements Comparator<NetworkPlayerInfo>
|
|
||||||
{
|
|
||||||
private PlayerComparator()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public int compare(NetworkPlayerInfo p_compare_1_, NetworkPlayerInfo p_compare_2_)
|
|
||||||
{
|
|
||||||
ScorePlayerTeam scoreplayerteam = p_compare_1_.getPlayerTeam();
|
|
||||||
ScorePlayerTeam scoreplayerteam1 = p_compare_2_.getPlayerTeam();
|
|
||||||
return ComparisonChain.start().compareTrueFirst(p_compare_1_.getGameType() != GameType.SPECTATOR, p_compare_2_.getGameType() != GameType.SPECTATOR).compare(scoreplayerteam != null ? scoreplayerteam.getName() : "", scoreplayerteam1 != null ? scoreplayerteam1.getName() : "").compare(p_compare_1_.getGameProfile().getName(), p_compare_2_.getGameProfile().getName()).result();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package net.minecraft.client.gui.spectator;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
|
||||||
import net.minecraft.client.gui.Gui;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.network.play.client.CPacketSpectate;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.util.text.TextComponentString;
|
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class PlayerMenuObject implements ISpectatorMenuObject
|
|
||||||
{
|
|
||||||
private final GameProfile profile;
|
|
||||||
private final ResourceLocation resourceLocation;
|
|
||||||
|
|
||||||
public PlayerMenuObject(GameProfile profileIn)
|
|
||||||
{
|
|
||||||
this.profile = profileIn;
|
|
||||||
/*
|
|
||||||
this.resourceLocation = AbstractClientPlayer.getLocationSkin(profileIn.getName());
|
|
||||||
AbstractClientPlayer.getDownloadImageSkin(this.resourceLocation, profileIn.getName());
|
|
||||||
*/
|
|
||||||
this.resourceLocation = customskinloader.fake.FakeClientPlayer.getLocationSkin(profileIn.getName());
|
|
||||||
customskinloader.fake.FakeClientPlayer.getDownloadImageSkin(this.resourceLocation, profileIn.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectItem(SpectatorMenu menu)
|
|
||||||
{
|
|
||||||
Minecraft.getMinecraft().getConnection().sendPacket(new CPacketSpectate(this.profile.getId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ITextComponent getSpectatorName()
|
|
||||||
{
|
|
||||||
return new TextComponentString(this.profile.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void renderIcon(float brightness, int alpha)
|
|
||||||
{
|
|
||||||
Minecraft.getMinecraft().getTextureManager().bindTexture(this.resourceLocation);
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, (float)alpha / 255.0F);
|
|
||||||
Gui.drawScaledCustomSizeModalRect(2, 2, 8.0F, 8.0F, 8, 8, 12, 12, 64.0F, 64.0F);
|
|
||||||
Gui.drawScaledCustomSizeModalRect(2, 2, 40.0F, 8.0F, 8, 8, 12, 12, 64.0F, 64.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
package net.minecraft.client.resources;
|
|
||||||
|
|
||||||
import com.google.common.cache.CacheBuilder;
|
|
||||||
import com.google.common.cache.CacheLoader;
|
|
||||||
import com.google.common.cache.LoadingCache;
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import com.mojang.authlib.minecraft.InsecureTextureException;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.IImageBuffer;
|
|
||||||
import net.minecraft.client.renderer.ImageBufferDownload;
|
|
||||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
|
||||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
public class SkinManager
|
|
||||||
{
|
|
||||||
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(0, 2, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue());
|
|
||||||
private final TextureManager textureManager;
|
|
||||||
private final File skinCacheDir;
|
|
||||||
private final MinecraftSessionService sessionService;
|
|
||||||
private final LoadingCache<GameProfile, Map<Type, MinecraftProfileTexture>> skinCacheLoader;
|
|
||||||
|
|
||||||
private customskinloader.fake.FakeSkinManager fakeManager;//Fake Skin Manager
|
|
||||||
|
|
||||||
public SkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService)
|
|
||||||
{
|
|
||||||
this.textureManager = textureManagerInstance;
|
|
||||||
this.skinCacheDir = skinCacheDirectory;
|
|
||||||
this.sessionService = sessionService;
|
|
||||||
this.skinCacheLoader = CacheBuilder.newBuilder().expireAfterAccess(15L, TimeUnit.SECONDS).<GameProfile, Map<Type, MinecraftProfileTexture>>build(new CacheLoader<GameProfile, Map<Type, MinecraftProfileTexture>>()
|
|
||||||
{
|
|
||||||
public Map<Type, MinecraftProfileTexture> load(GameProfile p_load_1_) throws Exception
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return Minecraft.getMinecraft().getSessionService().getTextures(p_load_1_, false);
|
|
||||||
}
|
|
||||||
catch (Throwable var3)
|
|
||||||
{
|
|
||||||
return Maps.<Type, MinecraftProfileTexture>newHashMap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.fakeManager=new customskinloader.fake.FakeSkinManager(textureManagerInstance,skinCacheDirectory,sessionService);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used in the Skull renderer to fetch a skin. May download the skin if it's not in the cache
|
|
||||||
*/
|
|
||||||
public ResourceLocation loadSkin(MinecraftProfileTexture profileTexture, Type textureType)
|
|
||||||
{
|
|
||||||
return this.loadSkin(profileTexture, textureType, (SkinManager.SkinAvailableCallback)null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* May download the skin if its not in the cache, can be passed a SkinManager#SkinAvailableCallback for handling
|
|
||||||
*/
|
|
||||||
public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final Type textureType, @Nullable final SkinManager.SkinAvailableCallback skinAvailableCallback)
|
|
||||||
{
|
|
||||||
return this.fakeManager.loadSkin(profileTexture, textureType, skinAvailableCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadProfileTextures(final GameProfile profile, final SkinManager.SkinAvailableCallback skinAvailableCallback, final boolean requireSecure)
|
|
||||||
{
|
|
||||||
this.fakeManager.loadProfileTextures(profile, skinAvailableCallback, requireSecure);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile)
|
|
||||||
{
|
|
||||||
return this.fakeManager.loadSkinFromCache(profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface SkinAvailableCallback
|
|
||||||
{
|
|
||||||
void skinAvailable(Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
minecraft_version=1.12.1
|
|
||||||
minecraft_full_versions=1.12.1,1.12.2
|
|
||||||
#forge gradle needs forge version
|
|
||||||
forge_mc_version=1.12.2
|
|
||||||
forge_version=14.23.2.2611
|
|
||||||
mappings_version=snapshot_20180210
|
|
||||||
@@ -1,402 +0,0 @@
|
|||||||
package net.minecraft.client.gui;
|
|
||||||
|
|
||||||
import com.google.common.collect.ComparisonChain;
|
|
||||||
import com.google.common.collect.Ordering;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
|
||||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.entity.player.EnumPlayerModelParts;
|
|
||||||
import net.minecraft.scoreboard.IScoreCriteria;
|
|
||||||
import net.minecraft.scoreboard.ScoreObjective;
|
|
||||||
import net.minecraft.scoreboard.ScorePlayerTeam;
|
|
||||||
import net.minecraft.scoreboard.Scoreboard;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
import net.minecraft.world.GameType;
|
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class GuiPlayerTabOverlay extends Gui
|
|
||||||
{
|
|
||||||
private static final Ordering<NetworkPlayerInfo> ENTRY_ORDERING = Ordering.from(new GuiPlayerTabOverlay.PlayerComparator());
|
|
||||||
private final Minecraft mc;
|
|
||||||
private final GuiIngame guiIngame;
|
|
||||||
private ITextComponent footer;
|
|
||||||
private ITextComponent header;
|
|
||||||
/** The last time the playerlist was opened (went from not being renderd, to being rendered) */
|
|
||||||
private long lastTimeOpened;
|
|
||||||
/** Weither or not the playerlist is currently being rendered */
|
|
||||||
private boolean isBeingRendered;
|
|
||||||
|
|
||||||
public GuiPlayerTabOverlay(Minecraft mcIn, GuiIngame guiIngameIn)
|
|
||||||
{
|
|
||||||
this.mc = mcIn;
|
|
||||||
this.guiIngame = guiIngameIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the name that should be renderd for the player supplied
|
|
||||||
*/
|
|
||||||
public String getPlayerName(NetworkPlayerInfo networkPlayerInfoIn)
|
|
||||||
{
|
|
||||||
return networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by GuiIngame to update the information stored in the playerlist, does not actually render the list,
|
|
||||||
* however.
|
|
||||||
*/
|
|
||||||
public void updatePlayerList(boolean willBeRendered)
|
|
||||||
{
|
|
||||||
if (willBeRendered && !this.isBeingRendered)
|
|
||||||
{
|
|
||||||
this.lastTimeOpened = Minecraft.getSystemTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.isBeingRendered = willBeRendered;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renders the playerlist, its background, headers and footers.
|
|
||||||
*/
|
|
||||||
public void renderPlayerlist(int width, Scoreboard scoreboardIn, @Nullable ScoreObjective scoreObjectiveIn)
|
|
||||||
{
|
|
||||||
NetHandlerPlayClient nethandlerplayclient = this.mc.player.connection;
|
|
||||||
List<NetworkPlayerInfo> list = ENTRY_ORDERING.<NetworkPlayerInfo>sortedCopy(nethandlerplayclient.getPlayerInfoMap());
|
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
|
|
||||||
for (NetworkPlayerInfo networkplayerinfo : list)
|
|
||||||
{
|
|
||||||
int k = this.mc.fontRenderer.getStringWidth(this.getPlayerName(networkplayerinfo));
|
|
||||||
i = Math.max(i, k);
|
|
||||||
|
|
||||||
if (scoreObjectiveIn != null && scoreObjectiveIn.getRenderType() != IScoreCriteria.EnumRenderType.HEARTS)
|
|
||||||
{
|
|
||||||
k = this.mc.fontRenderer.getStringWidth(" " + scoreboardIn.getOrCreateScore(networkplayerinfo.getGameProfile().getName(), scoreObjectiveIn).getScorePoints());
|
|
||||||
j = Math.max(j, k);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
list = list.subList(0, Math.min(list.size(), 80));
|
|
||||||
int l3 = list.size();
|
|
||||||
int i4 = l3;
|
|
||||||
int j4;
|
|
||||||
|
|
||||||
for (j4 = 1; i4 > 20; i4 = (l3 + j4 - 1) / j4)
|
|
||||||
{
|
|
||||||
++j4;
|
|
||||||
}
|
|
||||||
|
|
||||||
//boolean flag = this.mc.isIntegratedServerRunning() || this.mc.getConnection().getNetworkManager().isEncrypted();
|
|
||||||
boolean flag = true;//Modified
|
|
||||||
int l;
|
|
||||||
|
|
||||||
if (scoreObjectiveIn != null)
|
|
||||||
{
|
|
||||||
if (scoreObjectiveIn.getRenderType() == IScoreCriteria.EnumRenderType.HEARTS)
|
|
||||||
{
|
|
||||||
l = 90;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
l = j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
l = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int i1 = Math.min(j4 * ((flag ? 9 : 0) + i + l + 13), width - 50) / j4;
|
|
||||||
int j1 = width / 2 - (i1 * j4 + (j4 - 1) * 5) / 2;
|
|
||||||
int k1 = 10;
|
|
||||||
int l1 = i1 * j4 + (j4 - 1) * 5;
|
|
||||||
List<String> list1 = null;
|
|
||||||
|
|
||||||
if (this.header != null)
|
|
||||||
{
|
|
||||||
list1 = this.mc.fontRenderer.listFormattedStringToWidth(this.header.getFormattedText(), width - 50);
|
|
||||||
|
|
||||||
for (String s : list1)
|
|
||||||
{
|
|
||||||
l1 = Math.max(l1, this.mc.fontRenderer.getStringWidth(s));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> list2 = null;
|
|
||||||
|
|
||||||
if (this.footer != null)
|
|
||||||
{
|
|
||||||
list2 = this.mc.fontRenderer.listFormattedStringToWidth(this.footer.getFormattedText(), width - 50);
|
|
||||||
|
|
||||||
for (String s1 : list2)
|
|
||||||
{
|
|
||||||
l1 = Math.max(l1, this.mc.fontRenderer.getStringWidth(s1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (list1 != null)
|
|
||||||
{
|
|
||||||
drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + list1.size() * this.mc.fontRenderer.FONT_HEIGHT, Integer.MIN_VALUE);
|
|
||||||
|
|
||||||
for (String s2 : list1)
|
|
||||||
{
|
|
||||||
int i2 = this.mc.fontRenderer.getStringWidth(s2);
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s2, (float)(width / 2 - i2 / 2), (float)k1, -1);
|
|
||||||
k1 += this.mc.fontRenderer.FONT_HEIGHT;
|
|
||||||
}
|
|
||||||
|
|
||||||
++k1;
|
|
||||||
}
|
|
||||||
|
|
||||||
drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + i4 * 9, Integer.MIN_VALUE);
|
|
||||||
|
|
||||||
for (int k4 = 0; k4 < l3; ++k4)
|
|
||||||
{
|
|
||||||
int l4 = k4 / i4;
|
|
||||||
int i5 = k4 % i4;
|
|
||||||
int j2 = j1 + l4 * i1 + l4 * 5;
|
|
||||||
int k2 = k1 + i5 * 9;
|
|
||||||
drawRect(j2, k2, j2 + i1, k2 + 8, 553648127);
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
GlStateManager.enableAlpha();
|
|
||||||
GlStateManager.enableBlend();
|
|
||||||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
|
||||||
|
|
||||||
if (k4 < list.size())
|
|
||||||
{
|
|
||||||
NetworkPlayerInfo networkplayerinfo1 = list.get(k4);
|
|
||||||
GameProfile gameprofile = networkplayerinfo1.getGameProfile();
|
|
||||||
|
|
||||||
if (flag)
|
|
||||||
{
|
|
||||||
EntityPlayer entityplayer = ((net.minecraft.world.World)this.mc.world).getPlayerEntityByUUID(gameprofile.getId());//Modified
|
|
||||||
boolean flag1 = entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.CAPE) && ("Dinnerbone".equals(gameprofile.getName()) || "Grumm".equals(gameprofile.getName()));
|
|
||||||
this.mc.getTextureManager().bindTexture(networkplayerinfo1.getLocationSkin());
|
|
||||||
int l2 = 8 + (flag1 ? 8 : 0);
|
|
||||||
int i3 = 8 * (flag1 ? -1 : 1);
|
|
||||||
Gui.drawScaledCustomSizeModalRect(j2, k2, 8.0F, (float)l2, 8, i3, 8, 8, 64.0F, 64.0F);
|
|
||||||
|
|
||||||
if (entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.HAT))
|
|
||||||
{
|
|
||||||
int j3 = 8 + (flag1 ? 8 : 0);
|
|
||||||
int k3 = 8 * (flag1 ? -1 : 1);
|
|
||||||
Gui.drawScaledCustomSizeModalRect(j2, k2, 40.0F, (float)j3, 8, k3, 8, 8, 64.0F, 64.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
j2 += 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
String s4 = this.getPlayerName(networkplayerinfo1);
|
|
||||||
|
|
||||||
if (networkplayerinfo1.getGameType() == GameType.SPECTATOR)
|
|
||||||
{
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(TextFormatting.ITALIC + s4, (float)j2, (float)k2, -1862270977);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s4, (float)j2, (float)k2, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scoreObjectiveIn != null && networkplayerinfo1.getGameType() != GameType.SPECTATOR)
|
|
||||||
{
|
|
||||||
int k5 = j2 + i + 1;
|
|
||||||
int l5 = k5 + l;
|
|
||||||
|
|
||||||
if (l5 - k5 > 5)
|
|
||||||
{
|
|
||||||
this.drawScoreboardValues(scoreObjectiveIn, k2, gameprofile.getName(), k5, l5, networkplayerinfo1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.drawPing(i1, j2 - (flag ? 9 : 0), k2, networkplayerinfo1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (list2 != null)
|
|
||||||
{
|
|
||||||
k1 = k1 + i4 * 9 + 1;
|
|
||||||
drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + list2.size() * this.mc.fontRenderer.FONT_HEIGHT, Integer.MIN_VALUE);
|
|
||||||
|
|
||||||
for (String s3 : list2)
|
|
||||||
{
|
|
||||||
int j5 = this.mc.fontRenderer.getStringWidth(s3);
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s3, (float)(width / 2 - j5 / 2), (float)k1, -1);
|
|
||||||
k1 += this.mc.fontRenderer.FONT_HEIGHT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void drawPing(int p_175245_1_, int p_175245_2_, int p_175245_3_, NetworkPlayerInfo networkPlayerInfoIn)
|
|
||||||
{
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
this.mc.getTextureManager().bindTexture(ICONS);
|
|
||||||
int i = 0;
|
|
||||||
int j;
|
|
||||||
|
|
||||||
if (networkPlayerInfoIn.getResponseTime() < 0)
|
|
||||||
{
|
|
||||||
j = 5;
|
|
||||||
}
|
|
||||||
else if (networkPlayerInfoIn.getResponseTime() < 150)
|
|
||||||
{
|
|
||||||
j = 0;
|
|
||||||
}
|
|
||||||
else if (networkPlayerInfoIn.getResponseTime() < 300)
|
|
||||||
{
|
|
||||||
j = 1;
|
|
||||||
}
|
|
||||||
else if (networkPlayerInfoIn.getResponseTime() < 600)
|
|
||||||
{
|
|
||||||
j = 2;
|
|
||||||
}
|
|
||||||
else if (networkPlayerInfoIn.getResponseTime() < 1000)
|
|
||||||
{
|
|
||||||
j = 3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
j = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.zLevel += 100.0F;
|
|
||||||
this.drawTexturedModalRect(p_175245_2_ + p_175245_1_ - 11, p_175245_3_, 0, 176 + j * 8, 10, 8);
|
|
||||||
this.zLevel -= 100.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawScoreboardValues(ScoreObjective objective, int p_175247_2_, String name, int p_175247_4_, int p_175247_5_, NetworkPlayerInfo info)
|
|
||||||
{
|
|
||||||
int i = objective.getScoreboard().getOrCreateScore(name, objective).getScorePoints();
|
|
||||||
|
|
||||||
if (objective.getRenderType() == IScoreCriteria.EnumRenderType.HEARTS)
|
|
||||||
{
|
|
||||||
this.mc.getTextureManager().bindTexture(ICONS);
|
|
||||||
|
|
||||||
if (this.lastTimeOpened == info.getRenderVisibilityId())
|
|
||||||
{
|
|
||||||
if (i < info.getLastHealth())
|
|
||||||
{
|
|
||||||
info.setLastHealthTime(Minecraft.getSystemTime());
|
|
||||||
info.setHealthBlinkTime((long)(this.guiIngame.getUpdateCounter() + 20));
|
|
||||||
}
|
|
||||||
else if (i > info.getLastHealth())
|
|
||||||
{
|
|
||||||
info.setLastHealthTime(Minecraft.getSystemTime());
|
|
||||||
info.setHealthBlinkTime((long)(this.guiIngame.getUpdateCounter() + 10));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Minecraft.getSystemTime() - info.getLastHealthTime() > 1000L || this.lastTimeOpened != info.getRenderVisibilityId())
|
|
||||||
{
|
|
||||||
info.setLastHealth(i);
|
|
||||||
info.setDisplayHealth(i);
|
|
||||||
info.setLastHealthTime(Minecraft.getSystemTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
info.setRenderVisibilityId(this.lastTimeOpened);
|
|
||||||
info.setLastHealth(i);
|
|
||||||
int j = MathHelper.ceil((float)Math.max(i, info.getDisplayHealth()) / 2.0F);
|
|
||||||
int k = Math.max(MathHelper.ceil((float)(i / 2)), Math.max(MathHelper.ceil((float)(info.getDisplayHealth() / 2)), 10));
|
|
||||||
boolean flag = info.getHealthBlinkTime() > (long)this.guiIngame.getUpdateCounter() && (info.getHealthBlinkTime() - (long)this.guiIngame.getUpdateCounter()) / 3L % 2L == 1L;
|
|
||||||
|
|
||||||
if (j > 0)
|
|
||||||
{
|
|
||||||
float f = Math.min((float)(p_175247_5_ - p_175247_4_ - 4) / (float)k, 9.0F);
|
|
||||||
|
|
||||||
if (f > 3.0F)
|
|
||||||
{
|
|
||||||
for (int l = j; l < k; ++l)
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)l * f, (float)p_175247_2_, flag ? 25 : 16, 0, 9, 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j1 = 0; j1 < j; ++j1)
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, flag ? 25 : 16, 0, 9, 9);
|
|
||||||
|
|
||||||
if (flag)
|
|
||||||
{
|
|
||||||
if (j1 * 2 + 1 < info.getDisplayHealth())
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, 70, 0, 9, 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j1 * 2 + 1 == info.getDisplayHealth())
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, 79, 0, 9, 9);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j1 * 2 + 1 < i)
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, j1 >= 10 ? 160 : 52, 0, 9, 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j1 * 2 + 1 == i)
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, j1 >= 10 ? 169 : 61, 0, 9, 9);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
float f1 = MathHelper.clamp((float)i / 20.0F, 0.0F, 1.0F);
|
|
||||||
int i1 = (int)((1.0F - f1) * 255.0F) << 16 | (int)(f1 * 255.0F) << 8;
|
|
||||||
String s = "" + (float)i / 2.0F;
|
|
||||||
|
|
||||||
if (p_175247_5_ - this.mc.fontRenderer.getStringWidth(s + "hp") >= p_175247_4_)
|
|
||||||
{
|
|
||||||
s = s + "hp";
|
|
||||||
}
|
|
||||||
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s, (float)((p_175247_5_ + p_175247_4_) / 2 - this.mc.fontRenderer.getStringWidth(s) / 2), (float)p_175247_2_, i1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
String s1 = TextFormatting.YELLOW + "" + i;
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s1, (float)(p_175247_5_ - this.mc.fontRenderer.getStringWidth(s1)), (float)p_175247_2_, 16777215);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFooter(@Nullable ITextComponent footerIn)
|
|
||||||
{
|
|
||||||
this.footer = footerIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHeader(@Nullable ITextComponent headerIn)
|
|
||||||
{
|
|
||||||
this.header = headerIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetFooterHeader()
|
|
||||||
{
|
|
||||||
this.header = null;
|
|
||||||
this.footer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
static class PlayerComparator implements Comparator<NetworkPlayerInfo>
|
|
||||||
{
|
|
||||||
private PlayerComparator()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public int compare(NetworkPlayerInfo p_compare_1_, NetworkPlayerInfo p_compare_2_)
|
|
||||||
{
|
|
||||||
ScorePlayerTeam scoreplayerteam = p_compare_1_.getPlayerTeam();
|
|
||||||
ScorePlayerTeam scoreplayerteam1 = p_compare_2_.getPlayerTeam();
|
|
||||||
return ComparisonChain.start().compareTrueFirst(p_compare_1_.getGameType() != GameType.SPECTATOR, p_compare_2_.getGameType() != GameType.SPECTATOR).compare(scoreplayerteam != null ? scoreplayerteam.getName() : "", scoreplayerteam1 != null ? scoreplayerteam1.getName() : "").compare(p_compare_1_.getGameProfile().getName(), p_compare_2_.getGameProfile().getName()).result();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package net.minecraft.client.gui.spectator;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
|
||||||
import net.minecraft.client.gui.Gui;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.network.play.client.CPacketSpectate;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.util.text.TextComponentString;
|
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class PlayerMenuObject implements ISpectatorMenuObject
|
|
||||||
{
|
|
||||||
private final GameProfile profile;
|
|
||||||
private final ResourceLocation resourceLocation;
|
|
||||||
|
|
||||||
public PlayerMenuObject(GameProfile profileIn)
|
|
||||||
{
|
|
||||||
this.profile = profileIn;
|
|
||||||
/*
|
|
||||||
this.resourceLocation = AbstractClientPlayer.getLocationSkin(profileIn.getName());
|
|
||||||
AbstractClientPlayer.getDownloadImageSkin(this.resourceLocation, profileIn.getName());
|
|
||||||
*/
|
|
||||||
this.resourceLocation = customskinloader.fake.FakeClientPlayer.getLocationSkin(profileIn.getName());
|
|
||||||
customskinloader.fake.FakeClientPlayer.getDownloadImageSkin(this.resourceLocation, profileIn.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectItem(SpectatorMenu menu)
|
|
||||||
{
|
|
||||||
Minecraft.getMinecraft().getConnection().sendPacket(new CPacketSpectate(this.profile.getId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ITextComponent getSpectatorName()
|
|
||||||
{
|
|
||||||
return new TextComponentString(this.profile.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void renderIcon(float brightness, int alpha)
|
|
||||||
{
|
|
||||||
Minecraft.getMinecraft().getTextureManager().bindTexture(this.resourceLocation);
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, (float)alpha / 255.0F);
|
|
||||||
Gui.drawScaledCustomSizeModalRect(2, 2, 8.0F, 8.0F, 8, 8, 12, 12, 64.0F, 64.0F);
|
|
||||||
Gui.drawScaledCustomSizeModalRect(2, 2, 40.0F, 8.0F, 8, 8, 12, 12, 64.0F, 64.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File renamed without changes.
+44420
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,7 @@
|
|||||||
|
minecraft_version=1.13
|
||||||
|
minecraft_full_versions=1.13
|
||||||
|
#forge gradle needs forge version
|
||||||
|
forge_mc_version=1.12.2
|
||||||
|
forge_version=14.23.3.2655
|
||||||
|
mappings_version=snapshot_20180505
|
||||||
|
srg_notch_map=1.13.srg
|
||||||
@@ -33,12 +33,13 @@ public class CustomSkinLoader {
|
|||||||
CONFIG_FILE=new File(DATA_DIR,"CustomSkinLoader.json");
|
CONFIG_FILE=new File(DATA_DIR,"CustomSkinLoader.json");
|
||||||
public static final SkinSiteProfile[] DEFAULT_LOAD_LIST={
|
public static final SkinSiteProfile[] DEFAULT_LOAD_LIST={
|
||||||
SkinSiteProfile.createMojangAPI("Mojang"),
|
SkinSiteProfile.createMojangAPI("Mojang"),
|
||||||
SkinSiteProfile.createCustomSkinAPI("LittleSkin","https://mcskin.littleservice.cn/"),
|
SkinSiteProfile.createCustomSkinAPI("LittleSkin","https://littleskin.cn/"),
|
||||||
SkinSiteProfile.createCustomSkinAPI("BlessingSkin","http://skin.prinzeugen.net/"),
|
SkinSiteProfile.createCustomSkinAPI("BlessingSkin","http://skin.prinzeugen.net/"),
|
||||||
//OneSkin has been removed temporarily
|
//OneSkin has been removed temporarily
|
||||||
//SkinSiteProfile.createCustomSkinAPI("OneSkin","http://fleey.cn/skin/skin_user/skin_json.php/"),
|
//SkinSiteProfile.createCustomSkinAPI("OneSkin","http://fleey.cn/skin/skin_user/skin_json.php/"),
|
||||||
//Minecrack could not load skin correctly
|
//Minecrack could not load skin correctly
|
||||||
//SkinSiteProfile.creatLegacy("Minecrack","http://minecrack.fr.nf/mc/skinsminecrackd/{USERNAME}.png","http://minecrack.fr.nf/mc/cloaksminecrackd/{USERNAME}.png",null),
|
//SkinSiteProfile.creatLegacy("Minecrack","http://minecrack.fr.nf/mc/skinsminecrackd/{USERNAME}.png","http://minecrack.fr.nf/mc/cloaksminecrackd/{USERNAME}.png",null),
|
||||||
|
SkinSiteProfile.createElyByAPI("ElyBy"),
|
||||||
SkinSiteProfile.createUniSkinAPI("SkinMe","http://www.skinme.cc/uniskin/"),
|
SkinSiteProfile.createUniSkinAPI("SkinMe","http://www.skinme.cc/uniskin/"),
|
||||||
SkinSiteProfile.createLegacy("LocalSkin","LocalSkin/skins/{USERNAME}.png","LocalSkin/capes/{USERNAME}.png","LocalSkin/elytras/{USERNAME}.png")};
|
SkinSiteProfile.createLegacy("LocalSkin","LocalSkin/skins/{USERNAME}.png","LocalSkin/capes/{USERNAME}.png","LocalSkin/elytras/{USERNAME}.png")};
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ public class CustomSkinLoader {
|
|||||||
private static final DynamicSkullManager dynamicSkullManager=new DynamicSkullManager();
|
private static final DynamicSkullManager dynamicSkullManager=new DynamicSkullManager();
|
||||||
|
|
||||||
//For User Skin
|
//For User Skin
|
||||||
public static Map loadProfile(GameProfile gameProfile){
|
public static Map<Type, MinecraftProfileTexture> loadProfile(GameProfile gameProfile){
|
||||||
String username=gameProfile.getName();
|
String username=gameProfile.getName();
|
||||||
String credential=MinecraftUtil.getCredential(gameProfile);
|
String credential=MinecraftUtil.getCredential(gameProfile);
|
||||||
//Fix: http://hopper.minecraft.net/crashes/minecraft/MCX-2773713
|
//Fix: http://hopper.minecraft.net/crashes/minecraft/MCX-2773713
|
||||||
@@ -60,7 +61,7 @@ public class CustomSkinLoader {
|
|||||||
}
|
}
|
||||||
String tempName=Thread.currentThread().getName();
|
String tempName=Thread.currentThread().getName();
|
||||||
Thread.currentThread().setName(username);//Change Thread Name
|
Thread.currentThread().setName(username);//Change Thread Name
|
||||||
UserProfile profile=null;
|
UserProfile profile;
|
||||||
if(profileCache.isReady(credential)){
|
if(profileCache.isReady(credential)){
|
||||||
logger.info("Cached profile will be used.");
|
logger.info("Cached profile will be used.");
|
||||||
profile=profileCache.getProfile(credential);
|
profile=profileCache.getProfile(credential);
|
||||||
@@ -150,7 +151,7 @@ public class CustomSkinLoader {
|
|||||||
String username=gameProfile.getName();
|
String username=gameProfile.getName();
|
||||||
String credential=MinecraftUtil.getCredential(gameProfile);
|
String credential=MinecraftUtil.getCredential(gameProfile);
|
||||||
|
|
||||||
if(credential==null)
|
if(username == null || credential == null)
|
||||||
return dynamicSkullManager.getTexture(gameProfile);
|
return dynamicSkullManager.getTexture(gameProfile);
|
||||||
if(config.enableUpdateSkull?profileCache.isReady(credential):profileCache.isExist(credential)){
|
if(config.enableUpdateSkull?profileCache.isReady(credential):profileCache.isExist(credential)){
|
||||||
UserProfile profile=profileCache.getProfile(credential);
|
UserProfile profile=profileCache.getProfile(credential);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.io.OutputStreamWriter;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
public class Logger {
|
public class Logger {
|
||||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
public enum Level{
|
public enum Level{
|
||||||
@@ -32,6 +33,9 @@ public class Logger {
|
|||||||
public Logger(){
|
public Logger(){
|
||||||
//Logger isn't created.
|
//Logger isn't created.
|
||||||
}
|
}
|
||||||
|
public Logger(String logFile) {
|
||||||
|
this(new File(logFile));
|
||||||
|
}
|
||||||
public Logger(File logFile){
|
public Logger(File logFile){
|
||||||
try {
|
try {
|
||||||
if(!logFile.getParentFile().exists()){
|
if(!logFile.getParentFile().exists()){
|
||||||
@@ -59,18 +63,14 @@ public class Logger {
|
|||||||
public void log(Level level,String msg){
|
public void log(Level level,String msg){
|
||||||
if(!level.display()&&writer==null)
|
if(!level.display()&&writer==null)
|
||||||
return;
|
return;
|
||||||
StringBuilder sb=new StringBuilder();
|
String sb = String.format("[%s %s] %s", Thread.currentThread().getName(), level.getName(), msg);
|
||||||
sb.append("[").append(Thread.currentThread().getName()).append(" ").append(level.getName()).append("] ");
|
|
||||||
sb.append(msg);
|
|
||||||
if(level.display())
|
if(level.display())
|
||||||
System.out.println(sb.toString());
|
System.out.println(sb);
|
||||||
if(writer==null)
|
if(writer==null)
|
||||||
return;
|
return;
|
||||||
try {
|
try {
|
||||||
StringBuilder sb2=new StringBuilder();
|
String sb2 = String.format("[%s] %s\r\n", DATE_FORMAT.format(new Date()), sb);
|
||||||
sb2.append("[").append(DATE_FORMAT.format(new Date())).append("] ");
|
writer.write(sb2);
|
||||||
sb2.append(sb.toString()).append("\r\n");
|
|
||||||
writer.write(sb2.toString());
|
|
||||||
writer.flush();
|
writer.flush();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -82,9 +82,15 @@ public class Logger {
|
|||||||
public void info(String msg){
|
public void info(String msg){
|
||||||
log(Level.INFO,msg);
|
log(Level.INFO,msg);
|
||||||
}
|
}
|
||||||
|
public void info(String format, Object... objs){
|
||||||
|
info(String.format(format, objs));
|
||||||
|
}
|
||||||
public void warning(String msg){
|
public void warning(String msg){
|
||||||
log(Level.WARNING,msg);
|
log(Level.WARNING,msg);
|
||||||
}
|
}
|
||||||
|
public void warning(String format, Object... objs){
|
||||||
|
warning(String.format(format, objs));
|
||||||
|
}
|
||||||
public void warning(Throwable e){
|
public void warning(Throwable e){
|
||||||
log(Level.WARNING,"Exception: "+e.toString());
|
log(Level.WARNING,"Exception: "+e.toString());
|
||||||
StackTraceElement[] stes=e.getStackTrace();
|
StackTraceElement[] stes=e.getStackTrace();
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.io.Charsets;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
import customskinloader.CustomSkinLoader;
|
import customskinloader.CustomSkinLoader;
|
||||||
@@ -14,6 +13,7 @@ import customskinloader.utils.HttpRequestUtil;
|
|||||||
import customskinloader.utils.HttpTextureUtil;
|
import customskinloader.utils.HttpTextureUtil;
|
||||||
import customskinloader.utils.HttpUtil0;
|
import customskinloader.utils.HttpUtil0;
|
||||||
|
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
public class Config {
|
public class Config {
|
||||||
//Program
|
//Program
|
||||||
public String version;
|
public String version;
|
||||||
@@ -26,7 +26,7 @@ public class Config {
|
|||||||
public boolean forceLoadAllTextures=false;
|
public boolean forceLoadAllTextures=false;
|
||||||
|
|
||||||
//Cache
|
//Cache
|
||||||
public int cacheExpiry=20;
|
public int cacheExpiry=30;
|
||||||
public boolean enableUpdateSkull=false;
|
public boolean enableUpdateSkull=false;
|
||||||
public boolean enableLocalProfileCache=false;
|
public boolean enableLocalProfileCache=false;
|
||||||
public boolean enableCacheAutoClean=false;
|
public boolean enableCacheAutoClean=false;
|
||||||
@@ -104,7 +104,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
CustomSkinLoader.logger.info("Try to load config.");
|
CustomSkinLoader.logger.info("Try to load config.");
|
||||||
String json=FileUtils.readFileToString(CustomSkinLoader.CONFIG_FILE,Charsets.UTF_8);
|
String json=FileUtils.readFileToString(CustomSkinLoader.CONFIG_FILE, "UTF-8");
|
||||||
Config config=CustomSkinLoader.GSON.fromJson(json, Config.class);
|
Config config=CustomSkinLoader.GSON.fromJson(json, Config.class);
|
||||||
CustomSkinLoader.logger.info("Successfully load config.");
|
CustomSkinLoader.logger.info("Successfully load config.");
|
||||||
return config;
|
return config;
|
||||||
@@ -126,12 +126,12 @@ public class Config {
|
|||||||
}
|
}
|
||||||
List<SkinSiteProfile> adds=new ArrayList<SkinSiteProfile>();
|
List<SkinSiteProfile> adds=new ArrayList<SkinSiteProfile>();
|
||||||
File[] files=listAddition.listFiles();
|
File[] files=listAddition.listFiles();
|
||||||
for(File file:files){
|
for(File file: files != null ? files : new File[0]){
|
||||||
if(!file.getName().toLowerCase().endsWith(".json")&&!file.getName().toLowerCase().endsWith(".txt"))
|
if(!file.getName().toLowerCase().endsWith(".json")&&!file.getName().toLowerCase().endsWith(".txt"))
|
||||||
continue;
|
continue;
|
||||||
try {
|
try {
|
||||||
CustomSkinLoader.logger.info("Try to load Extra List.("+file.getName()+")");
|
CustomSkinLoader.logger.info("Try to load Extra List.("+file.getName()+")");
|
||||||
String json=FileUtils.readFileToString(file,Charsets.UTF_8);
|
String json=FileUtils.readFileToString(file, "UTF-8");
|
||||||
SkinSiteProfile ssp=CustomSkinLoader.GSON.fromJson(json, SkinSiteProfile.class);
|
SkinSiteProfile ssp=CustomSkinLoader.GSON.fromJson(json, SkinSiteProfile.class);
|
||||||
CustomSkinLoader.logger.info("Successfully load Extra List.");
|
CustomSkinLoader.logger.info("Successfully load Extra List.");
|
||||||
file.delete();
|
file.delete();
|
||||||
@@ -186,7 +186,7 @@ public class Config {
|
|||||||
CustomSkinLoader.CONFIG_FILE.delete();
|
CustomSkinLoader.CONFIG_FILE.delete();
|
||||||
try {
|
try {
|
||||||
CustomSkinLoader.CONFIG_FILE.createNewFile();
|
CustomSkinLoader.CONFIG_FILE.createNewFile();
|
||||||
FileUtils.write(CustomSkinLoader.CONFIG_FILE, json, Charsets.UTF_8);
|
FileUtils.write(CustomSkinLoader.CONFIG_FILE, json, "UTF-8");
|
||||||
CustomSkinLoader.logger.info("Successfully "+(update?"update":"create")+" config.");
|
CustomSkinLoader.logger.info("Successfully "+(update?"update":"create")+" config.");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CustomSkinLoader.logger.info("Failed to "+(update?"update":"create")+" config.("+e.toString()+")");
|
CustomSkinLoader.logger.info("Failed to "+(update?"update":"create")+" config.("+e.toString()+")");
|
||||||
|
|||||||
@@ -55,10 +55,11 @@ public class SkinSiteProfile {
|
|||||||
ssp.elytra=elytra;
|
ssp.elytra=elytra;
|
||||||
return ssp;
|
return ssp;
|
||||||
}
|
}
|
||||||
public static SkinSiteProfile createElfSkin(String name){
|
|
||||||
SkinSiteProfile ssp=new SkinSiteProfile();
|
public static SkinSiteProfile createElyByAPI(String name) {
|
||||||
ssp.name=name;
|
SkinSiteProfile ssp = new SkinSiteProfile();
|
||||||
ssp.type="ElfSkin";
|
ssp.name = name;
|
||||||
|
ssp.type = "ElyByAPI";
|
||||||
return ssp;
|
return ssp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
package customskinloader.fake;
|
package customskinloader.fake;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
@@ -20,67 +22,66 @@ import net.minecraft.util.ResourceLocation;
|
|||||||
import net.minecraft.util.StringUtils;
|
import net.minecraft.util.StringUtils;
|
||||||
|
|
||||||
public class FakeClientPlayer {
|
public class FakeClientPlayer {
|
||||||
//For Legacy Skin
|
//For Legacy Skin
|
||||||
public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation resourceLocationIn, String username)
|
public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation resourceLocationIn, String username) {
|
||||||
{
|
//CustomSkinLoader.logger.debug("FakeClientPlayer/getDownloadImageSkin "+username);
|
||||||
//CustomSkinLoader.logger.debug("FakeClientPlayer/getDownloadImageSkin "+username);
|
TextureManager textman = Minecraft.getMinecraft().getTextureManager();
|
||||||
|
ITextureObject ito = textman.getTexture(resourceLocationIn);
|
||||||
|
|
||||||
|
if (ito == null || !(ito instanceof ThreadDownloadImageData)) {
|
||||||
|
//if Legacy Skin for username not loaded yet
|
||||||
|
SkinManager skinman = Minecraft.getMinecraft().getSkinManager();
|
||||||
|
UUID offlineUUID = EntityPlayer.getOfflineUUID(username);
|
||||||
|
GameProfile offlineProfile = new GameProfile(offlineUUID, username);
|
||||||
|
|
||||||
|
//Load Default Skin
|
||||||
|
ResourceLocation defaultSkin = DefaultPlayerSkin.getDefaultSkin(offlineUUID);
|
||||||
|
ITextureObject defaultSkinObj = new SimpleTexture(defaultSkin);
|
||||||
|
textman.loadTexture(resourceLocationIn, defaultSkinObj);
|
||||||
|
|
||||||
|
//Load Skin from SkinManager
|
||||||
|
skinman.loadProfileTextures(offlineProfile, new LegacyBuffer(resourceLocationIn), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ito instanceof ThreadDownloadImageData)
|
||||||
|
return (ThreadDownloadImageData) ito;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResourceLocation getLocationSkin(String username) {
|
||||||
|
//CustomSkinLoader.logger.debug("FakeClientPlayer/getLocationSkin "+username);
|
||||||
|
return new ResourceLocation("skins/legacy-" + StringUtils.stripControlCodes(username));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<ResourceLocation, ITextureObject> textureCache = Maps.newHashMap();
|
||||||
|
|
||||||
|
public static class LegacyBuffer implements SkinAvailableCallback {
|
||||||
|
ResourceLocation resourceLocationIn;
|
||||||
|
boolean loaded = false;
|
||||||
|
|
||||||
|
public LegacyBuffer(ResourceLocation resourceLocationIn) {
|
||||||
|
CustomSkinLoader.logger.debug("Loading Legacy Texture (" + resourceLocationIn + ")");
|
||||||
|
this.resourceLocationIn = resourceLocationIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void skinAvailable(Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
||||||
|
if (typeIn != Type.SKIN || loaded)
|
||||||
|
return;
|
||||||
|
|
||||||
TextureManager textman = Minecraft.getMinecraft().getTextureManager();
|
TextureManager textman = Minecraft.getMinecraft().getTextureManager();
|
||||||
ITextureObject ito = textman.getTexture(resourceLocationIn);
|
ITextureObject ito = textman.getTexture(location);
|
||||||
|
if (ito == null)
|
||||||
|
ito = textureCache.get(location);
|
||||||
|
if (ito == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (ito == null || !(ito instanceof ThreadDownloadImageData))
|
loaded = true;
|
||||||
{
|
textman.loadTexture(resourceLocationIn, ito);
|
||||||
//if Legacy Skin for username not loaded yet
|
CustomSkinLoader.logger.debug("Legacy Texture (" + resourceLocationIn + ") Loaded as " +
|
||||||
SkinManager skinman = Minecraft.getMinecraft().getSkinManager();
|
ito.toString() + " (" + location + ")");
|
||||||
UUID offlineUUID=EntityPlayer.getOfflineUUID(username);
|
|
||||||
GameProfile offlineProfile=new GameProfile(offlineUUID,username);
|
|
||||||
|
|
||||||
//Load Default Skin
|
|
||||||
ResourceLocation defaultSkin=DefaultPlayerSkin.getDefaultSkin(offlineUUID);
|
|
||||||
ITextureObject defaultSkinObj=new SimpleTexture(defaultSkin);
|
|
||||||
textman.loadTexture(resourceLocationIn, defaultSkinObj);
|
|
||||||
|
|
||||||
//Load Skin from SkinManager
|
|
||||||
skinman.loadProfileTextures(offlineProfile, new LegacyBuffer(resourceLocationIn), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ito instanceof ThreadDownloadImageData)
|
|
||||||
return (ThreadDownloadImageData)ito;
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResourceLocation getLocationSkin(String username)
|
}
|
||||||
{
|
|
||||||
//CustomSkinLoader.logger.debug("FakeClientPlayer/getLocationSkin "+username);
|
|
||||||
return new ResourceLocation("skins/legacy-" + StringUtils.stripControlCodes(username));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class LegacyBuffer implements SkinAvailableCallback{
|
|
||||||
ResourceLocation resourceLocationIn;
|
|
||||||
boolean loaded=false;
|
|
||||||
|
|
||||||
public LegacyBuffer(ResourceLocation resourceLocationIn) {
|
|
||||||
CustomSkinLoader.logger.debug("Loading Legacy Texture ("+resourceLocationIn+")");
|
|
||||||
this.resourceLocationIn=resourceLocationIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void skinAvailable(Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
|
||||||
if(typeIn!=Type.SKIN || loaded)
|
|
||||||
return;
|
|
||||||
|
|
||||||
loaded=true;
|
|
||||||
|
|
||||||
|
|
||||||
TextureManager textman = Minecraft.getMinecraft().getTextureManager();
|
|
||||||
ITextureObject ito = textman.getTexture(location);
|
|
||||||
|
|
||||||
if(ito!=null)
|
|
||||||
textman.loadTexture(resourceLocationIn, ito);
|
|
||||||
CustomSkinLoader.logger.debug("Legacy Texture ("+resourceLocationIn+") Loaded as "+
|
|
||||||
ito==null?null:ito.toString()+" ("+location+")");
|
|
||||||
//textman.bindTexture(resourceLocationIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,117 +1,151 @@
|
|||||||
package customskinloader.fake;
|
package customskinloader.fake;
|
||||||
|
|
||||||
import java.awt.Color;
|
import customskinloader.CustomSkinLoader;
|
||||||
import java.awt.Graphics;
|
import customskinloader.fake.texture.FakeBufferedImage;
|
||||||
|
import customskinloader.fake.texture.FakeImage;
|
||||||
|
import customskinloader.fake.texture.FakeNativeImage;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.DataBufferInt;
|
|
||||||
import java.awt.image.ImageObserver;
|
|
||||||
|
|
||||||
public class FakeSkinBuffer implements net.minecraft.client.renderer.IImageBuffer {
|
public class FakeSkinBuffer implements net.minecraft.client.renderer.IImageBuffer {
|
||||||
|
|
||||||
private int[] imageData;
|
private int ratio = 1;
|
||||||
private int ratio=1;
|
private FakeImage image = null;
|
||||||
|
|
||||||
@Override
|
//parseUserSkin for 1.13+
|
||||||
public BufferedImage parseUserSkin(BufferedImage image) {
|
public net.minecraft.client.renderer.texture.NativeImage func_195786_a(net.minecraft.client.renderer.texture.NativeImage image) {
|
||||||
if(image==null)
|
if (image == null)
|
||||||
return null;
|
return null;
|
||||||
ratio = image.getWidth() / 64;
|
|
||||||
BufferedImage bufferedimage = new BufferedImage(64 * ratio, 64 * ratio, 2);
|
FakeImage img = parseUserSkin(new FakeNativeImage(image));
|
||||||
Graphics graphics = bufferedimage.getGraphics();
|
if (img instanceof FakeNativeImage)
|
||||||
graphics.setColor(new Color(0,0,0,0));
|
return ((FakeNativeImage) img).getImage();
|
||||||
graphics.fillRect(0,0,64,64);
|
|
||||||
graphics.drawImage(image,0,0,(ImageObserver)null);
|
CustomSkinLoader.logger.warning("Failed to parseUserSkin(func_195786_a).");
|
||||||
if (image.getHeight() == 32 * ratio){//Single Layer
|
return null;
|
||||||
//Revert to original algorithm
|
}
|
||||||
|
|
||||||
|
//parseUserSkin for 1.12.2-
|
||||||
|
public BufferedImage parseUserSkin(BufferedImage image) {
|
||||||
|
if (image == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
FakeImage img = parseUserSkin(new FakeBufferedImage(image));
|
||||||
|
if (img instanceof FakeBufferedImage)
|
||||||
|
return ((FakeBufferedImage) img).getImage();
|
||||||
|
|
||||||
|
CustomSkinLoader.logger.warning("Failed to parseUserSkin.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FakeImage parseUserSkin(FakeImage image) {
|
||||||
|
if (image == null) return null;
|
||||||
|
this.ratio = image.getWidth() / 64;
|
||||||
|
|
||||||
|
if (image.getHeight() != image.getWidth()) {//Single Layer
|
||||||
|
//Create a new image and copy origin image data
|
||||||
|
FakeImage img = image.createImage(64 * ratio, 64 * ratio);
|
||||||
|
img.copyImageData(image); image.close(); image = img;
|
||||||
|
image.fillArea(0 * ratio, 32 * ratio, 64 * ratio, 32 * ratio);
|
||||||
|
|
||||||
//Right Leg -> Left Leg
|
//Right Leg -> Left Leg
|
||||||
graphics.drawImage(bufferedimage, 24 * ratio, 48 * ratio, 20 * ratio, 52 * ratio, 4 * ratio, 16 * ratio, 8 * ratio, 20 * ratio, (ImageObserver)null);//Top
|
image.copyArea( 4 * ratio, 16 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Top
|
||||||
graphics.drawImage(bufferedimage, 28 * ratio, 48 * ratio, 24 * ratio, 52 * ratio, 8 * ratio, 16 * ratio, 12 * ratio, 20 * ratio, (ImageObserver)null);//Bottom
|
image.copyArea( 8 * ratio, 16 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Bottom
|
||||||
graphics.drawImage(bufferedimage, 20 * ratio, 52 * ratio, 16 * ratio, 64 * ratio, 8 * ratio, 20 * ratio, 12 * ratio, 32 * ratio, (ImageObserver)null);//Left
|
image.copyArea( 0 * ratio, 20 * ratio, 24 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Right
|
||||||
graphics.drawImage(bufferedimage, 24 * ratio, 52 * ratio, 20 * ratio, 64 * ratio, 4 * ratio, 20 * ratio, 8 * ratio, 32 * ratio, (ImageObserver)null);//Front
|
image.copyArea( 4 * ratio, 20 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Front
|
||||||
graphics.drawImage(bufferedimage, 28 * ratio, 52 * ratio, 24 * ratio, 64 * ratio, 0 * ratio, 20 * ratio, 4 * ratio, 32 * ratio, (ImageObserver)null);//Right
|
image.copyArea( 8 * ratio, 20 * ratio, 8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Left
|
||||||
graphics.drawImage(bufferedimage, 32 * ratio, 52 * ratio, 28 * ratio, 64 * ratio, 12 * ratio, 20 * ratio, 16 * ratio, 32 * ratio, (ImageObserver)null);//Back
|
image.copyArea(12 * ratio, 20 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Back
|
||||||
//Right Arm -> Left Arm
|
//Right Arm -> Left Arm
|
||||||
graphics.drawImage(bufferedimage, 40 * ratio, 48 * ratio, 36 * ratio, 52 * ratio, 44 * ratio, 16 * ratio, 48 * ratio, 20 * ratio, (ImageObserver)null);//Top
|
image.copyArea(44 * ratio, 16 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Top
|
||||||
graphics.drawImage(bufferedimage, 44 * ratio, 48 * ratio, 40 * ratio, 52 * ratio, 48 * ratio, 16 * ratio, 52 * ratio, 20 * ratio, (ImageObserver)null);//Bottom
|
image.copyArea(48 * ratio, 16 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Bottom
|
||||||
graphics.drawImage(bufferedimage, 36 * ratio, 52 * ratio, 32 * ratio, 64 * ratio, 48 * ratio, 20 * ratio, 52 * ratio, 32 * ratio, (ImageObserver)null);//Left
|
image.copyArea(40 * ratio, 20 * ratio, 0 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Right
|
||||||
graphics.drawImage(bufferedimage, 40 * ratio, 52 * ratio, 36 * ratio, 64 * ratio, 44 * ratio, 20 * ratio, 48 * ratio, 32 * ratio, (ImageObserver)null);//Front
|
image.copyArea(44 * ratio, 20 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Front
|
||||||
graphics.drawImage(bufferedimage, 44 * ratio, 52 * ratio, 40 * ratio, 64 * ratio, 40 * ratio, 20 * ratio, 44 * ratio, 32 * ratio, (ImageObserver)null);//Right
|
image.copyArea(48 * ratio, 20 * ratio,-16 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Left
|
||||||
graphics.drawImage(bufferedimage, 48 * ratio, 52 * ratio, 44 * ratio, 64 * ratio, 52 * ratio, 20 * ratio, 56 * ratio, 32 * ratio, (ImageObserver)null);//Back
|
image.copyArea(52 * ratio, 20 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Back
|
||||||
}
|
}
|
||||||
graphics.dispose();
|
|
||||||
this.imageData = ((DataBufferInt)bufferedimage.getRaster().getDataBuffer()).getData();
|
|
||||||
|
|
||||||
setAreaDueToConfig( 0 * ratio, 0 * ratio,32 * ratio,16 * ratio);//Head - 1
|
this.image = image;
|
||||||
setAreaTransparent(32 * ratio, 0 * ratio,64 * ratio,16 * ratio);//Head - 2
|
setAreaDueToConfig( 0 * ratio, 0 * ratio, 32 * ratio, 16 * ratio);//Head - 1
|
||||||
|
setAreaTransparent(32 * ratio, 0 * ratio, 64 * ratio, 16 * ratio);//Head - 2
|
||||||
|
setAreaDueToConfig(16 * ratio, 16 * ratio, 40 * ratio, 32 * ratio);//Body - 1
|
||||||
|
setAreaTransparent(16 * ratio, 32 * ratio, 40 * ratio, 48 * ratio);//Body - 2
|
||||||
|
|
||||||
setAreaDueToConfig( 0 * ratio,16 * ratio,16 * ratio,32 * ratio);//Right Leg - 1
|
setAreaDueToConfig(40 * ratio, 16 * ratio, 56 * ratio, 32 * ratio);//Right Arm - 1
|
||||||
setAreaDueToConfig(16 * ratio,16 * ratio,40 * ratio,32 * ratio);//Body - 1
|
setAreaTransparent(40 * ratio, 32 * ratio, 56 * ratio, 48 * ratio);//Right Arm - 2
|
||||||
setAreaDueToConfig(40 * ratio,16 * ratio,56 * ratio,32 * ratio);//Right Arm - 1
|
setAreaDueToConfig( 0 * ratio, 16 * ratio, 16 * ratio, 32 * ratio);//Right Leg - 1
|
||||||
|
setAreaTransparent( 0 * ratio, 32 * ratio, 16 * ratio, 48 * ratio);//Right Leg - 2
|
||||||
|
|
||||||
setAreaTransparent( 0 * ratio,32 * ratio,16 * ratio,48 * ratio);//Right Leg - 2
|
setAreaDueToConfig(32 * ratio, 48 * ratio, 48 * ratio, 64 * ratio);//Left Arm - 1
|
||||||
setAreaTransparent(16 * ratio,32 * ratio,40 * ratio,48 * ratio);//Body - 2
|
setAreaTransparent(48 * ratio, 48 * ratio, 64 * ratio, 64 * ratio);//Left Arm - 2
|
||||||
setAreaTransparent(40 * ratio,32 * ratio,56 * ratio,48 * ratio);//Right Arm - 2
|
setAreaDueToConfig(16 * ratio, 48 * ratio, 32 * ratio, 64 * ratio);//Left Leg - 1
|
||||||
|
setAreaTransparent( 0 * ratio, 48 * ratio, 16 * ratio, 64 * ratio);//Left Leg - 2
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
setAreaTransparent( 0 * ratio,48 * ratio,16 * ratio,64 * ratio);//Left Leg - 2
|
/**
|
||||||
setAreaDueToConfig(16 * ratio,48 * ratio,32 * ratio,64 * ratio);//Left Leg - 1
|
* Judge the type of skin
|
||||||
setAreaDueToConfig(32 * ratio,48 * ratio,48 * ratio,64 * ratio);//Left Arm - 1
|
* Must be called after parseUserSkin
|
||||||
setAreaTransparent(48 * ratio,48 * ratio,64 * ratio,64 * ratio);//Left Arm - 2
|
*
|
||||||
|
* @return type of skin (slim / default)
|
||||||
return bufferedimage;
|
* @since 14.9
|
||||||
|
*/
|
||||||
|
public String judgeType() {
|
||||||
|
if (this.image == null)
|
||||||
|
return null;
|
||||||
|
if (((image.getRGBA(55, 20) & B) >>> 24) == 0)//if (55,20) is transparent
|
||||||
|
return "slim";
|
||||||
|
return "default";
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 2^24-1
|
/* 2^24-1
|
||||||
* 00000000 11111111 11111111 11111111 */
|
* 00000000 11111111 11111111 11111111 */
|
||||||
private static final int A=16777215;
|
private static final int A = 16777215;
|
||||||
private static final int WHITE=getARGB(255,255,255,255);
|
private static final int WHITE = getARGB(255, 255, 255, 255);
|
||||||
private static final int BLACK=getARGB(255,0,0,0);
|
private static final int BLACK = getARGB(255, 0, 0, 0);
|
||||||
private boolean isFilled(int x0,int y0,int x1,int y1){
|
|
||||||
int data=this.imageData[getPosition(x0,y0)];
|
private boolean isFilled(int x0, int y0, int x1, int y1) {
|
||||||
if(data!=WHITE && data!=BLACK)
|
int data = image.getRGBA(x0, y0);
|
||||||
|
if (data != WHITE && data != BLACK)
|
||||||
return false;
|
return false;
|
||||||
for (int x=x0;x<x1;++x)
|
for (int x = x0; x < x1; ++x)
|
||||||
for (int y=y0;y<y1;++y)
|
for (int y = y0; y < y1; ++y)
|
||||||
if(this.imageData[getPosition(x,y)]!=data)
|
if (image.getRGBA(x, y) != data)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private void setAreaTransparent(int x0,int y0,int x1,int y1){
|
|
||||||
if(!isFilled(x0,y0,x1,y1))
|
private void setAreaTransparent(int x0, int y0, int x1, int y1) {
|
||||||
|
if (!isFilled(x0, y0, x1, y1))
|
||||||
return;
|
return;
|
||||||
for (int x=x0;x<x1;++x)
|
for (int x = x0; x < x1; ++x)
|
||||||
for (int y=y0;y<y1;++y)
|
for (int y = y0; y < y1; ++y)
|
||||||
this.imageData[getPosition(x,y)] &= A;
|
image.setRGBA(x, y, image.getRGBA(x,y) & A);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -2^24
|
/* -2^24
|
||||||
* 00000001 00000000 00000000 00000000 ->
|
* 00000001 00000000 00000000 00000000 ->
|
||||||
* 11111110 11111111 11111111 11111111 ->
|
* 11111110 11111111 11111111 11111111 ->
|
||||||
* 11111111 00000000 00000000 00000000 */
|
* 11111111 00000000 00000000 00000000 */
|
||||||
private static final int B=-16777216;
|
private static final int B = -16777216;
|
||||||
private void setAreaOpaque(int x0,int y0,int x1,int y1){
|
|
||||||
for (int x=x0;x<x1;++x)
|
private void setAreaOpaque(int x0, int y0, int x1, int y1) {
|
||||||
for (int y=y0;y<y1;++y)
|
for (int x = x0; x < x1; ++x)
|
||||||
this.imageData[getPosition(x,y)] |= B;
|
for (int y = y0; y < y1; ++y)
|
||||||
|
image.setRGBA(x, y, image.getRGBA(x,y) | B);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAreaDueToConfig(int x0,int y0,int x1,int y1){
|
private void setAreaDueToConfig(int x0, int y0, int x1, int y1) {
|
||||||
if(customskinloader.CustomSkinLoader.config.enableTransparentSkin)
|
if (customskinloader.CustomSkinLoader.config.enableTransparentSkin)
|
||||||
setAreaTransparent(x0,y0,x1,y1);
|
setAreaTransparent(x0, y0, x1, y1);
|
||||||
else
|
else
|
||||||
setAreaOpaque(x0,y0,x1,y1);
|
setAreaOpaque(x0, y0, x1, y1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void skinAvailable() {
|
||||||
@Override
|
//A callback when skin loaded, nothing to do
|
||||||
public void skinAvailable(){
|
|
||||||
//A callback when skin loaded
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getARGB(int a,int r,int g,int b){
|
private static int getARGB(int a, int r, int g, int b) {
|
||||||
return (a << 24) | (r << 16) | (g << 8) | b;
|
return (a << 24) | (r << 16) | (g << 8) | b;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getPosition(int x,int y){
|
|
||||||
return x+y*64*ratio;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
|
|||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
public class FakeSkinManager{
|
public class FakeSkinManager{
|
||||||
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(0, 2, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue());
|
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(0, 2, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>());
|
||||||
private final TextureManager textureManager;
|
private final TextureManager textureManager;
|
||||||
|
|
||||||
public FakeSkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) {
|
public FakeSkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) {
|
||||||
@@ -50,6 +50,8 @@ public class FakeSkinManager{
|
|||||||
else{
|
else{
|
||||||
ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(info.cacheFile, info.url, DefaultPlayerSkin.getDefaultSkinLegacy(),
|
ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(info.cacheFile, info.url, DefaultPlayerSkin.getDefaultSkinLegacy(),
|
||||||
new BaseBuffer(skinAvailableCallback, textureType, resourcelocation, profileTexture));
|
new BaseBuffer(skinAvailableCallback, textureType, resourcelocation, profileTexture));
|
||||||
|
if(skinAvailableCallback instanceof FakeClientPlayer.LegacyBuffer)//Cache for client player
|
||||||
|
FakeClientPlayer.textureCache.put(resourcelocation,threaddownloadimagedata);
|
||||||
this.textureManager.loadTexture(resourcelocation, threaddownloadimagedata);
|
this.textureManager.loadTexture(resourcelocation, threaddownloadimagedata);
|
||||||
}
|
}
|
||||||
return resourcelocation;
|
return resourcelocation;
|
||||||
@@ -57,14 +59,14 @@ public class FakeSkinManager{
|
|||||||
public void loadProfileTextures(final GameProfile profile, final SkinAvailableCallback skinAvailableCallback, final boolean requireSecure){
|
public void loadProfileTextures(final GameProfile profile, final SkinAvailableCallback skinAvailableCallback, final boolean requireSecure){
|
||||||
THREAD_POOL.submit(new Runnable(){
|
THREAD_POOL.submit(new Runnable(){
|
||||||
public void run(){
|
public void run(){
|
||||||
final Map<Type, MinecraftProfileTexture> map = Maps.<Type, MinecraftProfileTexture>newHashMap();
|
final Map<Type, MinecraftProfileTexture> map = Maps.newHashMap();
|
||||||
map.putAll(customskinloader.CustomSkinLoader.loadProfile(profile));
|
map.putAll(customskinloader.CustomSkinLoader.loadProfile(profile));
|
||||||
|
|
||||||
Minecraft.getMinecraft().addScheduledTask(new Runnable(){
|
Minecraft.getMinecraft().addScheduledTask(new Runnable(){
|
||||||
public void run(){
|
public void run(){
|
||||||
for(Type type:Type.values())
|
for(Type type:Type.values())
|
||||||
if(map.containsKey(type))
|
if(map.containsKey(type))
|
||||||
FakeSkinManager.this.loadSkin((MinecraftProfileTexture)map.get(type), type, skinAvailableCallback);
|
FakeSkinManager.this.loadSkin(map.get(type), type, skinAvailableCallback);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -94,12 +96,22 @@ public class FakeSkinManager{
|
|||||||
this.texture=texture;
|
this.texture=texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public net.minecraft.client.renderer.texture.NativeImage func_195786_a(net.minecraft.client.renderer.texture.NativeImage image){
|
||||||
|
return buffer instanceof FakeSkinBuffer ? ((FakeSkinBuffer) buffer).func_195786_a(image) : image;
|
||||||
|
}
|
||||||
public BufferedImage parseUserSkin(BufferedImage image){
|
public BufferedImage parseUserSkin(BufferedImage image){
|
||||||
return buffer==null?image:buffer.parseUserSkin(image);
|
return buffer==null?image:buffer.parseUserSkin(image);
|
||||||
}
|
}
|
||||||
public void skinAvailable(){
|
public void skinAvailable(){
|
||||||
if (buffer != null)
|
if (buffer != null){
|
||||||
buffer.skinAvailable();
|
buffer.skinAvailable();
|
||||||
|
if ("auto".equals(texture.getMetadata("model")) && buffer instanceof FakeSkinBuffer){
|
||||||
|
//Auto judge skin type
|
||||||
|
Map<String, String> metadata = Maps.newHashMap();
|
||||||
|
metadata.put("model", ((FakeSkinBuffer) buffer).judgeType());
|
||||||
|
texture = new MinecraftProfileTexture(texture.getUrl(), metadata);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FakeSkinManager.makeCallback(callback,type, location, texture);
|
FakeSkinManager.makeCallback(callback,type, location, texture);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package customskinloader.fake.texture;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
public class FakeBufferedImage implements FakeImage {
|
||||||
|
private BufferedImage image;
|
||||||
|
private Graphics graphics;
|
||||||
|
|
||||||
|
public FakeBufferedImage(int width, int height) {
|
||||||
|
this(new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB));
|
||||||
|
}
|
||||||
|
|
||||||
|
public FakeBufferedImage(BufferedImage image) {
|
||||||
|
this.image = image;
|
||||||
|
graphics = image.getGraphics();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BufferedImage getImage() {
|
||||||
|
graphics.dispose();
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FakeImage createImage(int width, int height) {
|
||||||
|
return new FakeBufferedImage(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWidth() {
|
||||||
|
return image.getWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeight() {
|
||||||
|
return image.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRGBA(int x, int y) {
|
||||||
|
return image.getRGB(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRGBA(int x, int y, int rgba) {
|
||||||
|
image.setRGB(x, y, rgba);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void copyImageData(FakeImage image) {
|
||||||
|
if (!(image instanceof FakeBufferedImage)) return;
|
||||||
|
BufferedImage img = ((FakeBufferedImage) image).getImage();
|
||||||
|
graphics.drawImage(img, 0, 0, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillArea(int x0, int y0, int width, int height) {
|
||||||
|
graphics.setColor(new Color(0, 0, 0, 0));
|
||||||
|
graphics.fillRect(x0, y0, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void copyArea(int x0, int y0, int dx, int dy, int width, int height, boolean reversex, boolean reversey) {
|
||||||
|
int x1 = x0 + width, x2 = x0 + dx, x3 = x2 + width;
|
||||||
|
int y1 = y0 + height, y2 = y0 + dy, y3 = y2 + height;
|
||||||
|
graphics.drawImage(image,
|
||||||
|
reversex ? x3 : x2, reversey ? y3 : y2,
|
||||||
|
reversex ? x2 : x3, reversey ? y2 : y3,
|
||||||
|
x0, y0, x1, y1, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
graphics.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package customskinloader.fake.texture;
|
||||||
|
|
||||||
|
public interface FakeImage {
|
||||||
|
FakeImage createImage(int width, int height);
|
||||||
|
|
||||||
|
int getWidth();
|
||||||
|
|
||||||
|
int getHeight();
|
||||||
|
|
||||||
|
int getRGBA(int x, int y);
|
||||||
|
|
||||||
|
void setRGBA(int x, int y, int rgba);
|
||||||
|
|
||||||
|
void copyImageData(FakeImage image);
|
||||||
|
|
||||||
|
void fillArea(int x0, int y0, int width, int height);
|
||||||
|
|
||||||
|
void copyArea(int x0, int y0, int dx, int dy, int width, int height, boolean reversex, boolean reversey);
|
||||||
|
|
||||||
|
void close();
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package customskinloader.fake.texture;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.NativeImage;
|
||||||
|
|
||||||
|
public class FakeNativeImage implements FakeImage {
|
||||||
|
private NativeImage image;
|
||||||
|
|
||||||
|
public FakeNativeImage(int width, int height) {
|
||||||
|
this(new NativeImage(width, height, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
public FakeNativeImage(NativeImage image) {
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NativeImage getImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FakeImage createImage(int width, int height) {
|
||||||
|
return new FakeNativeImage(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWidth() {
|
||||||
|
return image.func_195702_a();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeight() {
|
||||||
|
return image.func_195714_b();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRGBA(int x, int y) {
|
||||||
|
return image.func_195709_a(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRGBA(int x, int y, int rgba) {
|
||||||
|
image.func_195700_a(x, y, rgba);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void copyImageData(FakeImage image) {
|
||||||
|
if (!(image instanceof FakeNativeImage)) return;
|
||||||
|
this.image.func_195703_a(((FakeNativeImage) image).getImage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillArea(int x0, int y0, int width, int height) {
|
||||||
|
image.func_195715_a(x0, y0, width, height, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void copyArea(int x0, int y0, int dx, int dy, int width, int height, boolean reversex, boolean reversey) {
|
||||||
|
image.func_195699_a(x0, y0, dx, dy, width, height, reversex, reversey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,19 +20,22 @@ import customskinloader.utils.HttpRequestUtil.HttpResponce;
|
|||||||
public class JsonAPILoader implements ProfileLoader.IProfileLoader {
|
public class JsonAPILoader implements ProfileLoader.IProfileLoader {
|
||||||
|
|
||||||
public interface IJsonAPI {
|
public interface IJsonAPI {
|
||||||
public String toJsonUrl(String root,String username);
|
String toJsonUrl(String root, String username);
|
||||||
public String getPayload(SkinSiteProfile ssp);
|
String getPayload(SkinSiteProfile ssp);
|
||||||
public UserProfile toUserProfile(String root,String json,boolean local);
|
UserProfile toUserProfile(String root, String json, boolean local);
|
||||||
public String getName();
|
String getName();
|
||||||
}
|
}
|
||||||
public static class ErrorProfile{
|
public static class ErrorProfile{
|
||||||
public int errno;
|
public int errno;
|
||||||
public String msg;
|
public String msg;
|
||||||
}
|
}
|
||||||
public static enum Type{
|
public enum Type{
|
||||||
CustomSkinAPI(new CustomSkinAPI()),CustomSkinAPIPlus(new CustomSkinAPIPlus()),UniSkinAPI(new UniSkinAPI());
|
CustomSkinAPI(new CustomSkinAPI()),
|
||||||
|
CustomSkinAPIPlus(new CustomSkinAPIPlus()),
|
||||||
|
UniSkinAPI(new UniSkinAPI()),
|
||||||
|
ElyByAPI(new ElyByAPI());
|
||||||
public IJsonAPI jsonAPI;
|
public IJsonAPI jsonAPI;
|
||||||
private Type(IJsonAPI jsonAPI){
|
Type(IJsonAPI jsonAPI){
|
||||||
this.jsonAPI=jsonAPI;
|
this.jsonAPI=jsonAPI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,20 +48,20 @@ public class JsonAPILoader implements ProfileLoader.IProfileLoader {
|
|||||||
@Override
|
@Override
|
||||||
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
|
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
|
||||||
String username=gameProfile.getName();
|
String username=gameProfile.getName();
|
||||||
boolean local=HttpUtil0.isLocal(ssp.root);
|
if(StringUtils.isEmpty(ssp.root) && type!=Type.ElyByAPI){
|
||||||
if(ssp.root==null||ssp.root.equals("")){
|
|
||||||
CustomSkinLoader.logger.info("Root not defined.");
|
CustomSkinLoader.logger.info("Root not defined.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
boolean local = HttpUtil0.isLocal(ssp.root);
|
||||||
String jsonUrl=type.jsonAPI.toJsonUrl(ssp.root, username);
|
String jsonUrl=type.jsonAPI.toJsonUrl(ssp.root, username);
|
||||||
String json;
|
String json;
|
||||||
if(local){
|
if(local){
|
||||||
File jsonFile=new File(jsonUrl);
|
File jsonFile = new File(CustomSkinLoader.DATA_DIR, jsonUrl);
|
||||||
if(!jsonFile.exists()){
|
if(!jsonFile.exists()){
|
||||||
CustomSkinLoader.logger.info("Profile File not found.");
|
CustomSkinLoader.logger.info("Profile File not found.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
json=IOUtils.toString(new FileInputStream(jsonFile));
|
json=IOUtils.toString(new FileInputStream(jsonFile), "UTF-8");
|
||||||
}else{
|
}else{
|
||||||
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(jsonUrl).setCacheTime(90).setUserAgent(ssp.userAgent).setPayload(type.jsonAPI.getPayload(ssp)));
|
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(jsonUrl).setCacheTime(90).setUserAgent(ssp.userAgent).setPayload(type.jsonAPI.getPayload(ssp)));
|
||||||
json=responce.content;
|
json=responce.content;
|
||||||
@@ -84,12 +87,13 @@ public class JsonAPILoader implements ProfileLoader.IProfileLoader {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
|
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
|
||||||
return StringUtils.isNoneEmpty(ssp0.root)?ssp0.root.equalsIgnoreCase(ssp1.root):true;
|
return !StringUtils.isNoneEmpty(ssp0.root) || ssp0.root.equalsIgnoreCase(ssp1.root);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return type.jsonAPI.getName();
|
return type.jsonAPI.getName();
|
||||||
}
|
}
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
@Override
|
@Override
|
||||||
public void initLocalFolder(SkinSiteProfile ssp) {
|
public void initLocalFolder(SkinSiteProfile ssp) {
|
||||||
if(HttpUtil0.isLocal(ssp.root)){
|
if(HttpUtil0.isLocal(ssp.root)){
|
||||||
|
|||||||
@@ -17,45 +17,45 @@ import customskinloader.utils.HttpTextureUtil;
|
|||||||
import customskinloader.utils.HttpUtil0;
|
import customskinloader.utils.HttpUtil0;
|
||||||
|
|
||||||
public class LegacyLoader implements ProfileLoader.IProfileLoader {
|
public class LegacyLoader implements ProfileLoader.IProfileLoader {
|
||||||
public static final String USERNAME_REGEX="\\{USERNAME\\}";
|
public static final String USERNAME_PLACEHOLDER="{USERNAME}";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
|
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
|
||||||
String username=gameProfile.getName();
|
String username=gameProfile.getName();
|
||||||
UserProfile profile=new UserProfile();
|
UserProfile profile=new UserProfile();
|
||||||
if(StringUtils.isNoneEmpty(ssp.skin)){
|
if(StringUtils.isNoneEmpty(ssp.skin)){
|
||||||
String skin=ssp.skin.replaceAll(USERNAME_REGEX, username);
|
String skin=ssp.skin.replace(USERNAME_PLACEHOLDER, username);
|
||||||
if(HttpUtil0.isLocal(ssp.skin)){
|
if(HttpUtil0.isLocal(ssp.skin)){
|
||||||
File skinFile=new File(CustomSkinLoader.DATA_DIR,skin);
|
File skinFile=new File(CustomSkinLoader.DATA_DIR,skin);
|
||||||
if(skinFile.exists()&&skinFile.isFile())
|
if(skinFile.exists()&&skinFile.isFile())
|
||||||
profile.skinUrl=HttpTextureUtil.getLocalLegacyFakeUrl(skin, HttpTextureUtil.getHash(skin, skinFile.length(), skinFile.lastModified()));
|
profile.skinUrl=HttpTextureUtil.getLocalLegacyFakeUrl(skin, HttpTextureUtil.getHash(skin, skinFile.length(), skinFile.lastModified()));
|
||||||
}else{
|
}else{
|
||||||
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(skin).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null&&ssp.checkPNG!=false).setLoadContent(false).setCacheTime(90));
|
HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequest(skin).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null && ssp.checkPNG).setLoadContent(false).setCacheTime(90));
|
||||||
if(responce.success)
|
if(responce.success)
|
||||||
profile.skinUrl=HttpTextureUtil.getLegacyFakeUrl(skin);
|
profile.skinUrl=HttpTextureUtil.getLegacyFakeUrl(skin);
|
||||||
}
|
}
|
||||||
profile.model=profile.hasSkinUrl()?ssp.model:null;
|
profile.model=profile.hasSkinUrl()?ssp.model:null;
|
||||||
}
|
}
|
||||||
if(StringUtils.isNoneEmpty(ssp.cape)){
|
if(StringUtils.isNoneEmpty(ssp.cape)){
|
||||||
String cape=ssp.cape.replaceAll(USERNAME_REGEX, username);
|
String cape=ssp.cape.replace(USERNAME_PLACEHOLDER, username);
|
||||||
if(HttpUtil0.isLocal(ssp.cape)){
|
if(HttpUtil0.isLocal(ssp.cape)){
|
||||||
File capeFile=new File(CustomSkinLoader.DATA_DIR,cape);
|
File capeFile=new File(CustomSkinLoader.DATA_DIR,cape);
|
||||||
if(capeFile.exists()&&capeFile.isFile())
|
if(capeFile.exists()&&capeFile.isFile())
|
||||||
profile.capeUrl=HttpTextureUtil.getLocalLegacyFakeUrl(cape, HttpTextureUtil.getHash(cape, capeFile.length(), capeFile.lastModified()));
|
profile.capeUrl=HttpTextureUtil.getLocalLegacyFakeUrl(cape, HttpTextureUtil.getHash(cape, capeFile.length(), capeFile.lastModified()));
|
||||||
}else{
|
}else{
|
||||||
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(cape).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null&&ssp.checkPNG!=false).setLoadContent(false).setCacheTime(90));
|
HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequest(cape).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null && ssp.checkPNG).setLoadContent(false).setCacheTime(90));
|
||||||
if(responce.success)
|
if(responce.success)
|
||||||
profile.capeUrl=HttpTextureUtil.getLegacyFakeUrl(cape);
|
profile.capeUrl=HttpTextureUtil.getLegacyFakeUrl(cape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(ModelManager0.isElytraSupported()&&StringUtils.isNoneEmpty(ssp.elytra)){
|
if(ModelManager0.isElytraSupported()&&StringUtils.isNoneEmpty(ssp.elytra)){
|
||||||
String elytra=ssp.elytra.replaceAll(USERNAME_REGEX, username);
|
String elytra=ssp.elytra.replace(USERNAME_PLACEHOLDER, username);
|
||||||
if(HttpUtil0.isLocal(ssp.elytra)){
|
if(HttpUtil0.isLocal(ssp.elytra)){
|
||||||
File elytraFile=new File(CustomSkinLoader.DATA_DIR,elytra);
|
File elytraFile=new File(CustomSkinLoader.DATA_DIR,elytra);
|
||||||
if(elytraFile.exists()&&elytraFile.isFile())
|
if(elytraFile.exists()&&elytraFile.isFile())
|
||||||
profile.elytraUrl=HttpTextureUtil.getLocalLegacyFakeUrl(elytra, HttpTextureUtil.getHash(elytra, elytraFile.length(), elytraFile.lastModified()));
|
profile.elytraUrl=HttpTextureUtil.getLocalLegacyFakeUrl(elytra, HttpTextureUtil.getHash(elytra, elytraFile.length(), elytraFile.lastModified()));
|
||||||
}else{
|
}else{
|
||||||
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(elytra).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null&&ssp.checkPNG!=false).setLoadContent(false).setCacheTime(90));
|
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(elytra).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null && ssp.checkPNG).setLoadContent(false).setCacheTime(90));
|
||||||
if(responce.success)
|
if(responce.success)
|
||||||
profile.elytraUrl=HttpTextureUtil.getLegacyFakeUrl(elytra);
|
profile.elytraUrl=HttpTextureUtil.getLegacyFakeUrl(elytra);
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ public class LegacyLoader implements ProfileLoader.IProfileLoader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
|
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
|
||||||
return (StringUtils.isNoneEmpty(ssp0.skin)?ssp0.skin.equalsIgnoreCase(ssp1.skin):true) || (StringUtils.isNoneEmpty(ssp0.cape)?ssp0.cape.equalsIgnoreCase(ssp1.cape):true);
|
return (!StringUtils.isNoneEmpty(ssp0.skin) || ssp0.skin.equalsIgnoreCase(ssp1.skin)) || (!StringUtils.isNoneEmpty(ssp0.cape) || ssp0.cape.equalsIgnoreCase(ssp1.cape));
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -85,8 +85,9 @@ public class LegacyLoader implements ProfileLoader.IProfileLoader {
|
|||||||
if(HttpUtil0.isLocal(ssp.elytra))
|
if(HttpUtil0.isLocal(ssp.elytra))
|
||||||
initFolder(ssp.elytra);
|
initFolder(ssp.elytra);
|
||||||
}
|
}
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
private void initFolder(String target){
|
private void initFolder(String target){
|
||||||
String file=target.replaceAll(USERNAME_REGEX, "init");
|
String file=target.replace(USERNAME_PLACEHOLDER, "init");
|
||||||
File folder=new File(CustomSkinLoader.DATA_DIR,file).getParentFile();
|
File folder=new File(CustomSkinLoader.DATA_DIR,file).getParentFile();
|
||||||
if(folder!=null&&!folder.exists())
|
if(folder!=null&&!folder.exists())
|
||||||
folder.mkdirs();
|
folder.mkdirs();
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package customskinloader.loader;
|
package customskinloader.loader;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
import org.apache.commons.codec.Charsets;
|
import org.apache.commons.codec.Charsets;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -56,7 +56,7 @@ public class MojangAPILoader implements ProfileLoader.IProfileLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Username -> UUID
|
//Username -> UUID
|
||||||
public static GameProfile loadGameProfile(String username) throws Exception{
|
public static GameProfile loadGameProfile(String username) {
|
||||||
//Doc (http://wiki.vg/Mojang_API#Username_-.3E_UUID_at_time)
|
//Doc (http://wiki.vg/Mojang_API#Username_-.3E_UUID_at_time)
|
||||||
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest("https://api.mojang.com/users/profiles/minecraft/"+username).setCacheTime(0));
|
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest("https://api.mojang.com/users/profiles/minecraft/"+username).setCacheTime(0));
|
||||||
if(StringUtils.isEmpty(responce.content))
|
if(StringUtils.isEmpty(responce.content))
|
||||||
@@ -70,9 +70,11 @@ public class MojangAPILoader implements ProfileLoader.IProfileLoader {
|
|||||||
return new GameProfile(gameProfile.getId(),gameProfile.getName());
|
return new GameProfile(gameProfile.getId(),gameProfile.getName());
|
||||||
}
|
}
|
||||||
//UUID -> Profile
|
//UUID -> Profile
|
||||||
public static GameProfile fillGameProfile(GameProfile profile) throws Exception{
|
public static GameProfile fillGameProfile(GameProfile profile) {
|
||||||
//Doc (http://wiki.vg/Mojang_API#UUID_-.3E_Profile_.2B_Skin.2FCape)
|
//Doc (http://wiki.vg/Mojang_API#UUID_-.3E_Profile_.2B_Skin.2FCape)
|
||||||
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest("https://sessionserver.mojang.com/session/minecraft/profile/"+UUIDTypeAdapter.fromUUID(profile.getId())).setCacheTime(90));
|
HttpResponce responce = HttpRequestUtil.makeHttpRequest(
|
||||||
|
new HttpRequest("https://sessionserver.mojang.com/session/minecraft/profile/"
|
||||||
|
+ UUIDTypeAdapter.fromUUID(profile.getId())).setCacheTime(90));
|
||||||
if(StringUtils.isEmpty(responce.content))
|
if(StringUtils.isEmpty(responce.content))
|
||||||
return profile;
|
return profile;
|
||||||
|
|
||||||
@@ -87,20 +89,20 @@ public class MojangAPILoader implements ProfileLoader.IProfileLoader {
|
|||||||
return newGameProfile;
|
return newGameProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<MinecraftProfileTexture.Type,MinecraftProfileTexture> getTextures(GameProfile gameProfile) throws Exception{
|
public static Map<MinecraftProfileTexture.Type,MinecraftProfileTexture> getTextures(GameProfile gameProfile) {
|
||||||
if(gameProfile==null)
|
if(gameProfile==null)
|
||||||
return new HashMap();
|
return Maps.newHashMap();
|
||||||
Property textureProperty=(Property)Iterables.getFirst(gameProfile.getProperties().get("textures"), null);
|
Property textureProperty=Iterables.getFirst(gameProfile.getProperties().get("textures"), null);
|
||||||
if (textureProperty==null)
|
if (textureProperty==null)
|
||||||
return new HashMap();
|
return Maps.newHashMap();
|
||||||
String value=textureProperty.getValue();
|
String value=textureProperty.getValue();
|
||||||
if(StringUtils.isBlank(value))
|
if(StringUtils.isBlank(value))
|
||||||
return new HashMap();
|
return Maps.newHashMap();
|
||||||
String json=new String(Base64.decodeBase64(value),Charsets.UTF_8);
|
@SuppressWarnings("deprecation") String json = new String(Base64.decodeBase64(value), Charsets.UTF_8);
|
||||||
Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class,new UUIDTypeAdapter()).create();
|
Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class,new UUIDTypeAdapter()).create();
|
||||||
MinecraftTexturesPayload result=gson.fromJson(json,MinecraftTexturesPayload.class);
|
MinecraftTexturesPayload result=gson.fromJson(json,MinecraftTexturesPayload.class);
|
||||||
if (result==null||result.getTextures()==null)
|
if (result==null||result.getTextures()==null)
|
||||||
return new HashMap();
|
return Maps.newHashMap();
|
||||||
return result.getTextures();
|
return result.getTextures();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,9 @@ public class ProfileLoader {
|
|||||||
new MojangAPILoader(),
|
new MojangAPILoader(),
|
||||||
new JsonAPILoader(JsonAPILoader.Type.CustomSkinAPI),
|
new JsonAPILoader(JsonAPILoader.Type.CustomSkinAPI),
|
||||||
new JsonAPILoader(JsonAPILoader.Type.CustomSkinAPIPlus),
|
new JsonAPILoader(JsonAPILoader.Type.CustomSkinAPIPlus),
|
||||||
new LegacyLoader(),
|
new JsonAPILoader(JsonAPILoader.Type.UniSkinAPI),
|
||||||
new JsonAPILoader(JsonAPILoader.Type.UniSkinAPI)};
|
new JsonAPILoader(JsonAPILoader.Type.ElyByAPI),
|
||||||
|
new LegacyLoader()};
|
||||||
|
|
||||||
public static final HashMap<String,IProfileLoader> LOADERS=initLoaders();
|
public static final HashMap<String,IProfileLoader> LOADERS=initLoaders();
|
||||||
|
|
||||||
@@ -26,9 +27,9 @@ public class ProfileLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface IProfileLoader {
|
public interface IProfileLoader {
|
||||||
public UserProfile loadProfile(SkinSiteProfile ssp,GameProfile gameProfile) throws Exception;
|
UserProfile loadProfile(SkinSiteProfile ssp,GameProfile gameProfile) throws Exception;
|
||||||
public boolean compare(SkinSiteProfile ssp0,SkinSiteProfile ssp1);
|
boolean compare(SkinSiteProfile ssp0,SkinSiteProfile ssp1);
|
||||||
public String getName();
|
String getName();
|
||||||
public void initLocalFolder(SkinSiteProfile ssp);
|
void initLocalFolder(SkinSiteProfile ssp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,7 @@ public class CustomSkinAPI implements IJsonAPI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toJsonUrl(String root, String username) {
|
public String toJsonUrl(String root, String username) {
|
||||||
return new StringBuilder().append(root).append(username).append(SUFFIX).toString();
|
return root + username + SUFFIX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -22,14 +22,14 @@ public class CustomSkinAPIPlus implements IJsonAPI {
|
|||||||
|
|
||||||
if(clientIDFile.isFile())
|
if(clientIDFile.isFile())
|
||||||
try{
|
try{
|
||||||
clientID=FileUtils.readFileToString(clientIDFile);
|
clientID=FileUtils.readFileToString(clientIDFile, "UTF-8");
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if(clientID==null){
|
if(clientID==null){
|
||||||
clientID=UUID.randomUUID().toString();
|
clientID=UUID.randomUUID().toString();
|
||||||
try {
|
try {
|
||||||
FileUtils.write(clientIDFile, clientID);
|
FileUtils.write(clientIDFile, clientID, "UTF-8");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package customskinloader.loader.jsonapi;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
|
import customskinloader.config.SkinSiteProfile;
|
||||||
|
import customskinloader.loader.JsonAPILoader;
|
||||||
|
import customskinloader.profile.ModelManager0;
|
||||||
|
import customskinloader.profile.UserProfile;
|
||||||
|
import customskinloader.utils.MinecraftUtil;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ElyByAPI implements JsonAPILoader.IJsonAPI {
|
||||||
|
@Override
|
||||||
|
public String toJsonUrl(String root, String username) {
|
||||||
|
return "http://skinsystem.ely.by/textures/" + username + "?version=2&minecraft_version=" + MinecraftUtil.getMinecraftMainVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserProfile toUserProfile(String root, String json, boolean local) {
|
||||||
|
Map<Type, MinecraftProfileTexture> result = new Gson().fromJson(json, new TypeToken<Map<Type, MinecraftProfileTexture>>() {
|
||||||
|
}.getType());
|
||||||
|
if (!result.containsKey(Type.SKIN))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
//Check URL
|
||||||
|
try {
|
||||||
|
URI uri = new URI(result.get(Type.SKIN).getUrl());
|
||||||
|
if (!uri.getHost().endsWith("ely.by"))
|
||||||
|
return null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ModelManager0.toUserProfile(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPayload(SkinSiteProfile ssp) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "ElyByAPI";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,7 +19,7 @@ public class UniSkinAPI implements IJsonAPI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toJsonUrl(String root, String username) {
|
public String toJsonUrl(String root, String username) {
|
||||||
return new StringBuilder().append(root).append(username).append(SUFFIX).toString();
|
return root + username + SUFFIX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
package customskinloader.profile;
|
package customskinloader.profile;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import org.apache.commons.codec.Charsets;
|
import org.apache.commons.codec.Charsets;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
@@ -46,33 +43,34 @@ public class DynamicSkullManager {
|
|||||||
private List<GameProfile> loadingList=new ArrayList<GameProfile>();
|
private List<GameProfile> loadingList=new ArrayList<GameProfile>();
|
||||||
|
|
||||||
private void parseGameProfile(GameProfile profile){
|
private void parseGameProfile(GameProfile profile){
|
||||||
Property textureProperty=(Property)Iterables.getFirst(profile.getProperties().get("textures"), null);
|
Property textureProperty = Iterables.getFirst(profile.getProperties().get("textures"), null);
|
||||||
if (textureProperty==null){
|
if (textureProperty==null){
|
||||||
staticTextures.put(profile, new HashMap());
|
staticTextures.put(profile, Maps.<Type, MinecraftProfileTexture>newHashMap());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String value=textureProperty.getValue();
|
String value=textureProperty.getValue();
|
||||||
if(StringUtils.isBlank(value)){
|
if(StringUtils.isBlank(value)){
|
||||||
staticTextures.put(profile, new HashMap());
|
staticTextures.put(profile, Maps.<Type, MinecraftProfileTexture>newHashMap());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String json=new String(Base64.decodeBase64(value),Charsets.UTF_8);
|
@SuppressWarnings("deprecation") String json = new String(Base64.decodeBase64(value), Charsets.UTF_8);
|
||||||
Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class,new UUIDTypeAdapter()).create();
|
Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class,new UUIDTypeAdapter()).create();
|
||||||
SkullTexture result=gson.fromJson(json,SkullTexture.class);
|
SkullTexture result=gson.fromJson(json,SkullTexture.class);
|
||||||
if(result==null){
|
if(result==null){
|
||||||
staticTextures.put(profile, new HashMap());
|
staticTextures.put(profile, Maps.<Type, MinecraftProfileTexture>newHashMap());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
staticTextures.put(profile, (result.textures==null||!result.textures.containsKey(Type.SKIN))?new HashMap():parseTextures(result.textures));
|
staticTextures.put(profile, (result.textures==null || !result.textures.containsKey(Type.SKIN)) ?
|
||||||
|
Maps.<Type, MinecraftProfileTexture>newHashMap() : parseTextures(result.textures));
|
||||||
|
|
||||||
if(StringUtils.isNotEmpty(result.index)){
|
if(StringUtils.isNotEmpty(result.index)){
|
||||||
File indexFile=new File(CustomSkinLoader.DATA_DIR,result.index);
|
File indexFile=new File(CustomSkinLoader.DATA_DIR,result.index);
|
||||||
try{
|
try{
|
||||||
String index=FileUtils.readFileToString(indexFile, Charsets.UTF_8);
|
String index=FileUtils.readFileToString(indexFile, "UTF-8");
|
||||||
if(StringUtils.isNotEmpty(index)){
|
if(StringUtils.isNotEmpty(index)){
|
||||||
ArrayList<String> skins=CustomSkinLoader.GSON.fromJson(index, ArrayList.class);
|
String[] skins = CustomSkinLoader.GSON.fromJson(index, String[].class);
|
||||||
if(skins!=null&&!skins.isEmpty())
|
if(skins != null && skins.length != 0)
|
||||||
result.skins=skins;
|
result.skins = Lists.newArrayList(skins);
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
CustomSkinLoader.logger.warning("Exception occurs while parsing index file: "+e.toString());
|
CustomSkinLoader.logger.warning("Exception occurs while parsing index file: "+e.toString());
|
||||||
@@ -96,7 +94,6 @@ public class DynamicSkullManager {
|
|||||||
}else{
|
}else{
|
||||||
//Could not find skin
|
//Could not find skin
|
||||||
result.skins.remove(i--);
|
result.skins.remove(i--);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//Online Skin
|
//Online Skin
|
||||||
@@ -104,7 +101,6 @@ public class DynamicSkullManager {
|
|||||||
if(!responce.success){
|
if(!responce.success){
|
||||||
//Could not load skin
|
//Could not load skin
|
||||||
result.skins.remove(i--);
|
result.skins.remove(i--);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,7 +126,7 @@ public class DynamicSkullManager {
|
|||||||
return textures;
|
return textures;
|
||||||
File skinFile=new File(CustomSkinLoader.DATA_DIR,skinUrl);
|
File skinFile=new File(CustomSkinLoader.DATA_DIR,skinUrl);
|
||||||
if(!skinFile.isFile())
|
if(!skinFile.isFile())
|
||||||
return new HashMap();
|
return Maps.newHashMap();
|
||||||
textures.put(Type.SKIN, ModelManager0.getProfileTexture(HttpTextureUtil.getLocalFakeUrl(skinUrl), null));
|
textures.put(Type.SKIN, ModelManager0.getProfileTexture(HttpTextureUtil.getLocalFakeUrl(skinUrl), null));
|
||||||
return textures;
|
return textures;
|
||||||
}
|
}
|
||||||
@@ -139,7 +135,7 @@ public class DynamicSkullManager {
|
|||||||
if(staticTextures.get(profile)!=null)
|
if(staticTextures.get(profile)!=null)
|
||||||
return staticTextures.get(profile);
|
return staticTextures.get(profile);
|
||||||
if(loadingList.contains(profile))
|
if(loadingList.contains(profile))
|
||||||
return new HashMap();
|
return Maps.newHashMap();
|
||||||
if(dynamicTextures.containsKey(profile)){
|
if(dynamicTextures.containsKey(profile)){
|
||||||
SkullTexture texture=dynamicTextures.get(profile);
|
SkullTexture texture=dynamicTextures.get(profile);
|
||||||
long time=System.currentTimeMillis()-texture.startTime;
|
long time=System.currentTimeMillis()-texture.startTime;
|
||||||
@@ -158,6 +154,6 @@ public class DynamicSkullManager {
|
|||||||
};
|
};
|
||||||
loadThread.setName("Skull "+profile.hashCode());
|
loadThread.setName("Skull "+profile.hashCode());
|
||||||
loadThread.start();
|
loadThread.start();
|
||||||
return new HashMap();
|
return Maps.newHashMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@ import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
|||||||
* @since 13.1
|
* @since 13.1
|
||||||
*/
|
*/
|
||||||
public class ModelManager0 {
|
public class ModelManager0 {
|
||||||
public static enum Model{
|
public enum Model{
|
||||||
SKIN_DEFAULT,
|
SKIN_DEFAULT,
|
||||||
SKIN_SLIM,
|
SKIN_SLIM,
|
||||||
CAPE,
|
CAPE,
|
||||||
@@ -67,17 +67,17 @@ public class ModelManager0 {
|
|||||||
* @return profile - UserProfile instance
|
* @return profile - UserProfile instance
|
||||||
* @since 13.1
|
* @since 13.1
|
||||||
*/
|
*/
|
||||||
public static UserProfile toUserProfile(Map profile){
|
public static UserProfile toUserProfile(Map<Type, MinecraftProfileTexture> profile){
|
||||||
UserProfile userProfile=new UserProfile();
|
UserProfile userProfile=new UserProfile();
|
||||||
if(profile==null)
|
if(profile==null)
|
||||||
return userProfile;
|
return userProfile;
|
||||||
MinecraftProfileTexture skin=(MinecraftProfileTexture)profile.get(Type.SKIN);
|
MinecraftProfileTexture skin = profile.get(Type.SKIN);
|
||||||
userProfile.skinUrl= skin==null?null:skin.getUrl();//Avoid NullPointerException
|
userProfile.skinUrl= skin==null?null:skin.getUrl();//Avoid NullPointerException
|
||||||
userProfile.model= skin==null?null:skin.getMetadata("model");
|
userProfile.model= skin==null?null:skin.getMetadata("model");
|
||||||
if(StringUtils.isEmpty(userProfile.model))
|
if(StringUtils.isEmpty(userProfile.model))
|
||||||
userProfile.model="default";
|
userProfile.model="default";
|
||||||
|
|
||||||
MinecraftProfileTexture cape=(MinecraftProfileTexture)profile.get(Type.CAPE);
|
MinecraftProfileTexture cape = profile.get(Type.CAPE);
|
||||||
userProfile.capeUrl= cape==null?null:cape.getUrl();
|
userProfile.capeUrl= cape==null?null:cape.getUrl();
|
||||||
return userProfile;
|
return userProfile;
|
||||||
}
|
}
|
||||||
@@ -88,15 +88,15 @@ public class ModelManager0 {
|
|||||||
* @return profile - hashMapProfile (HashMap<String,MinecraftProfileTexture>)
|
* @return profile - hashMapProfile (HashMap<String,MinecraftProfileTexture>)
|
||||||
* @since 13.1
|
* @since 13.1
|
||||||
*/
|
*/
|
||||||
public static Map fromUserProfile(UserProfile profile){
|
public static Map<Type, MinecraftProfileTexture> fromUserProfile(UserProfile profile){
|
||||||
Map map=Maps.newHashMap();
|
Map<Type, MinecraftProfileTexture> map=Maps.newHashMap();
|
||||||
if(profile==null)
|
if(profile==null)
|
||||||
return map;
|
return map;
|
||||||
if(profile.skinUrl!=null){
|
if(profile.skinUrl!=null){
|
||||||
Map metadata=null;
|
Map<String,String> metadata = null;
|
||||||
if(profile.model!=null&&profile.model.equals("slim")){
|
if("slim".equals(profile.model) || "auto".equals(profile.model)){
|
||||||
metadata = Maps.newHashMap();
|
metadata = Maps.newHashMap();
|
||||||
metadata.put("model", "slim");
|
metadata.put("model", profile.model);
|
||||||
}
|
}
|
||||||
map.put(Type.SKIN, getProfileTexture(profile.skinUrl,metadata));
|
map.put(Type.SKIN, getProfileTexture(profile.skinUrl,metadata));
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,7 @@ public class ModelManager0 {
|
|||||||
* @return MinecraftProfileTexture
|
* @return MinecraftProfileTexture
|
||||||
* @since 14.5
|
* @since 14.5
|
||||||
*/
|
*/
|
||||||
public static MinecraftProfileTexture getProfileTexture(String url,Map metadata){
|
public static MinecraftProfileTexture getProfileTexture(String url,Map<String,String> metadata){
|
||||||
return new MinecraftProfileTexture(url,metadata);
|
return new MinecraftProfileTexture(url,metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,9 @@
|
|||||||
package customskinloader.profile;
|
package customskinloader.profile;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
import customskinloader.CustomSkinLoader;
|
import customskinloader.CustomSkinLoader;
|
||||||
import customskinloader.utils.TimeUtil;
|
import customskinloader.utils.TimeUtil;
|
||||||
@@ -16,6 +14,7 @@ public class ProfileCache {
|
|||||||
private HashMap<String,CachedProfile> cachedProfiles=new HashMap<String,CachedProfile>();
|
private HashMap<String,CachedProfile> cachedProfiles=new HashMap<String,CachedProfile>();
|
||||||
private HashMap<String,UserProfile> localProfiles=new HashMap<String,UserProfile>();
|
private HashMap<String,UserProfile> localProfiles=new HashMap<String,UserProfile>();
|
||||||
|
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
public ProfileCache(){
|
public ProfileCache(){
|
||||||
if(!PROFILE_CACHE_DIR.exists())
|
if(!PROFILE_CACHE_DIR.exists())
|
||||||
PROFILE_CACHE_DIR.mkdir();
|
PROFILE_CACHE_DIR.mkdir();
|
||||||
@@ -26,11 +25,11 @@ public class ProfileCache {
|
|||||||
}
|
}
|
||||||
public boolean isReady(String username){
|
public boolean isReady(String username){
|
||||||
CachedProfile cp=cachedProfiles.get(username.toLowerCase());
|
CachedProfile cp=cachedProfiles.get(username.toLowerCase());
|
||||||
return cp==null?false:(cp.loading||cp.expiryTime>TimeUtil.getCurrentUnixTimestamp());
|
return cp != null && (cp.loading || cp.expiryTime > TimeUtil.getCurrentUnixTimestamp());
|
||||||
}
|
}
|
||||||
public boolean isExpired(String username){
|
public boolean isExpired(String username){
|
||||||
CachedProfile cp=cachedProfiles.get(username.toLowerCase());
|
CachedProfile cp=cachedProfiles.get(username.toLowerCase());
|
||||||
return cp==null?true:(cp.expiryTime<=TimeUtil.getCurrentUnixTimestamp());
|
return cp == null || (cp.expiryTime <= TimeUtil.getCurrentUnixTimestamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserProfile getProfile(String username){
|
public UserProfile getProfile(String username){
|
||||||
@@ -74,7 +73,7 @@ public class ProfileCache {
|
|||||||
localProfiles.put(username.toLowerCase(), null);
|
localProfiles.put(username.toLowerCase(), null);
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
String json=IOUtils.toString(new FileInputStream(localProfile));
|
String json = FileUtils.readFileToString(localProfile, "UTF-8");
|
||||||
UserProfile profile=CustomSkinLoader.GSON.fromJson(json, UserProfile.class);
|
UserProfile profile=CustomSkinLoader.GSON.fromJson(json, UserProfile.class);
|
||||||
localProfiles.put(username.toLowerCase(), profile);
|
localProfiles.put(username.toLowerCase(), profile);
|
||||||
CustomSkinLoader.logger.info("Successfully load LocalProfile.");
|
CustomSkinLoader.logger.info("Successfully load LocalProfile.");
|
||||||
@@ -85,14 +84,14 @@ public class ProfileCache {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
private void saveLocalProfile(String username,UserProfile profile){
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
|
private void saveLocalProfile(String username, UserProfile profile){
|
||||||
String json=CustomSkinLoader.GSON.toJson(profile);
|
String json=CustomSkinLoader.GSON.toJson(profile);
|
||||||
File localProfile=new File(PROFILE_CACHE_DIR,username+".json");
|
File localProfile=new File(PROFILE_CACHE_DIR,username+".json");
|
||||||
if(localProfile.exists())
|
if(localProfile.exists())
|
||||||
localProfile.delete();
|
localProfile.delete();
|
||||||
try {
|
try {
|
||||||
localProfile.createNewFile();
|
FileUtils.write(localProfile, json, "UTF-8");
|
||||||
IOUtils.write(json, new FileOutputStream(localProfile));
|
|
||||||
CustomSkinLoader.logger.info("Successfully save LocalProfile.");
|
CustomSkinLoader.logger.info("Successfully save LocalProfile.");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CustomSkinLoader.logger.info("Failed to save LocalProfile.("+e.toString()+")");
|
CustomSkinLoader.logger.info("Failed to save LocalProfile.("+e.toString()+")");
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ public class UserProfile {
|
|||||||
return;
|
return;
|
||||||
case ELYTRA:
|
case ELYTRA:
|
||||||
this.capeUrl=url;
|
this.capeUrl=url;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,8 +91,10 @@ public class UserProfile {
|
|||||||
public void mix(UserProfile profile){
|
public void mix(UserProfile profile){
|
||||||
if(profile==null)
|
if(profile==null)
|
||||||
return;
|
return;
|
||||||
if(StringUtils.isEmpty(this.skinUrl))
|
if(StringUtils.isEmpty(this.skinUrl)) {
|
||||||
this.skinUrl=profile.skinUrl;
|
this.skinUrl = profile.skinUrl;
|
||||||
|
this.model = profile.model;
|
||||||
|
}
|
||||||
if(StringUtils.isEmpty(this.capeUrl))
|
if(StringUtils.isEmpty(this.capeUrl))
|
||||||
this.capeUrl=profile.capeUrl;
|
this.capeUrl=profile.capeUrl;
|
||||||
if(StringUtils.isEmpty(this.elytraUrl))
|
if(StringUtils.isEmpty(this.elytraUrl))
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class HttpRequestUtil {
|
|||||||
if(request.cacheTime==0 && request.cacheFile.isFile())
|
if(request.cacheTime==0 && request.cacheFile.isFile())
|
||||||
return loadFromCache(request,new HttpResponce());
|
return loadFromCache(request,new HttpResponce());
|
||||||
if(cacheInfoFile!=null&&cacheInfoFile.isFile()){
|
if(cacheInfoFile!=null&&cacheInfoFile.isFile()){
|
||||||
String json=FileUtils.readFileToString(cacheInfoFile);
|
String json=FileUtils.readFileToString(cacheInfoFile, "UTF-8");
|
||||||
if(StringUtils.isNotEmpty(json))
|
if(StringUtils.isNotEmpty(json))
|
||||||
cacheInfo=CustomSkinLoader.GSON.fromJson(json, CacheInfo.class);
|
cacheInfo=CustomSkinLoader.GSON.fromJson(json, CacheInfo.class);
|
||||||
if(cacheInfo==null)
|
if(cacheInfo==null)
|
||||||
@@ -121,7 +121,7 @@ public class HttpRequestUtil {
|
|||||||
CustomSkinLoader.logger.info("Payload: "+request.payload);
|
CustomSkinLoader.logger.info("Payload: "+request.payload);
|
||||||
c.setDoOutput(true);
|
c.setDoOutput(true);
|
||||||
OutputStream os=c.getOutputStream();
|
OutputStream os=c.getOutputStream();
|
||||||
IOUtils.write(request.payload, os);
|
IOUtils.write(request.payload, os, "UTF-8");
|
||||||
IOUtils.closeQuietly(os);
|
IOUtils.closeQuietly(os);
|
||||||
}
|
}
|
||||||
c.connect();
|
c.connect();
|
||||||
@@ -154,13 +154,13 @@ public class HttpRequestUtil {
|
|||||||
cacheInfo.etag=c.getHeaderField("ETag");
|
cacheInfo.etag=c.getHeaderField("ETag");
|
||||||
cacheInfo.lastModified=c.getLastModified();
|
cacheInfo.lastModified=c.getLastModified();
|
||||||
cacheInfo.expire=getExpire(c,request.cacheTime);
|
cacheInfo.expire=getExpire(c,request.cacheTime);
|
||||||
FileUtils.write(cacheInfoFile, CustomSkinLoader.GSON.toJson(cacheInfo));
|
FileUtils.write(cacheInfoFile, CustomSkinLoader.GSON.toJson(cacheInfo), "UTF-8");
|
||||||
}
|
}
|
||||||
CustomSkinLoader.logger.debug("Saved to cache (Length: "+request.cacheFile.length()+" , Path: '"+request.cacheFile.getAbsolutePath()+"' , Expire: "+cacheInfo.expire+")");
|
CustomSkinLoader.logger.debug("Saved to cache (Length: "+request.cacheFile.length()+" , Path: '"+request.cacheFile.getAbsolutePath()+"' , Expire: "+cacheInfo.expire+")");
|
||||||
}
|
}
|
||||||
if(!request.loadContent)
|
if(!request.loadContent)
|
||||||
return responce;
|
return responce;
|
||||||
responce.content=new String(bytes,Charsets.UTF_8);
|
responce.content=new String(bytes, "UTF-8");
|
||||||
CustomSkinLoader.logger.debug("Content: "+responce.content);
|
CustomSkinLoader.logger.debug("Content: "+responce.content);
|
||||||
return responce;
|
return responce;
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ public class HttpRequestUtil {
|
|||||||
|
|
||||||
CustomSkinLoader.logger.info("Try to load from cache '"+request.cacheFile.getAbsolutePath()+"'.");
|
CustomSkinLoader.logger.info("Try to load from cache '"+request.cacheFile.getAbsolutePath()+"'.");
|
||||||
try {
|
try {
|
||||||
responce.content=FileUtils.readFileToString(request.cacheFile);
|
responce.content=FileUtils.readFileToString(request.cacheFile, "UTF-8");
|
||||||
CustomSkinLoader.logger.debug("Successfully load from cache");
|
CustomSkinLoader.logger.debug("Successfully load from cache");
|
||||||
CustomSkinLoader.logger.debug("Content: "+responce.content);
|
CustomSkinLoader.logger.debug("Content: "+responce.content);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -201,7 +201,7 @@ public class HttpRequestUtil {
|
|||||||
String cacheControl=connection.getHeaderField("Cache-Control");
|
String cacheControl=connection.getHeaderField("Cache-Control");
|
||||||
if(StringUtils.isNotEmpty(cacheControl)){
|
if(StringUtils.isNotEmpty(cacheControl)){
|
||||||
Matcher m=MAX_AGE_PATTERN.matcher(cacheControl);
|
Matcher m=MAX_AGE_PATTERN.matcher(cacheControl);
|
||||||
if(m!=null && m.matches())
|
if(m.matches())
|
||||||
return TimeUtil.getUnixTimestamp(Long.parseLong(m.group(m.groupCount())));
|
return TimeUtil.getUnixTimestamp(Long.parseLong(m.group(m.groupCount())));
|
||||||
}
|
}
|
||||||
long expires=connection.getExpiration();
|
long expires=connection.getExpiration();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public class HttpTextureUtil {
|
|||||||
LOCAL_MARK="(LOCAL)",
|
LOCAL_MARK="(LOCAL)",
|
||||||
LOCAL_LEGACY_MARK="(LOCAL_LEGACY)";
|
LOCAL_LEGACY_MARK="(LOCAL_LEGACY)";
|
||||||
public static File defaultCacheDir;
|
public static File defaultCacheDir;
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
public static void cleanCacheDir(){
|
public static void cleanCacheDir(){
|
||||||
if(defaultCacheDir!=null){
|
if(defaultCacheDir!=null){
|
||||||
defaultCacheDir.delete();
|
defaultCacheDir.delete();
|
||||||
@@ -54,8 +55,8 @@ public class HttpTextureUtil {
|
|||||||
if(fakeUrl.startsWith(LEGACY_MARK)){
|
if(fakeUrl.startsWith(LEGACY_MARK)){
|
||||||
fakeUrl=fakeUrl.replace(LEGACY_MARK, "");
|
fakeUrl=fakeUrl.replace(LEGACY_MARK, "");
|
||||||
info.url=fakeUrl;
|
info.url=fakeUrl;
|
||||||
info.hash=DigestUtils.sha1Hex(info.url);;
|
info.hash=DigestUtils.sha1Hex(info.url);
|
||||||
info.cacheFile=HttpTextureUtil.getCacheFile(info.hash);
|
info.cacheFile = HttpRequestUtil.getCacheFile(info.hash);
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
|
|
||||||
public class HttpUtil0 {
|
public class HttpUtil0 {
|
||||||
public static boolean isLocal(String url){
|
public static boolean isLocal(String url){
|
||||||
return url==null? false : !url.startsWith("http");
|
return url != null && !url.startsWith("http");
|
||||||
}
|
}
|
||||||
|
|
||||||
//From: http://blog.csdn.net/xiyushiyi/article/details/46685387
|
//From: http://blog.csdn.net/xiyushiyi/article/details/46685387
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package customskinloader.utils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
public class JavaUtil {
|
||||||
|
public static URL[] getClasspath() {
|
||||||
|
if (JavaUtil.class.getClassLoader() instanceof URLClassLoader) {
|
||||||
|
//Java 8-
|
||||||
|
//Use URLClassLoader Directly
|
||||||
|
URLClassLoader ucl = (URLClassLoader) JavaUtil.class.getClassLoader();
|
||||||
|
return ucl.getURLs();
|
||||||
|
} else {
|
||||||
|
//Java 9+
|
||||||
|
//It uses APPClassLoader instead of URLClassLoader
|
||||||
|
//Get Classpath from properties and parse it to URL array
|
||||||
|
String classpath = System.getProperty("java.class.path");
|
||||||
|
String[] elements = classpath.split(File.pathSeparator);
|
||||||
|
if (elements.length == 0)
|
||||||
|
return new URL[0];
|
||||||
|
LinkedList<URL> urls = new LinkedList<URL>();
|
||||||
|
for (String ele : elements) {
|
||||||
|
try {
|
||||||
|
urls.add(new URL(ele));
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (URL[]) urls.toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,6 @@ package customskinloader.utils;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@@ -85,8 +84,7 @@ public class MinecraftUtil {
|
|||||||
private final static Pattern MINECRAFT_CORE_FILE_PATTERN = Pattern.compile("^(.*?)/versions/([^\\/\\\\]*?)/([^\\/\\\\]*?).jar$");
|
private final static Pattern MINECRAFT_CORE_FILE_PATTERN = Pattern.compile("^(.*?)/versions/([^\\/\\\\]*?)/([^\\/\\\\]*?).jar$");
|
||||||
private static void testProbe(){
|
private static void testProbe(){
|
||||||
minecraftVersion.clear();
|
minecraftVersion.clear();
|
||||||
URLClassLoader ucl = (URLClassLoader)new MinecraftUtil().getClass().getClassLoader();
|
URL urls[] = JavaUtil.getClasspath();
|
||||||
URL urls[] = ucl.getURLs();
|
|
||||||
for(URL url:urls){
|
for(URL url:urls){
|
||||||
Matcher m = null;
|
Matcher m = null;
|
||||||
try{
|
try{
|
||||||
@@ -101,26 +99,26 @@ public class MinecraftUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCoreFile(URL url){
|
public static boolean isCoreFile(URL url){
|
||||||
Matcher m = null;
|
Matcher m;
|
||||||
try{
|
try{
|
||||||
m=MINECRAFT_CORE_FILE_PATTERN.matcher(URLDecoder.decode(url.getPath(),"UTF-8"));
|
m=MINECRAFT_CORE_FILE_PATTERN.matcher(URLDecoder.decode(url.getPath(),"UTF-8"));
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return m!=null && m.matches();
|
return m.matches();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static Pattern LIBRARY_FILE_PATTERN = Pattern.compile("^(.*?)/libraries/(.*?)/([^\\/\\\\]*?).jar$");
|
private final static Pattern LIBRARY_FILE_PATTERN = Pattern.compile("^(.*?)/libraries/(.*?)/([^\\/\\\\]*?).jar$");
|
||||||
public static boolean isLibraryFile(URL url){
|
public static boolean isLibraryFile(URL url){
|
||||||
Matcher m = null;
|
Matcher m;
|
||||||
try{
|
try{
|
||||||
m=LIBRARY_FILE_PATTERN.matcher(URLDecoder.decode(url.getPath(),"UTF-8"));
|
m=LIBRARY_FILE_PATTERN.matcher(URLDecoder.decode(url.getPath(),"UTF-8"));
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return m!=null && m.matches();
|
return m.matches();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCredential(GameProfile profile) {
|
public static String getCredential(GameProfile profile) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package customskinloader.utils;
|
|||||||
|
|
||||||
public class TimeUtil {
|
public class TimeUtil {
|
||||||
public static long getCurrentUnixTimestamp(){
|
public static long getCurrentUnixTimestamp(){
|
||||||
return System.currentTimeMillis()/1000l;
|
return System.currentTimeMillis() / 1000L;
|
||||||
}
|
}
|
||||||
public static long getUnixTimestamp(long offset){
|
public static long getUnixTimestamp(long offset){
|
||||||
return getCurrentUnixTimestamp()+offset;
|
return getCurrentUnixTimestamp()+offset;
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package net.minecraft.client.renderer.texture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empty stack for NativeImage
|
||||||
|
*/
|
||||||
|
public class NativeImage {
|
||||||
|
public NativeImage(int p_i48122_1_, int p_i48122_2_, boolean p_i48122_3_) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getWidth
|
||||||
|
*/
|
||||||
|
public int func_195702_a() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getHeight
|
||||||
|
*/
|
||||||
|
public int func_195714_b() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* copyImage image
|
||||||
|
*/
|
||||||
|
public void func_195703_a(NativeImage p_195703_1_) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fillAreaRGBA x0 y0 weight height rgba
|
||||||
|
*/
|
||||||
|
public void func_195715_a(int p_195715_1_, int p_195715_2_, int p_195715_3_, int p_195715_4_, int p_195715_5_) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* copyAreaRGBA x0 y0 dx dy weight height reversex reversey
|
||||||
|
*/
|
||||||
|
public void func_195699_a(int p_195699_1_, int p_195699_2_, int p_195699_3_, int p_195699_4_, int p_195699_5_, int p_195699_6_, boolean p_195699_7_, boolean p_195699_8_) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getPixelRGBA x y
|
||||||
|
*/
|
||||||
|
public int func_195709_a(int p_195709_1_, int p_195709_2_) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setPixelRGBA x y rgba
|
||||||
|
*/
|
||||||
|
public void func_195700_a(int p_195700_1_, int p_195700_2_, int p_195700_3_) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
}
|
||||||
|
}
|
||||||
+42
-61
@@ -1,11 +1,11 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
/*maven {
|
mavenCentral()
|
||||||
name = "fmm"
|
|
||||||
url = "http://forgemavenmirror.sinaapp.com/maven"
|
|
||||||
}*/
|
|
||||||
jcenter()
|
jcenter()
|
||||||
maven { url = "http://files.minecraftforge.net/maven" }
|
maven {
|
||||||
|
name = "forge"
|
||||||
|
url = "http://files.minecraftforge.net/maven"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||||
@@ -13,44 +13,49 @@ buildscript {
|
|||||||
}
|
}
|
||||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||||
|
|
||||||
ext.MINECRAFT_VERSION="1.12.2"
|
ext.MINECRAFT_VERSION = "1.12.2"
|
||||||
ext.FORGE_VERSION="14.23.2.2611"
|
ext.FORGE_VERSION = "14.23.3.2655"
|
||||||
ext.MAPPING_VERSION="snapshot_20180210"
|
ext.MAPPING_VERSION = "snapshot_20180505"
|
||||||
ext.MINECRAFT_FULL_VERSIONS="1.8,1.8.8,1.8.9,1.9,1.9.4,1.10,1.10.2,1.11,1.11.2,1.12,1.12.1,1.12.2"
|
ext.MINECRAFT_FULL_VERSIONS = "1.8,1.8.8,1.8.9,1.9,1.9.4,1.10,1.10.2,1.11,1.11.2,1.12,1.12.1,1.12.2"
|
||||||
|
|
||||||
ext.snapshot = !(rootProject.ext.config.snapshot==""||rootProject.ext.config.snapshot=="0"||rootProject.ext.config.snapshot==0)
|
ext.snapshot = !(rootProject.ext.config.snapshot == "" || rootProject.ext.config.snapshot == "0" || rootProject.ext.config.snapshot == 0)
|
||||||
|
|
||||||
archivesBaseName = "CustomSkinLoader_Forge"
|
archivesBaseName = "CustomSkinLoader_Forge"
|
||||||
version = rootProject.ext.config.version + rootProject.ext.config.dev_version + (snapshot?"-SNAPSHOT-"+System.getenv("CIRCLE_BUILD_NUM"):"")
|
version = rootProject.ext.config.version + rootProject.ext.config.dev_version + (snapshot ? "-SNAPSHOT-" + System.getenv("CIRCLE_BUILD_NUM") : "")
|
||||||
group = "customskinloader"
|
group = "customskinloader"
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = "1.6"
|
sourceCompatibility = targetCompatibility = 1.6
|
||||||
compileJava {
|
compileJava {
|
||||||
sourceCompatibility = targetCompatibility = "1.6"
|
sourceCompatibility = targetCompatibility = 1.6
|
||||||
}
|
}
|
||||||
jar {
|
jar {
|
||||||
manifest {
|
manifest {
|
||||||
attributes 'FMLCorePlugin': 'customskinloader.forge.ForgePlugin'
|
attributes 'FMLCorePlugin': 'customskinloader.forge.ForgePlugin'
|
||||||
attributes 'FMLCorePluginContainsFMLMod': true
|
attributes 'FMLCorePluginContainsFMLMod': true
|
||||||
}
|
}
|
||||||
|
exclude 'net/minecraft/client/renderer/texture/NativeImage.class'
|
||||||
}
|
}
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
java {
|
java {
|
||||||
srcDir 'MergedSource'//Merge source
|
//Common
|
||||||
|
srcDir '../Common/source'
|
||||||
|
//Forge
|
||||||
|
srcDir 'source'
|
||||||
}
|
}
|
||||||
resources {
|
resources {
|
||||||
srcDir 'MergedResource'
|
//Common
|
||||||
|
srcDir '../Common/resource'
|
||||||
|
//Forge
|
||||||
|
srcDir 'resource'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
version = MINECRAFT_VERSION+"-"+FORGE_VERSION
|
version = MINECRAFT_VERSION + "-" + FORGE_VERSION
|
||||||
runDir = "run"
|
runDir = "run"
|
||||||
|
|
||||||
mappings = MAPPING_VERSION
|
mappings = MAPPING_VERSION
|
||||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
|
||||||
|
|
||||||
replace '@MOD_VERSION@', rootProject.ext.config.version
|
replace '@MOD_VERSION@', rootProject.ext.config.version
|
||||||
replace '@MOD_FULL_VERSION@', project.version
|
replace '@MOD_FULL_VERSION@', project.version
|
||||||
@@ -58,51 +63,27 @@ minecraft {
|
|||||||
replaceIn 'ForgeMod.java'
|
replaceIn 'ForgeMod.java'
|
||||||
}
|
}
|
||||||
|
|
||||||
task mergeSource { doLast {
|
processResources {
|
||||||
copy {
|
expand([
|
||||||
from '../Common/source'
|
modVersion : rootProject.ext.config.version,
|
||||||
exclude '**/tweaker/**'
|
modFullVersion: project.version,
|
||||||
from 'source'
|
mcVersion : MINECRAFT_VERSION,
|
||||||
into 'MergedSource'
|
mcFullVersions: MINECRAFT_FULL_VERSIONS,
|
||||||
}
|
forgeVersion : FORGE_VERSION,
|
||||||
}}
|
gitVersion : System.getenv("CIRCLE_SHA1"),
|
||||||
sourceMainJava.dependsOn mergeSource
|
buildUrl : System.getenv("CIRCLE_BUILD_URL")
|
||||||
|
|
||||||
task mergeResources { doLast {
|
|
||||||
copy {
|
|
||||||
from '../Common/resource'
|
|
||||||
from 'resource'
|
|
||||||
into 'MergedResource'
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
processResources.dependsOn mergeResources
|
|
||||||
|
|
||||||
processResources
|
|
||||||
{
|
|
||||||
expand ([
|
|
||||||
modVersion :rootProject.ext.config.version,
|
|
||||||
modFullVersion :project.version,
|
|
||||||
mcVersion :MINECRAFT_VERSION,
|
|
||||||
mcFullVersions :MINECRAFT_FULL_VERSIONS,
|
|
||||||
forgeVersion :FORGE_VERSION,
|
|
||||||
gitVersion :System.getenv("CIRCLE_SHA1"),
|
|
||||||
buildUrl :System.getenv("CIRCLE_BUILD_URL")
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
task afterBuild { doLast {
|
task afterBuild {
|
||||||
//Clean Up
|
doLast {
|
||||||
def sourceDir = file("MergedSource")
|
//copyBuildFile
|
||||||
sourceDir.deleteDir()
|
copy {
|
||||||
def resourceDir = file("MergedResource")
|
from 'build/libs'
|
||||||
resourceDir.deleteDir()
|
into '../build/libs'
|
||||||
|
include '**/*.jar'
|
||||||
//copyBuildFile
|
exclude '**/*-sources.jar'
|
||||||
copy {
|
}
|
||||||
from 'build/libs'
|
|
||||||
into '../build/libs'
|
|
||||||
include '**/*.jar'
|
|
||||||
exclude '**/*-sources.jar'
|
|
||||||
}
|
}
|
||||||
}}
|
}
|
||||||
build.finalizedBy afterBuild
|
build.finalizedBy afterBuild
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"modid": "customskinloader",
|
"modid": "customskinloader",
|
||||||
"name": "CustomSkinLoader",
|
"name": "CustomSkinLoader",
|
||||||
"description": "Custom Skin Loader for Minecraft",
|
"description": "Custom Skin Loader for Minecraft",
|
||||||
"version": "${modFullVersion}",
|
"version": "${modFullVersion}",
|
||||||
"url": "https://github.com/xfl03/MCCustomSkinLoader",
|
"url": "https://github.com/xfl03/MCCustomSkinLoader",
|
||||||
"authorList": ["xfl03"],
|
"authorList": ["xfl03", "JLChnToZ"],
|
||||||
"credits": "GPLv3"
|
"credits": "GPLv3"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -9,6 +9,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import customskinloader.Logger;
|
||||||
import org.objectweb.asm.ClassReader;
|
import org.objectweb.asm.ClassReader;
|
||||||
import org.objectweb.asm.ClassWriter;
|
import org.objectweb.asm.ClassWriter;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
@@ -16,21 +17,21 @@ import org.objectweb.asm.tree.MethodNode;
|
|||||||
|
|
||||||
import net.minecraft.launchwrapper.IClassTransformer;
|
import net.minecraft.launchwrapper.IClassTransformer;
|
||||||
import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
|
import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
|
||||||
import net.minecraftforge.fml.relauncher.FMLRelaunchLog;
|
import customskinloader.forge.transformer.PlayerTabTransformer.ScoreObjectiveTransformer;
|
||||||
import customskinloader.forge.PlayerTabTransformer.ScoreObjectiveTransformer;
|
import customskinloader.forge.transformer.SkinManagerTransformer.*;
|
||||||
import customskinloader.forge.SkinManagerTransformer.*;
|
import customskinloader.forge.transformer.SpectatorMenuTransformer.PlayerMenuObjectTransformer;
|
||||||
import customskinloader.forge.SpectatorMenuTransformer.PlayerMenuObjectTransformer;
|
|
||||||
|
|
||||||
public class TransformerManager implements IClassTransformer {
|
public class TransformerManager implements IClassTransformer {
|
||||||
|
public static Logger logger = new Logger("CustomSkinLoader/ForgePlugin.log");
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
public @interface TransformTarget{
|
public @interface TransformTarget{
|
||||||
public String className();
|
String className();
|
||||||
public String[] methodNames();
|
String[] methodNames();
|
||||||
public String desc();
|
String desc();
|
||||||
}
|
}
|
||||||
public interface IMethodTransformer{
|
public interface IMethodTransformer{
|
||||||
public void transform(ClassNode cn,MethodNode mn);
|
void transform(ClassNode cn,MethodNode mn);
|
||||||
}
|
}
|
||||||
private static final IMethodTransformer[] TRANFORMERS={
|
private static final IMethodTransformer[] TRANFORMERS={
|
||||||
new InitTransformer(),
|
new InitTransformer(),
|
||||||
@@ -43,9 +44,9 @@ public class TransformerManager implements IClassTransformer {
|
|||||||
public TransformerManager(){
|
public TransformerManager(){
|
||||||
map = new HashMap<String, Map<String, IMethodTransformer>>();
|
map = new HashMap<String, Map<String, IMethodTransformer>>();
|
||||||
for(IMethodTransformer t:TRANFORMERS){
|
for(IMethodTransformer t:TRANFORMERS){
|
||||||
FMLRelaunchLog.info("[CSL DEBUG] REGISTERING TRANSFORMER %s",t.getClass().getName());
|
logger.info("[CSL DEBUG] REGISTERING TRANSFORMER %s" , t.getClass().getName());
|
||||||
if(!t.getClass().isAnnotationPresent(TransformTarget.class)){
|
if(!t.getClass().isAnnotationPresent(TransformTarget.class)){
|
||||||
FMLRelaunchLog.info("[CSL DEBUG] ERROR occurs while parsing Annotation.");
|
logger.info("[CSL DEBUG] ERROR occurs while parsing Annotation.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
addMethodTransformer(t.getClass().getAnnotation(TransformTarget.class),t);
|
addMethodTransformer(t.getClass().getAnnotation(TransformTarget.class),t);
|
||||||
@@ -56,7 +57,7 @@ public class TransformerManager implements IClassTransformer {
|
|||||||
map.put(target.className(), new HashMap<String, IMethodTransformer>());
|
map.put(target.className(), new HashMap<String, IMethodTransformer>());
|
||||||
for(String methodName:target.methodNames()){
|
for(String methodName:target.methodNames()){
|
||||||
map.get(target.className()).put(methodName + target.desc(), transformer);
|
map.get(target.className()).put(methodName + target.desc(), transformer);
|
||||||
FMLRelaunchLog.info("[CSL DEBUG] REGISTERING METHOD %s(%s)",target.className(),methodName + target.desc());
|
logger.info("[CSL DEBUG] REGISTERING METHOD %s(%s)",target.className(),methodName + target.desc());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +65,7 @@ public class TransformerManager implements IClassTransformer {
|
|||||||
@Override
|
@Override
|
||||||
public byte[] transform(String obfClassName, String className, byte[] bytes) {
|
public byte[] transform(String obfClassName, String className, byte[] bytes) {
|
||||||
if (!map.containsKey(className)) return bytes;
|
if (!map.containsKey(className)) return bytes;
|
||||||
FMLRelaunchLog.info("[CSL DEBUG] CLASS %s will be transformed", className);
|
logger.info("[CSL DEBUG] CLASS %s will be transformed", className);
|
||||||
Map<String, IMethodTransformer> transMap = map.get(className);
|
Map<String, IMethodTransformer> transMap = map.get(className);
|
||||||
|
|
||||||
ClassReader cr = new ClassReader(bytes);
|
ClassReader cr = new ClassReader(bytes);
|
||||||
@@ -72,18 +73,17 @@ public class TransformerManager implements IClassTransformer {
|
|||||||
cr.accept(cn, 0);
|
cr.accept(cn, 0);
|
||||||
|
|
||||||
// NOTE: `map` = convert obfuscated name to srgName;
|
// NOTE: `map` = convert obfuscated name to srgName;
|
||||||
List<MethodNode> ml = new ArrayList<MethodNode>();
|
List<MethodNode> ml = new ArrayList<MethodNode>(cn.methods);
|
||||||
ml.addAll(cn.methods);
|
|
||||||
for (MethodNode mn : ml) {
|
for (MethodNode mn : ml) {
|
||||||
String methodName = FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(obfClassName, mn.name, mn.desc);
|
String methodName = FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(obfClassName, mn.name, mn.desc);
|
||||||
String methodDesc = FMLDeobfuscatingRemapper.INSTANCE.mapMethodDesc(mn.desc);
|
String methodDesc = FMLDeobfuscatingRemapper.INSTANCE.mapMethodDesc(mn.desc);
|
||||||
if (transMap.containsKey(methodName + methodDesc)) {
|
if (transMap.containsKey(methodName + methodDesc)) {
|
||||||
try {
|
try {
|
||||||
FMLRelaunchLog.info("[CSL DEBUG] Transforming method %s in class %s(%s)", methodName + methodDesc, obfClassName, className);
|
logger.info("[CSL DEBUG] Transforming method %s in class %s(%s)", methodName + methodDesc, obfClassName, className);
|
||||||
transMap.get(methodName + methodDesc).transform(cn,mn);
|
transMap.get(methodName + methodDesc).transform(cn,mn);
|
||||||
FMLRelaunchLog.info("[CSL DEBUG] Successfully transformed method %s in class %s(%s)", methodName + methodDesc, obfClassName, className);
|
logger.info("[CSL DEBUG] Successfully transformed method %s in class %s(%s)", methodName + methodDesc, obfClassName, className);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FMLRelaunchLog.warning("[CSL DEBUG] An error happened when transforming method %s in class %s(%s). The whole class was not modified.", methodName + methodDesc, obfClassName, className);
|
logger.warning("[CSL DEBUG] An error happened when transforming method %s in class %s(%s). The whole class was not modified.", methodName + methodDesc, obfClassName, className);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package customskinloader.forge;
|
package customskinloader.forge.transformer;
|
||||||
|
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package customskinloader.forge;
|
package customskinloader.forge.transformer;
|
||||||
|
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
+6
-3
@@ -1,4 +1,4 @@
|
|||||||
package customskinloader.forge;
|
package customskinloader.forge.transformer;
|
||||||
|
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
@@ -28,8 +28,11 @@ public class SpectatorMenuTransformer {
|
|||||||
AbstractInsnNode ain=li.next();
|
AbstractInsnNode ain=li.next();
|
||||||
if(ain.getOpcode()!=Opcodes.INVOKESTATIC)
|
if(ain.getOpcode()!=Opcodes.INVOKESTATIC)
|
||||||
continue;
|
continue;
|
||||||
//MethodInsnNode min=(MethodInsnNode)nn;
|
|
||||||
//min.owner="customskinloader/fake/FakeClientPlayer";
|
MethodInsnNode min = (MethodInsnNode)ain;
|
||||||
|
if(min.owner.equals("net/minecraft/client/entity/AbstractClientPlayer"))//Fix 1.13
|
||||||
|
continue;
|
||||||
|
|
||||||
if(!flag) {
|
if(!flag) {
|
||||||
//First InvokeStatic
|
//First InvokeStatic
|
||||||
il.set(ain, new MethodInsnNode(Opcodes.INVOKESTATIC,"customskinloader/fake/FakeClientPlayer","getLocationSkin",
|
il.set(ain, new MethodInsnNode(Opcodes.INVOKESTATIC,"customskinloader/fake/FakeClientPlayer","getLocationSkin",
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# CustomSkinLoader
|
# CustomSkinLoader
|
||||||
## What's this?
|
## What's this?
|
||||||
Custom Skin Loader mod for Minecraft.
|
Custom Skin Loader mod for Minecraft.
|
||||||
You can use it to load any skin from any website.
|
It's a mod which can load skin from any online source or local source.
|
||||||
|
|
||||||
## Download
|
## Download
|
||||||
Build Server : [CircleCI](https://circleci.com/gh/xfl03/MCCustomSkinLoader) & [~~Infinity Studio CI~~](https://ci.infstudio.net/job/CustomSkinLoader/)
|
Build Server : [CircleCI](https://circleci.com/gh/xfl03/MCCustomSkinLoader) & [~~Infinity Studio CI~~](https://ci.infstudio.net/job/CustomSkinLoader/)
|
||||||
@@ -14,6 +14,7 @@ Skin Load API Supported:
|
|||||||
- [CustomSkinAPI](https://github.com/xfl03/CustomSkinLoaderAPI/tree/master/CustomSkinAPI)
|
- [CustomSkinAPI](https://github.com/xfl03/CustomSkinLoaderAPI/tree/master/CustomSkinAPI)
|
||||||
- CustomSkinAPIPlus (Test Only)
|
- CustomSkinAPIPlus (Test Only)
|
||||||
- [UniSkinAPI](https://github.com/RecursiveG/UniSkinServer/tree/master/doc)
|
- [UniSkinAPI](https://github.com/RecursiveG/UniSkinServer/tree/master/doc)
|
||||||
|
- [ElfByAPI](http://docs.ely.by/api.html)
|
||||||
- Legacy
|
- Legacy
|
||||||
|
|
||||||
You can use this feature to customize your skin load list so as to load from any skin server you want.
|
You can use this feature to customize your skin load list so as to load from any skin server you want.
|
||||||
@@ -48,8 +49,9 @@ The problem of rendering incorrect texture has been fixed.
|
|||||||
|
|
||||||
## Default Load List
|
## Default Load List
|
||||||
- [Mojang](http://www.minecraft.net/) (Mojang API)
|
- [Mojang](http://www.minecraft.net/) (Mojang API)
|
||||||
- [Little Skin](https://mcskin.littleservice.cn/) (CustomSkinAPI)
|
- [LittleSkin](https://littleskin.cn/) (CustomSkinAPI)
|
||||||
- [Blessing Skin](http://skin.prinzeugen.net/) (CustomSkinAPI)
|
- [Blessing Skin](http://skin.prinzeugen.net/) (CustomSkinAPI)
|
||||||
|
- [ElyBy](http://docs.ely.by/) (ElyByAPI)
|
||||||
- SkinMe (UniSkinAPI)
|
- SkinMe (UniSkinAPI)
|
||||||
- LocalSkin (Legacy)
|
- LocalSkin (Legacy)
|
||||||
If you want to apply to add other skin server to default list, please go to [issue](https://github.com/JLChnToZ/MCCustomSkinLoader/issues).
|
If you want to apply to add other skin server to default list, please go to [issue](https://github.com/JLChnToZ/MCCustomSkinLoader/issues).
|
||||||
|
|||||||
+6
-7
@@ -4,12 +4,12 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
|
import customskinloader.utils.JavaUtil;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
import customskinloader.utils.MinecraftUtil;
|
import customskinloader.utils.MinecraftUtil;
|
||||||
@@ -23,8 +23,7 @@ public class ClassTransformer implements IClassTransformer {
|
|||||||
public ClassTransformer() {
|
public ClassTransformer() {
|
||||||
ModSystemTweaker.logger.info("ClassTransformer Begin");
|
ModSystemTweaker.logger.info("ClassTransformer Begin");
|
||||||
try {
|
try {
|
||||||
URLClassLoader ucl = (URLClassLoader)this.getClass().getClassLoader();
|
URL urls[] = JavaUtil.getClasspath();
|
||||||
URL urls[] = ucl.getURLs();
|
|
||||||
for (URL url : urls) {
|
for (URL url : urls) {
|
||||||
if(MinecraftUtil.isCoreFile(url)){
|
if(MinecraftUtil.isCoreFile(url)){
|
||||||
ModSystemTweaker.logger.debug(url.toString()+" : SKIP (core file).");
|
ModSystemTweaker.logger.debug(url.toString()+" : SKIP (core file).");
|
||||||
@@ -35,7 +34,7 @@ public class ClassTransformer implements IClassTransformer {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
File file = new File(url.toURI());
|
File file = new File(url.toURI());
|
||||||
if(file==null||!file.isFile()){
|
if(!file.isFile()){
|
||||||
ModSystemTweaker.logger.info(url.toString()+" : EXCEPTION (file not found).");
|
ModSystemTweaker.logger.info(url.toString()+" : EXCEPTION (file not found).");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -75,7 +74,7 @@ public class ClassTransformer implements IClassTransformer {
|
|||||||
|
|
||||||
private static ZipFile getZipFile(File file)
|
private static ZipFile getZipFile(File file)
|
||||||
{
|
{
|
||||||
ZipFile zipFile0=null;
|
ZipFile zipFile0;
|
||||||
try {
|
try {
|
||||||
zipFile0 = new ZipFile(file);
|
zipFile0 = new ZipFile(file);
|
||||||
return zipFile0;
|
return zipFile0;
|
||||||
@@ -89,11 +88,11 @@ public class ClassTransformer implements IClassTransformer {
|
|||||||
if (zipFile == null)
|
if (zipFile == null)
|
||||||
return bytes;
|
return bytes;
|
||||||
|
|
||||||
String fullName = new StringBuilder().append(name.startsWith("net") ? name.replaceAll("\\.", "\\/") : name).append(".class").toString();//Notch(Run)/MCP(Dev) Class Name
|
String fullName = (name.startsWith("net") ? name.replace('.', '/') : name) + ".class";//Notch(Run)/MCP(Dev) Class Name
|
||||||
if(!classes.contains(fullName)){//Check Name
|
if(!classes.contains(fullName)){//Check Name
|
||||||
if(name.equals(transformedName))
|
if(name.equals(transformedName))
|
||||||
return bytes;
|
return bytes;
|
||||||
fullName = new StringBuilder().append(transformedName.replaceAll("\\.", "\\/")).append(".class").toString();//MCP Class Name
|
fullName = transformedName.replace('.', '/') + ".class";//MCP Class Name
|
||||||
if(!classes.contains(fullName))//check Again
|
if(!classes.contains(fullName))//check Again
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-11
@@ -9,21 +9,12 @@ configFile.withReader {
|
|||||||
}
|
}
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
/*
|
mavenCentral()
|
||||||
maven {
|
|
||||||
name = "fmm"
|
|
||||||
url = "http://forgemavenmirror.sinaapp.com/maven"
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
jcenter()
|
jcenter()
|
||||||
maven {
|
maven {
|
||||||
name = "forge"
|
name = "forge"
|
||||||
url = "http://files.minecraftforge.net/maven"
|
url = "http://files.minecraftforge.net/maven"
|
||||||
}
|
}
|
||||||
maven {
|
|
||||||
name = "sonatype"
|
|
||||||
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||||
@@ -31,6 +22,6 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
if(!project.name.toLowerCase().contains("forge"))
|
if (!project.name.toLowerCase().contains("forge"))
|
||||||
apply from: rootProject.file('common.gradle')
|
apply from: rootProject.file('common.gradle')
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
name=CustomSkinLoader
|
name=CustomSkinLoader
|
||||||
group=customskinloader
|
group=customskinloader
|
||||||
version=14.8
|
version=14.9
|
||||||
dev_version=
|
dev_version=
|
||||||
#RELEASE: snapshot=0
|
#RELEASE: snapshot=0
|
||||||
snapshot=0
|
snapshot=0
|
||||||
+64
-60
@@ -1,20 +1,11 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
/*
|
mavenCentral()
|
||||||
maven {
|
|
||||||
name = "fmm"
|
|
||||||
url = "http://forgemavenmirror.sinaapp.com/maven"
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
jcenter()
|
jcenter()
|
||||||
maven {
|
maven {
|
||||||
name = "forge"
|
name = "forge"
|
||||||
url = "http://files.minecraftforge.net/maven"
|
url = "http://files.minecraftforge.net/maven"
|
||||||
}
|
}
|
||||||
maven {
|
|
||||||
name = "sonatype"
|
|
||||||
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||||
@@ -29,13 +20,20 @@ configFile.withReader {
|
|||||||
prop.load(it)
|
prop.load(it)
|
||||||
project.ext.config = new ConfigSlurper().parse prop
|
project.ext.config = new ConfigSlurper().parse prop
|
||||||
}
|
}
|
||||||
|
ext.release = (rootProject.ext.config.snapshot == "" || rootProject.ext.config.snapshot == "0" || rootProject.ext.config.snapshot == 0)
|
||||||
//Example: 14.4a-SNAPSHOT-20160820
|
//Example: 14.4a-SNAPSHOT-20160820
|
||||||
version = rootProject.ext.config.version + rootProject.ext.config.dev_version + ((rootProject.ext.config.snapshot==""||rootProject.ext.config.snapshot=="0"||rootProject.ext.config.snapshot==0)?'':('-SNAPSHOT-'+System.getenv("CIRCLE_BUILD_NUM")))
|
version = rootProject.ext.config.version + rootProject.ext.config.dev_version +
|
||||||
|
(ext.release ? '' : ('-SNAPSHOT-' + System.getenv("CIRCLE_BUILD_NUM")))
|
||||||
group = config.group
|
group = config.group
|
||||||
archivesBaseName = rootProject.ext.config.name+"_"+config.minecraft_version
|
archivesBaseName = rootProject.ext.config.name + "_" + config.minecraft_version
|
||||||
|
|
||||||
|
sourceCompatibility = targetCompatibility = 1.6
|
||||||
|
compileJava {
|
||||||
|
sourceCompatibility = targetCompatibility = 1.6
|
||||||
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
version = config.forge_mc_version+"-"+config.forge_version
|
version = config.forge_mc_version + "-" + config.forge_version
|
||||||
runDir = "run"
|
runDir = "run"
|
||||||
mappings = config.mappings_version
|
mappings = config.mappings_version
|
||||||
|
|
||||||
@@ -46,36 +44,39 @@ minecraft {
|
|||||||
|
|
||||||
jar {
|
jar {
|
||||||
manifest {
|
manifest {
|
||||||
attributes 'TweakClass' : 'customskinloader.tweaker.ModSystemTweaker'
|
attributes 'TweakClass' : 'customskinloader.tweaker.ModSystemTweaker'
|
||||||
attributes 'TweakName' : rootProject.ext.config.name
|
attributes 'TweakName' : rootProject.ext.config.name
|
||||||
attributes 'TweakAuthor' : 'xfl03,JLChnToZ'
|
attributes 'TweakAuthor' : 'xfl03,JLChnToZ'
|
||||||
attributes 'TweakVersion' : version
|
attributes 'TweakVersion': version
|
||||||
attributes 'TweakOrder' : '-10'
|
attributes 'TweakOrder' : '-10'
|
||||||
}
|
}
|
||||||
|
exclude 'net/minecraft/client/renderer/texture/NativeImage.class'
|
||||||
}
|
}
|
||||||
|
|
||||||
task copySource << {
|
sourceSets {
|
||||||
def outputFile = file("src/main/java")
|
main {
|
||||||
outputFile.deleteDir()
|
java {
|
||||||
copy {
|
//Common
|
||||||
from '../Common/source'
|
srcDir '../Common/source'
|
||||||
from 'src/minecraft/'
|
//Vanilla
|
||||||
into 'src/main/java'
|
srcDir '../Vanilla'
|
||||||
|
}
|
||||||
|
resources {
|
||||||
|
//Common
|
||||||
|
srcDir '../Common/resource'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sourceMainJava.dependsOn copySource
|
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
expand ([
|
expand([
|
||||||
modVersion:rootProject.ext.config.version,
|
modVersion : rootProject.ext.config.version,
|
||||||
modFullVersion:project.version,
|
modFullVersion: project.version,
|
||||||
mcVersion:config.minecraft_version,
|
mcVersion : config.minecraft_version,
|
||||||
mcFullVersions:config.minecraft_full_versions,
|
mcFullVersions: config.minecraft_full_versions,
|
||||||
forgeVersion:config.forge_version,
|
forgeVersion : config.forge_version,
|
||||||
//gitVersion:System.getenv("GIT_COMMIT"),
|
gitVersion : System.getenv("CIRCLE_SHA1"),
|
||||||
//buildUrl:System.getenv("BUILD_URL")
|
buildUrl : System.getenv("CIRCLE_BUILD_URL")
|
||||||
gitVersion:System.getenv("CIRCLE_SHA1"),
|
|
||||||
buildUrl:System.getenv("CIRCLE_BUILD_URL")
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
task copyResources << {
|
task copyResources << {
|
||||||
@@ -88,43 +89,45 @@ task copyResources << {
|
|||||||
}
|
}
|
||||||
processResources.dependsOn copyResources
|
processResources.dependsOn copyResources
|
||||||
|
|
||||||
task afterBuild << {
|
task afterBuild {
|
||||||
//renameSrgJar
|
doLast {
|
||||||
def file0 = file("build/libs/${archivesBaseName}-${version}.jar")
|
//renameSrgJar
|
||||||
def file1 = file("build/libs/${archivesBaseName}-${version}-srg.jar")
|
def file0 = file("build/libs/${archivesBaseName}-${version}.jar")
|
||||||
file0.renameTo(file1)
|
def file1 = file("build/libs/${archivesBaseName}-${version}-srg.jar")
|
||||||
|
file0.renameTo(file1)
|
||||||
|
|
||||||
//reobfSrgToNotch
|
//reobfSrgToNotch
|
||||||
reobfSrgToNotch()
|
reobfSrgToNotch()
|
||||||
|
|
||||||
//copyBuildFile
|
//copyBuildFile
|
||||||
copy {
|
copy {
|
||||||
from 'build/libs'
|
from 'build/libs'
|
||||||
into '../build/libs'
|
into '../build/libs'
|
||||||
include '**/*.jar'
|
include '**/*.jar'
|
||||||
exclude '**/*-srg.jar'
|
exclude '**/*-srg.jar'
|
||||||
exclude '**/*-dev.jar'
|
exclude '**/*-dev.jar'
|
||||||
exclude '**/*-sources.jar'
|
exclude '**/*-sources.jar'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
build.finalizedBy afterBuild
|
build.finalizedBy afterBuild
|
||||||
|
|
||||||
//notch pack
|
//notch pack
|
||||||
void reobfSrgToNotch(){
|
void reobfSrgToNotch() {
|
||||||
def srgName = "${archivesBaseName}-${version}-srg.jar"
|
def srgName = "${archivesBaseName}-${version}-srg.jar"
|
||||||
def notchName = srgName.replace('-srg', '')
|
def notchName = srgName.replace('-srg', '')
|
||||||
if(config.srg_notch_map==null||!(config.srg_notch_map instanceof String)||config.srg_notch_map==""){
|
if (config.srg_notch_map == null || !(config.srg_notch_map instanceof String) || config.srg_notch_map == "") {
|
||||||
//Default Map
|
//Default Map
|
||||||
def mcpName = srgName.replace('-srg', '-dev')
|
def mcpName = srgName.replace('-srg', '-dev')
|
||||||
applySpecialSource(srgName,mcpName,getDefaultMap("srg-mcp"))
|
applySpecialSource(srgName, mcpName, getDefaultMap("srg-mcp"))
|
||||||
applySpecialSource(mcpName,notchName,getDefaultMap("mcp-notch"))
|
applySpecialSource(mcpName, notchName, getDefaultMap("mcp-notch"))
|
||||||
}else{
|
} else {
|
||||||
//Custom Map
|
//Custom Map
|
||||||
applySpecialSource(srgName,notchName,config.srg_notch_map)
|
applySpecialSource(srgName, notchName, config.srg_notch_map)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void applySpecialSource(String inputName,String outputName,String mapFile){
|
void applySpecialSource(String inputName, String outputName, String mapFile) {
|
||||||
def mapping = new net.md_5.specialsource.JarMapping()
|
def mapping = new net.md_5.specialsource.JarMapping()
|
||||||
def srgFile = file(mapFile)
|
def srgFile = file(mapFile)
|
||||||
def inputFile = file("build/libs/${inputName}")
|
def inputFile = file("build/libs/${inputName}")
|
||||||
@@ -138,7 +141,8 @@ void applySpecialSource(String inputName,String outputName,String mapFile){
|
|||||||
mapping.setFallbackInheritanceProvider(inheritanceProviders)
|
mapping.setFallbackInheritanceProvider(inheritanceProviders)
|
||||||
remapper.remapJar(inputJar, outputFile)
|
remapper.remapJar(inputJar, outputFile)
|
||||||
}
|
}
|
||||||
String getDefaultMap(String srgType){
|
|
||||||
def mcpVersion = minecraft.mappings.replace('_',"/")
|
String getDefaultMap(String srgType) {
|
||||||
|
def mcpVersion = minecraft.mappings.replace('_', "/")
|
||||||
return System.getProperty('user.home') + "/.gradle/caches/minecraft/de/oceanlabs/mcp/mcp_${mcpVersion}/${config.forge_mc_version}/srgs/${srgType}.srg"
|
return System.getProperty('user.home') + "/.gradle/caches/minecraft/de/oceanlabs/mcp/mcp_${mcpVersion}/${config.forge_mc_version}/srgs/${srgType}.srg"
|
||||||
}
|
}
|
||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
include "1.12-mcp940"
|
//Special Vanilla Edition
|
||||||
include "1.12.1-test"
|
include "1.13"
|
||||||
|
|
||||||
//Universial Forge Version for [1.8,)
|
//Universal Forge Edition for [1.8,)
|
||||||
include "Forge"
|
include "Forge"
|
||||||
Reference in new issue
Block a user