mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-25 22:07:59 +01:00
Fix skin menu not showing ponies
This commit is contained in:
parent
4950ba2161
commit
192ed73809
4 changed files with 49 additions and 48 deletions
|
@ -27,8 +27,6 @@ import net.minecraft.util.ResourceLocation;
|
||||||
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;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -39,6 +37,8 @@ import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public final class HDSkinManager implements IResourceManagerReloadListener {
|
public final class HDSkinManager implements IResourceManagerReloadListener {
|
||||||
|
|
||||||
|
@ -201,13 +201,27 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PreviewTexture getPreviewTexture(ResourceLocation skinResource, GameProfile profile, Type type, ResourceLocation def) {
|
public static PreviewTexture getPreviewTexture(ResourceLocation skinResource, GameProfile profile, Type type, ResourceLocation def, @Nullable final SkinAvailableCallback callback) {
|
||||||
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
|
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
|
||||||
String url = INSTANCE.getCustomTextureURLForId(type, UUIDTypeAdapter.fromUUID(profile.getId()), true);
|
String url = INSTANCE.getCustomTextureURLForId(type, UUIDTypeAdapter.fromUUID(profile.getId()), true);
|
||||||
ITextureObject skinTexture = new PreviewTexture(url, def, type == Type.SKIN ? new ImageBufferDownloadHD() : null);
|
IImageBuffer buffer = new ImageBufferDownloadHD();
|
||||||
|
PreviewTexture skinTexture = new PreviewTexture(url, def, type == Type.SKIN ? new IImageBuffer() {
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public BufferedImage parseUserSkin(BufferedImage image) {
|
||||||
|
return buffer.parseUserSkin(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void skinAvailable() {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.skinAvailable(type, skinResource, new MinecraftProfileTexture(url, Maps.newHashMap()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} : null);
|
||||||
textureManager.loadTexture(skinResource, skinTexture);
|
textureManager.loadTexture(skinResource, skinTexture);
|
||||||
|
|
||||||
return (PreviewTexture) skinTexture;
|
return skinTexture;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,17 +12,18 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||||
|
import net.minecraft.client.resources.SkinManager;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumHandSide;
|
import net.minecraft.util.EnumHandSide;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
@SuppressWarnings("EntityConstructor")
|
@SuppressWarnings("EntityConstructor")
|
||||||
public class EntityPlayerModel extends EntityLivingBase {
|
public class EntityPlayerModel extends EntityLivingBase {
|
||||||
|
@ -64,7 +65,7 @@ public class EntityPlayerModel extends EntityLivingBase {
|
||||||
this.textureManager.deleteTexture(this.remoteElytraResource);
|
this.textureManager.deleteTexture(this.remoteElytraResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadRemoteSkin() {
|
public void reloadRemoteSkin(SkinManager.SkinAvailableCallback listener) {
|
||||||
this.remoteSkin = true;
|
this.remoteSkin = true;
|
||||||
if (this.remoteSkinTexture != null) {
|
if (this.remoteSkinTexture != null) {
|
||||||
this.textureManager.deleteTexture(this.remoteSkinResource);
|
this.textureManager.deleteTexture(this.remoteSkinResource);
|
||||||
|
@ -73,8 +74,8 @@ public class EntityPlayerModel extends EntityLivingBase {
|
||||||
this.textureManager.deleteTexture(this.remoteElytraResource);
|
this.textureManager.deleteTexture(this.remoteElytraResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.remoteSkinTexture = HDSkinManager.getPreviewTexture(this.remoteSkinResource, this.profile, Type.SKIN, NO_SKIN);
|
this.remoteSkinTexture = HDSkinManager.getPreviewTexture(this.remoteSkinResource, this.profile, Type.SKIN, NO_SKIN, listener);
|
||||||
this.remoteElytraTexture = HDSkinManager.getPreviewTexture(this.remoteElytraResource, this.profile, Type.ELYTRA, NO_ELYTRA);
|
this.remoteElytraTexture = HDSkinManager.getPreviewTexture(this.remoteElytraResource, this.profile, Type.ELYTRA, NO_ELYTRA, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,11 +129,6 @@ public class EntityPlayerModel extends EntityLivingBase {
|
||||||
return !this.remoteSkin && this.hasLocalTexture;
|
return !this.remoteSkin && this.hasLocalTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override TODO
|
|
||||||
public float getBrightness(float par1) {
|
|
||||||
return 1.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTextureSetupComplete() {
|
public boolean isTextureSetupComplete() {
|
||||||
return (this.remoteSkin && this.remoteSkinTexture != null) && this.remoteSkinTexture.isTextureUploaded();
|
return (this.remoteSkin && this.remoteSkinTexture != null) && this.remoteSkinTexture.isTextureUploaded();
|
||||||
}
|
}
|
||||||
|
@ -189,12 +185,6 @@ public class EntityPlayerModel extends EntityLivingBase {
|
||||||
return Minecraft.getMinecraft().gameSettings.mainHand;
|
return Minecraft.getMinecraft().gameSettings.mainHand;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override TODO
|
|
||||||
public int getBrightnessForRender(float partialTicks) {
|
|
||||||
return 0xf000f0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<ItemStack> getArmorInventoryList() {
|
public Iterable<ItemStack> getArmorInventoryList() {
|
||||||
return armors.values();
|
return armors.values();
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class GuiSkins extends GuiScreen {
|
||||||
protected EntityPlayerModel localPlayer;
|
protected EntityPlayerModel localPlayer;
|
||||||
protected EntityPlayerModel remotePlayer;
|
protected EntityPlayerModel remotePlayer;
|
||||||
|
|
||||||
protected DoubleBuffer doubleBuffer;
|
private DoubleBuffer doubleBuffer;
|
||||||
|
|
||||||
private String uploadError;
|
private String uploadError;
|
||||||
private volatile String skinMessage = I18n.format("hdskins.choose");
|
private volatile String skinMessage = I18n.format("hdskins.choose");
|
||||||
|
@ -87,7 +87,6 @@ public class GuiSkins extends GuiScreen {
|
||||||
private final Object skinLock = new Object();
|
private final Object skinLock = new Object();
|
||||||
private File pendingSkinFile;
|
private File pendingSkinFile;
|
||||||
private File selectedSkin;
|
private File selectedSkin;
|
||||||
private BufferedImage pendingSkinImage;
|
|
||||||
private float uploadOpacity = 0.0F;
|
private float uploadOpacity = 0.0F;
|
||||||
private float lastPartialTick;
|
private float lastPartialTick;
|
||||||
private JFrame fileDrop;
|
private JFrame fileDrop;
|
||||||
|
@ -128,8 +127,7 @@ public class GuiSkins extends GuiScreen {
|
||||||
this.localPlayer.setLocalTexture(this.pendingSkinFile, textureType);
|
this.localPlayer.setLocalTexture(this.pendingSkinFile, textureType);
|
||||||
this.selectedSkin = this.pendingSkinFile;
|
this.selectedSkin = this.pendingSkinFile;
|
||||||
this.pendingSkinFile = null;
|
this.pendingSkinFile = null;
|
||||||
this.onSetLocalSkin(this.pendingSkinImage, textureType);
|
this.onSetLocalSkin(textureType);
|
||||||
this.pendingSkinImage = null;
|
|
||||||
this.btnUpload.enabled = true;
|
this.btnUpload.enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +137,6 @@ public class GuiSkins extends GuiScreen {
|
||||||
this.fetchingSkin = true;
|
this.fetchingSkin = true;
|
||||||
this.btnClear.enabled = false;
|
this.btnClear.enabled = false;
|
||||||
this.reloadRemoteSkin();
|
this.reloadRemoteSkin();
|
||||||
this.onSetRemoteSkin(textureType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.throttledByMojang) {
|
if (this.throttledByMojang) {
|
||||||
|
@ -156,15 +153,15 @@ public class GuiSkins extends GuiScreen {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onSetRemoteSkin(MinecraftProfileTexture.Type type) {
|
protected void onSetRemoteSkin(MinecraftProfileTexture.Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onSetLocalSkin(BufferedImage skin, MinecraftProfileTexture.Type type) {
|
protected void onSetLocalSkin(MinecraftProfileTexture.Type type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reloadRemoteSkin() {
|
private void reloadRemoteSkin() {
|
||||||
try {
|
try {
|
||||||
this.remotePlayer.reloadRemoteSkin();
|
this.remotePlayer.reloadRemoteSkin(this::onSetRemoteSkin);
|
||||||
} catch (Exception var2) {
|
} catch (Exception var2) {
|
||||||
var2.printStackTrace();
|
var2.printStackTrace();
|
||||||
this.throttledByMojang = true;
|
this.throttledByMojang = true;
|
||||||
|
@ -192,9 +189,6 @@ public class GuiSkins extends GuiScreen {
|
||||||
(this.textureType == SKIN ? this.btnModeSkin : this.btnModeElytra).enabled = false;
|
(this.textureType == SKIN ? this.btnModeSkin : this.btnModeElytra).enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @wbp.parser.entryPoint
|
|
||||||
*/
|
|
||||||
private void enableDnd() {
|
private void enableDnd() {
|
||||||
if (fileDrop != null) {
|
if (fileDrop != null) {
|
||||||
fileDrop.setVisible(true);
|
fileDrop.setVisible(true);
|
||||||
|
@ -227,7 +221,7 @@ public class GuiSkins extends GuiScreen {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initPanoramaRenderer() {
|
private void initPanoramaRenderer() {
|
||||||
this.viewportTexture = this.mc.getTextureManager().getDynamicTextureLocation("skinpanorama", new DynamicTexture(256, 256));
|
this.viewportTexture = this.mc.getTextureManager().getDynamicTextureLocation("skinpanorama", new DynamicTexture(256, 256));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,7 +267,6 @@ public class GuiSkins extends GuiScreen {
|
||||||
&& chosenImage.getHeight() <= MAX_SKIN_DIMENSION) {
|
&& chosenImage.getHeight() <= MAX_SKIN_DIMENSION) {
|
||||||
synchronized (this.skinLock) {
|
synchronized (this.skinLock) {
|
||||||
this.pendingSkinFile = skinFile;
|
this.pendingSkinFile = skinFile;
|
||||||
this.pendingSkinImage = chosenImage;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.skinMessage = I18n.format("hdskins.error.invalid");
|
this.skinMessage = I18n.format("hdskins.error.invalid");
|
||||||
|
@ -362,7 +355,7 @@ public class GuiSkins extends GuiScreen {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupCubemapCamera() {
|
private void setupCubemapCamera() {
|
||||||
matrixMode(GL11.GL_PROJECTION);
|
matrixMode(GL11.GL_PROJECTION);
|
||||||
pushMatrix();
|
pushMatrix();
|
||||||
loadIdentity();
|
loadIdentity();
|
||||||
|
@ -372,7 +365,7 @@ public class GuiSkins extends GuiScreen {
|
||||||
loadIdentity();
|
loadIdentity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void revertPanoramaMatrix() {
|
private void revertPanoramaMatrix() {
|
||||||
matrixMode(GL11.GL_PROJECTION);
|
matrixMode(GL11.GL_PROJECTION);
|
||||||
popMatrix();
|
popMatrix();
|
||||||
matrixMode(GL11.GL_MODELVIEW);
|
matrixMode(GL11.GL_MODELVIEW);
|
||||||
|
@ -471,7 +464,7 @@ public class GuiSkins extends GuiScreen {
|
||||||
disableBlend();
|
disableBlend();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderPanorama(float partialTicks) {
|
private void renderPanorama(float partialTicks) {
|
||||||
viewport(0, 0, 256, 256);
|
viewport(0, 0, 256, 256);
|
||||||
this.renderCubeMapTexture(partialTicks);
|
this.renderCubeMapTexture(partialTicks);
|
||||||
disableTexture2D();
|
disableTexture2D();
|
||||||
|
@ -523,7 +516,7 @@ public class GuiSkins extends GuiScreen {
|
||||||
super.drawScreen(mouseX, mouseY, partialTick);
|
super.drawScreen(mouseX, mouseY, partialTick);
|
||||||
|
|
||||||
popAttrib();
|
popAttrib();
|
||||||
this.enableClipping(30, bottom);
|
this.enableClipping(bottom);
|
||||||
|
|
||||||
float yPos = this.height * 0.75F;
|
float yPos = this.height * 0.75F;
|
||||||
float xPos1 = this.width * 0.25F;
|
float xPos1 = this.width * 0.25F;
|
||||||
|
@ -613,13 +606,14 @@ public class GuiSkins extends GuiScreen {
|
||||||
Gui.drawRect(0, 0, this.width, this.height, 0xB0000000);
|
Gui.drawRect(0, 0, this.width, this.height, 0xB0000000);
|
||||||
this.drawCenteredString(this.fontRenderer, I18n.format("hdskins.failed"), this.width / 2, this.height / 2 - 10, 0xFFFFFF55);
|
this.drawCenteredString(this.fontRenderer, I18n.format("hdskins.failed"), this.width / 2, this.height / 2 - 10, 0xFFFFFF55);
|
||||||
this.drawCenteredString(this.fontRenderer, this.uploadError, this.width / 2, this.height / 2 + 2, 0xFFFF5555);
|
this.drawCenteredString(this.fontRenderer, this.uploadError, this.width / 2, this.height / 2 + 2, 0xFFFF5555);
|
||||||
|
LiteLoaderLogger.warning("Upload Failed: {}", this.uploadError);
|
||||||
}
|
}
|
||||||
|
|
||||||
depthMask(true);
|
depthMask(true);
|
||||||
enableDepth();
|
enableDepth();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderPlayerModel(EntityPlayerModel thePlayer, float xPosition, float yPosition, float scale, float mouseY, float partialTick) {
|
private void renderPlayerModel(EntityPlayerModel thePlayer, float xPosition, float yPosition, float scale, float mouseY, float partialTick) {
|
||||||
enableColorMaterial();
|
enableColorMaterial();
|
||||||
pushMatrix();
|
pushMatrix();
|
||||||
translate(xPosition, yPosition, 300.0F);
|
translate(xPosition, yPosition, 300.0F);
|
||||||
|
@ -645,13 +639,13 @@ public class GuiSkins extends GuiScreen {
|
||||||
disableColorMaterial();
|
disableColorMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void enableClipping(int yTop, int yBottom) {
|
private void enableClipping(int yBottom) {
|
||||||
if (this.doubleBuffer == null) {
|
if (this.doubleBuffer == null) {
|
||||||
this.doubleBuffer = BufferUtils.createByteBuffer(32).asDoubleBuffer();
|
this.doubleBuffer = BufferUtils.createByteBuffer(32).asDoubleBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.doubleBuffer.clear();
|
this.doubleBuffer.clear();
|
||||||
this.doubleBuffer.put(0.0D).put(1.0D).put(0.0D).put((-yTop)).flip();
|
this.doubleBuffer.put(0.0D).put(1.0D).put(0.0D).put((-30)).flip();
|
||||||
|
|
||||||
GL11.glClipPlane(GL11.GL_CLIP_PLANE0, this.doubleBuffer);
|
GL11.glClipPlane(GL11.GL_CLIP_PLANE0, this.doubleBuffer);
|
||||||
this.doubleBuffer.clear();
|
this.doubleBuffer.clear();
|
||||||
|
@ -662,12 +656,12 @@ public class GuiSkins extends GuiScreen {
|
||||||
GL11.glEnable(GL11.GL_CLIP_PLANE1);
|
GL11.glEnable(GL11.GL_CLIP_PLANE1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void disableClipping() {
|
private void disableClipping() {
|
||||||
GL11.glDisable(GL11.GL_CLIP_PLANE1);
|
GL11.glDisable(GL11.GL_CLIP_PLANE1);
|
||||||
GL11.glDisable(GL11.GL_CLIP_PLANE0);
|
GL11.glDisable(GL11.GL_CLIP_PLANE0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPowerOfTwo(int number) {
|
private static boolean isPowerOfTwo(int number) {
|
||||||
return number != 0 && (number & number - 1) == 0;
|
return number != 0 && (number & number - 1) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,7 @@ import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
|
import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
|
||||||
import com.voxelmodpack.hdskins.gui.GuiSkins;
|
import com.voxelmodpack.hdskins.gui.GuiSkins;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
public class GuiSkinsMineLP extends GuiSkins {
|
public class GuiSkinsMineLP extends GuiSkins {
|
||||||
|
|
||||||
|
@ -23,15 +22,19 @@ public class GuiSkinsMineLP extends GuiSkins {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSetLocalSkin(BufferedImage skin, MinecraftProfileTexture.Type type) {
|
protected void onSetLocalSkin(MinecraftProfileTexture.Type type) {
|
||||||
MineLittlePony.logger.debug("Invalidating old local skin, checking updated local skin");
|
MineLittlePony.logger.debug("Invalidating old local skin, checking updated local skin");
|
||||||
|
if (type == MinecraftProfileTexture.Type.SKIN) {
|
||||||
ponyManager.removePony(this.localPlayer.getSkinTexture());
|
ponyManager.removePony(this.localPlayer.getSkinTexture());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSetRemoteSkin(MinecraftProfileTexture.Type type) {
|
protected void onSetRemoteSkin(MinecraftProfileTexture.Type type, ResourceLocation location, MinecraftProfileTexture profileTexture) {
|
||||||
MineLittlePony.logger.debug("Invalidating old remote skin, checking updated remote skin");
|
MineLittlePony.logger.debug("Invalidating old remote skin, checking updated remote skin");
|
||||||
ponyManager.removePony(this.remotePlayer.getSkinTexture());
|
if (type == MinecraftProfileTexture.Type.SKIN) {
|
||||||
|
ponyManager.removePony(location);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue