From 89711831210ac2d597100acc434371777f6643be Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Wed, 21 Dec 2016 01:20:02 -0500 Subject: [PATCH] Add support for uploading elytras. --- .../voxelmodpack/hdskins/HDSkinManager.java | 16 +-- .../hdskins/gui/EntityPlayerModel.java | 122 +++++++++++++----- .../hdskins/gui/GuiButtonSkins.java | 22 ---- .../hdskins/gui/GuiItemStackButton.java | 24 ++++ .../voxelmodpack/hdskins/gui/GuiSkins.java | 75 +++++++++-- .../hdskins/gui/RenderPlayerModel.java | 51 +++++++- .../hdskins/mixin/MixinGuiMainMenu.java | 8 +- .../resources/assets/hdskins/lang/en_us.lang | 4 +- .../hdskins/gui/GuiSkinsMineLP.java | 7 +- .../hdskins/gui/RenderPonyModel.java | 52 ++++++++ 10 files changed, 293 insertions(+), 88 deletions(-) delete mode 100644 src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiButtonSkins.java create mode 100644 src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiItemStackButton.java diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java b/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java index c05a62ad..08566e76 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java @@ -33,7 +33,7 @@ import org.apache.commons.codec.binary.Base64; import org.apache.commons.io.FileUtils; import javax.annotation.Nullable; -import java.awt.Graphics; +import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; @@ -231,16 +231,12 @@ public final class HDSkinManager implements IResourceManagerReloadListener { this.enabled = enabled; } - public static PreviewTexture getPreviewTexture(ResourceLocation skinResource, GameProfile profile) { + public static PreviewTexture getPreviewTexture(ResourceLocation skinResource, GameProfile profile, Type type, ResourceLocation def) { TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); - ITextureObject skinTexture = textureManager.getTexture(skinResource); - Map textures = getTexturesForProfile(profile); - MinecraftProfileTexture skin = textures.get(Type.SKIN); - if (skin != null) { - String url = INSTANCE.getCustomTextureURLForId(Type.SKIN, UUIDTypeAdapter.fromUUID(profile.getId()), true); - skinTexture = new PreviewTexture(url, DefaultPlayerSkin.getDefaultSkin(profile.getId()), new ImageBufferDownloadHD()); - TextureLoader.loadTexture(skinResource, skinTexture); - } + String url = INSTANCE.getCustomTextureURLForId(type, UUIDTypeAdapter.fromUUID(profile.getId()), true); + ITextureObject skinTexture = new PreviewTexture(url, def, type == Type.SKIN ? new ImageBufferDownloadHD() : null); + textureManager.loadTexture(skinResource, skinTexture); + return (PreviewTexture) skinTexture; } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/EntityPlayerModel.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/EntityPlayerModel.java index 22a08cd3..305cd47e 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/EntityPlayerModel.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/EntityPlayerModel.java @@ -1,7 +1,9 @@ package com.voxelmodpack.hdskins.gui; -import com.google.common.collect.Iterables; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; import com.mojang.authlib.GameProfile; +import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import com.voxelmodpack.hdskins.DynamicTextureImage; import com.voxelmodpack.hdskins.HDSkinManager; import com.voxelmodpack.hdskins.ImageBufferDownloadHD; @@ -20,13 +22,30 @@ import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; +import java.util.Map; +@SuppressWarnings("EntityConstructor") public class EntityPlayerModel extends EntityLivingBase { - public static final ResourceLocation NOSKIN = new ResourceLocation("hdskins", "textures/mob/noskin.png"); + + public static final ResourceLocation NO_SKIN = new ResourceLocation("hdskins", "textures/mob/noskin.png"); + public static final ResourceLocation NO_ELYTRA = new ResourceLocation("textures/entity/elytra.png"); + + private Map armors = Maps.newEnumMap(ImmutableMap.of( + EntityEquipmentSlot.HEAD, ItemStack.EMPTY, + EntityEquipmentSlot.CHEST, ItemStack.EMPTY, + EntityEquipmentSlot.LEGS, ItemStack.EMPTY, + EntityEquipmentSlot.FEET, ItemStack.EMPTY, + EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY + )); + private PreviewTexture remoteSkinTexture; private ResourceLocation remoteSkinResource; private ResourceLocation localSkinResource; private DynamicTexture localSkinTexture; + private PreviewTexture remoteElytraTexture; + private ResourceLocation remoteElytraResource; + private ResourceLocation localElytraResource; + private DynamicTexture localElytraTexture; private TextureManager textureManager; public final GameProfile profile; public boolean isSwinging = false; @@ -38,8 +57,11 @@ public class EntityPlayerModel extends EntityLivingBase { this.profile = profile; this.textureManager = Minecraft.getMinecraft().getTextureManager(); this.remoteSkinResource = new ResourceLocation("skins/preview_" + this.profile.getName() + ".png"); - this.localSkinResource = NOSKIN; + this.remoteElytraResource = new ResourceLocation("elytras/preview_" + this.profile.getName() + ".png"); + this.localSkinResource = NO_SKIN; + this.localElytraResource = NO_ELYTRA; this.textureManager.deleteTexture(this.remoteSkinResource); + this.textureManager.deleteTexture(this.remoteElytraResource); } public void reloadRemoteSkin() { @@ -47,33 +69,58 @@ public class EntityPlayerModel extends EntityLivingBase { if (this.remoteSkinTexture != null) { this.textureManager.deleteTexture(this.remoteSkinResource); } - - this.remoteSkinTexture = HDSkinManager.getPreviewTexture(this.remoteSkinResource, this.profile); - } - - public void setLocalSkin(File skinTextureFile) { - if (skinTextureFile.exists()) { - this.remoteSkin = false; - if (this.localSkinTexture != null) { - this.textureManager.deleteTexture(this.localSkinResource); - this.localSkinTexture = null; - } - - BufferedImage bufferedImage; - try { - BufferedImage image = ImageIO.read(skinTextureFile); - bufferedImage = new ImageBufferDownloadHD().parseUserSkin(image); - } catch (IOException var4) { - this.localSkinResource = NOSKIN; - var4.printStackTrace(); - return; - } - - this.localSkinTexture = new DynamicTextureImage(bufferedImage); - this.localSkinResource = this.textureManager.getDynamicTextureLocation("localSkinPreview", this.localSkinTexture); - this.hasLocalTexture = true; + if (this.remoteElytraTexture != null) { + this.textureManager.deleteTexture(this.remoteElytraResource); } + this.remoteSkinTexture = HDSkinManager.getPreviewTexture(this.remoteSkinResource, this.profile, Type.SKIN, NO_SKIN); + this.remoteElytraTexture = HDSkinManager.getPreviewTexture(this.remoteElytraResource, this.profile, Type.ELYTRA, NO_ELYTRA); + + } + + public void setLocalTexture(File skinTextureFile, Type type) { + if (skinTextureFile.exists()) { + if (type == Type.SKIN) { + this.remoteSkin = false; + if (this.localSkinTexture != null) { + this.textureManager.deleteTexture(this.localSkinResource); + this.localSkinTexture = null; + } + + BufferedImage bufferedImage; + try { + BufferedImage image = ImageIO.read(skinTextureFile); + bufferedImage = new ImageBufferDownloadHD().parseUserSkin(image); + } catch (IOException var4) { + this.localSkinResource = NO_SKIN; + var4.printStackTrace(); + return; + } + + this.localSkinTexture = new DynamicTextureImage(bufferedImage); + this.localSkinResource = this.textureManager.getDynamicTextureLocation("localSkinPreview", this.localSkinTexture); + this.hasLocalTexture = true; + } else if (type == Type.ELYTRA) { + this.remoteSkin = false; + if (this.localElytraTexture != null) { + this.textureManager.deleteTexture(this.localElytraResource); + this.localElytraTexture = null; + } + + BufferedImage bufferedImage; + try { + bufferedImage = ImageIO.read(skinTextureFile); + } catch (IOException var4) { + this.localElytraResource = NO_ELYTRA; + var4.printStackTrace(); + return; + } + + this.localElytraTexture = new DynamicTextureImage(bufferedImage); + this.localElytraResource = this.textureManager.getDynamicTextureLocation("localElytraPreview", this.localElytraTexture); + this.hasLocalTexture = true; + } + } } public boolean isUsingLocalTexture() { @@ -93,7 +140,13 @@ public class EntityPlayerModel extends EntityLivingBase { if (this.localSkinTexture != null) { this.textureManager.deleteTexture(this.localSkinResource); this.localSkinTexture = null; - this.localSkinResource = NOSKIN; + this.localSkinResource = NO_SKIN; + this.hasLocalTexture = false; + } + if (this.localElytraTexture != null) { + this.textureManager.deleteTexture(this.localElytraResource); + this.localElytraTexture = null; + this.localElytraResource = NO_ELYTRA; this.hasLocalTexture = false; } } @@ -103,6 +156,10 @@ public class EntityPlayerModel extends EntityLivingBase { : DefaultPlayerSkin.getDefaultSkin(entityUniqueID)) : this.localSkinResource; } + public ResourceLocation getElytraTexture() { + return this.remoteSkin && this.remoteElytraTexture != null ? this.remoteElytraResource : localElytraResource; + } + public void swingArm() { if (!this.isSwinging || this.swingProgressInt >= 4 || this.swingProgressInt < 0) { this.swingProgressInt = -1; @@ -136,19 +193,20 @@ public class EntityPlayerModel extends EntityLivingBase { return 15728880; } + @Override public Iterable getArmorInventoryList() { - return Iterables.cycle(null, null, null, null); + return armors.values(); } @Override public ItemStack getItemStackFromSlot(EntityEquipmentSlot slotIn) { - return null; + return armors.get(slotIn); } @Override public void setItemStackToSlot(EntityEquipmentSlot slotIn, ItemStack stack) { - + armors.put(slotIn, stack); } } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiButtonSkins.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiButtonSkins.java deleted file mode 100644 index 7c53a19b..00000000 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiButtonSkins.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.voxelmodpack.hdskins.gui; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - -public class GuiButtonSkins extends GuiButton { - - public GuiButtonSkins(int buttonId, int x, int y) { - super(buttonId, x, y, 20, 20, ""); - } - - @Override - public void drawButton(Minecraft mc, int mouseX, int mouseY) { - super.drawButton(mc, mouseX, mouseY); - - ItemStack stack = new ItemStack(Items.LEATHER_LEGGINGS, 1, 0); - Items.LEATHER_LEGGINGS.setColor(stack, 0x3c5dcb); - mc.getRenderItem().renderItemIntoGUI(stack, this.xPosition + 2, this.yPosition + 2); - } -} diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiItemStackButton.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiItemStackButton.java new file mode 100644 index 00000000..187bca49 --- /dev/null +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiItemStackButton.java @@ -0,0 +1,24 @@ +package com.voxelmodpack.hdskins.gui; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.item.ItemStack; + +import javax.annotation.Nonnull; + +public class GuiItemStackButton extends GuiButton { + + private ItemStack itemStack; + + public GuiItemStackButton(int buttonId, int x, int y, @Nonnull ItemStack itemStack) { + super(buttonId, x, y, 20, 20, ""); + this.itemStack = itemStack; + } + + @Override + public void drawButton(Minecraft mc, int mouseX, int mouseY) { + super.drawButton(mc, mouseX, mouseY); + + mc.getRenderItem().renderItemIntoGUI(itemStack, this.xPosition + 2, this.yPosition + 2); + } +} diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java index eacc46c8..39203785 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java @@ -3,6 +3,7 @@ package com.voxelmodpack.hdskins.gui; import com.google.common.collect.ImmutableMap; import com.mojang.authlib.GameProfile; import com.mojang.authlib.exceptions.AuthenticationException; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.authlib.minecraft.MinecraftSessionService; import com.mumfrey.liteloader.util.log.LiteLoaderLogger; import com.voxelmodpack.hdskins.HDSkinManager; @@ -22,6 +23,9 @@ import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.resources.I18n; +import net.minecraft.init.Items; +import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Session; import net.minecraft.util.math.MathHelper; @@ -32,14 +36,7 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.util.glu.GLU; import javax.imageio.ImageIO; -import javax.swing.BorderFactory; -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.SwingConstants; -import javax.swing.UIManager; -import javax.swing.WindowConstants; +import javax.swing.*; import java.awt.Color; import java.awt.Window.Type; import java.awt.dnd.DropTarget; @@ -47,8 +44,11 @@ import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.nio.DoubleBuffer; +import java.util.Locale; import java.util.Map; +import static com.mojang.authlib.minecraft.MinecraftProfileTexture.Type.ELYTRA; +import static com.mojang.authlib.minecraft.MinecraftProfileTexture.Type.SKIN; import static net.minecraft.client.renderer.GlStateManager.*; public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpenFileCallback { @@ -63,12 +63,17 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_3.png"), new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_4.png"), new ResourceLocation("hdskins", "textures/cubemaps/cubemap0_5.png")}; + private GuiButton btnBrowse; private GuiButton btnUpload; private GuiButton btnClear; private GuiButton btnBack; + private GuiButton btnModeSkin; + private GuiButton btnModeElytra; + protected EntityPlayerModel localPlayer; protected EntityPlayerModel remotePlayer; + protected DoubleBuffer doubleBuffer; // private String screenTitle; private String uploadError; @@ -89,6 +94,8 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe private float lastPartialTick; private JFrame fileDrop; + private MinecraftProfileTexture.Type textureType = SKIN; + // translations private final String screenTitle = I18n.format("hdskins.manager"); private final String unreadable = I18n.format("hdskins.error.unreadable"); @@ -136,10 +143,11 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe synchronized (this.skinLock) { if (this.pendingSkinFile != null) { - this.localPlayer.setLocalSkin(this.pendingSkinFile); + System.out.println("Set " + textureType + " " + this.pendingSkinFile); + this.localPlayer.setLocalTexture(this.pendingSkinFile, textureType); this.selectedSkin = this.pendingSkinFile; this.pendingSkinFile = null; - this.onSetLocalSkin(this.pendingSkinImage); + this.onSetLocalSkin(this.pendingSkinImage, textureType); this.pendingSkinImage = null; this.btnUpload.enabled = true; } @@ -150,7 +158,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe this.fetchingSkin = true; this.btnClear.enabled = false; this.reloadRemoteSkin(); - this.onSetRemoteSkin(); + this.onSetRemoteSkin(textureType); } if (this.throttledByMojang) { @@ -167,10 +175,10 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe } - protected void onSetRemoteSkin() { + protected void onSetRemoteSkin(MinecraftProfileTexture.Type type) { } - protected void onSetLocalSkin(BufferedImage skin) { + protected void onSetLocalSkin(BufferedImage skin, MinecraftProfileTexture.Type type) { } private void reloadRemoteSkin() { @@ -192,8 +200,15 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe this.buttonList.add(this.btnUpload = new GuiButton(1, this.width / 2 - 24, this.height / 2 - 10, 48, 20, ">>")); this.buttonList.add(this.btnClear = new GuiButton(2, this.width - 90, this.height - 36, 60, 20, "Clear")); this.buttonList.add(this.btnBack = new GuiButton(3, this.width / 2 - 50, this.height - 36, 100, 20, "Close")); + + ItemStack skin = new ItemStack(Items.LEATHER_LEGGINGS); + Items.LEATHER_LEGGINGS.setColor(skin, 0x3c5dcb); + this.buttonList.add(this.btnModeElytra = new GuiItemStackButton(5, 2, 24, new ItemStack(Items.ELYTRA))); + this.buttonList.add(this.btnModeSkin = new GuiItemStackButton(4, 2, 2, skin)); + this.btnUpload.enabled = false; this.btnBrowse.enabled = !this.mc.isFullScreen(); + (this.textureType == SKIN ? this.btnModeSkin : this.btnModeElytra).enabled = false; } /** @@ -318,6 +333,27 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe this.mc.displayGuiScreen(new GuiMainMenu()); } + if (guiButton.id == this.btnModeSkin.id || guiButton.id == this.btnModeElytra.id) { + ItemStack stack; + if (guiButton.id == this.btnModeSkin.id) { + this.textureType = SKIN; + this.btnModeElytra.enabled = true; + stack = ItemStack.EMPTY; + } else { + this.textureType = ELYTRA; + this.btnModeSkin.enabled = true; + stack = new ItemStack(Items.ELYTRA); + } + guiButton.enabled = false; + // clear currently selected skin + this.selectedSkin = null; + this.localPlayer.releaseTextures(); + + // put on or take off the elytra + this.localPlayer.setItemStackToSlot(EntityEquipmentSlot.CHEST, stack); + this.remotePlayer.setItemStackToSlot(EntityEquipmentSlot.CHEST, stack); + } + } } } @@ -542,6 +578,16 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe Gui.drawRect(40, this.height / 2 - 12, this.width / 2 - 40, this.height / 2 + 12, 0xB0000000); this.fontRendererObj.drawStringWithShadow(this.skinMessage, (int) (xPos1 - opacity), this.height / 2 - 4, 0xffffff); } + if (this.btnModeSkin.isMouseOver() || this.btnModeElytra.isMouseOver()) { + int y = Math.max(mouseY, 16); + String text; + if (this.btnModeSkin.isMouseOver()) { + text = "hdskins.mode.skin"; + } else{ + text = "hdskins.mode.elytra"; + } + this.drawCreativeTabHoveringText(I18n.format(text), mouseX, y); + } if (this.fetchingSkin) { String opacity1; @@ -671,6 +717,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe return ImmutableMap.of( "user", session.getUsername(), "uuid", session.getPlayerID(), + "type", this.textureType.toString().toLowerCase(Locale.US), param, val); } @@ -679,7 +726,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe } private Map getUploadData(Session session, File skinFile) { - return getData(session, "skin", skinFile); + return getData(session, this.textureType.toString().toLowerCase(Locale.US), skinFile); } private void setUploadError(String error) { diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java index 263c5dba..0d700258 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java @@ -1,27 +1,70 @@ package com.voxelmodpack.hdskins.gui; import net.minecraft.client.Minecraft; +import net.minecraft.client.model.ModelElytra; import net.minecraft.client.model.ModelPlayer; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.layers.LayerRenderer; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EnumPlayerModelParts; +import net.minecraft.init.Items; +import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import java.util.Set; -import static net.minecraft.client.renderer.GlStateManager.popAttrib; -import static net.minecraft.client.renderer.GlStateManager.popMatrix; -import static net.minecraft.client.renderer.GlStateManager.pushMatrix; -import static net.minecraft.client.renderer.GlStateManager.scale; +import static net.minecraft.client.renderer.GlStateManager.*; public class RenderPlayerModel extends RenderLivingBase { + /** + * The basic Elytra texture. + */ + protected final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("textures/entity/elytra.png"); + private static final ModelPlayer FAT = new ModelPlayer(0, false); //private static final ModelPlayer THIN = new ModelPlayer(0, true); public RenderPlayerModel(RenderManager renderer) { super(renderer, FAT, 0.0F); + this.addLayer(this.getElytraLayer()); + } + + protected LayerRenderer getElytraLayer() { + final ModelElytra modelElytra = new ModelElytra(); + return new LayerRenderer() { + @Override + public void doRenderLayer(EntityLivingBase entityBase, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + EntityPlayerModel entity = (EntityPlayerModel) entityBase; + ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST); + + if (itemstack.getItem() == Items.ELYTRA) { + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); + + bindTexture(entity.getElytraTexture()); + + GlStateManager.pushMatrix(); + GlStateManager.translate(0.0F, 0.0F, 0.125F); + + modelElytra.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entity); + modelElytra.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); + + GlStateManager.disableBlend(); + GlStateManager.popMatrix(); + } + } + + @Override + public boolean shouldCombineTextures() { + return false; + } + }; } @Override diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinGuiMainMenu.java b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinGuiMainMenu.java index 6612e71e..9f1e26fc 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinGuiMainMenu.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinGuiMainMenu.java @@ -1,10 +1,12 @@ package com.voxelmodpack.hdskins.mixin; -import com.voxelmodpack.hdskins.gui.GuiButtonSkins; +import com.voxelmodpack.hdskins.gui.GuiItemStackButton; import com.voxelmodpack.hdskins.gui.GuiSkins; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.client.gui.GuiScreen; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -17,7 +19,9 @@ public class MixinGuiMainMenu extends GuiScreen { @Inject(method = "initGui()V", at = @At("RETURN")) private void onInit(CallbackInfo ci) { - this.buttonList.add(new GuiButtonSkins(SKINS, width - 50, height - 50)); + ItemStack itemStack = new ItemStack(Items.LEATHER_LEGGINGS); + Items.LEATHER_LEGGINGS.setColor(itemStack, 0x3c5dcb); + this.buttonList.add(new GuiItemStackButton(SKINS, width - 50, height - 50, itemStack)); } @Inject(method = "actionPerformed(Lnet/minecraft/client/gui/GuiButton;)V", at = @At("RETURN")) diff --git a/src/hdskins/resources/assets/hdskins/lang/en_us.lang b/src/hdskins/resources/assets/hdskins/lang/en_us.lang index b5ccefa1..5e0fd519 100644 --- a/src/hdskins/resources/assets/hdskins/lang/en_us.lang +++ b/src/hdskins/resources/assets/hdskins/lang/en_us.lang @@ -17,4 +17,6 @@ hdskins.upload=Uploading skin please wait... hdskins.local=Local Skin hdskins.server=Server Skin -gui.ok=OK +hdskins.mode.skin=Skin +hdskins.mode.elytra=Elytra + diff --git a/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java b/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java index de4a59d4..468bb17f 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/GuiSkinsMineLP.java @@ -3,6 +3,7 @@ package com.minelittlepony.hdskins.gui; import com.minelittlepony.MineLittlePony; import com.minelittlepony.PonyManager; import com.mojang.authlib.GameProfile; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.voxelmodpack.hdskins.gui.EntityPlayerModel; import com.voxelmodpack.hdskins.gui.GuiSkins; @@ -22,14 +23,14 @@ public class GuiSkinsMineLP extends GuiSkins { } @Override - protected void onSetLocalSkin(BufferedImage skin) { + protected void onSetLocalSkin(BufferedImage skin, MinecraftProfileTexture.Type type) { MineLittlePony.logger.debug("Invalidating old local skin, checking updated local skin"); ponyManager.getPonyFromResourceRegistry(this.localPlayer.getSkinTexture()).checkSkin(skin); } @Override - protected void onSetRemoteSkin() { - MineLittlePony.logger.debug("Invalidating old remove skin, checking updated remote skin"); + protected void onSetRemoteSkin(MinecraftProfileTexture.Type type) { + MineLittlePony.logger.debug("Invalidating old remote skin, checking updated remote skin"); ponyManager.getPonyFromResourceRegistry(this.remotePlayer.getSkinTexture()).invalidateSkinCheck(); } diff --git a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java index 1054b29e..dedacb20 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java @@ -2,10 +2,20 @@ package com.minelittlepony.hdskins.gui; import com.minelittlepony.MineLittlePony; import com.minelittlepony.Pony; +import com.minelittlepony.model.AbstractPonyModel; +import com.minelittlepony.model.BodyPart; +import com.minelittlepony.model.ModelPonyElytra; import com.minelittlepony.model.PlayerModel; +import com.minelittlepony.model.pony.ModelHumanPlayer; import com.voxelmodpack.hdskins.gui.RenderPlayerModel; import net.minecraft.client.model.ModelPlayer; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.layers.LayerRenderer; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Items; +import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.item.ItemStack; public class RenderPonyModel extends RenderPlayerModel { @@ -26,4 +36,46 @@ public class RenderPonyModel extends RenderPlayerModel { return pm.getModel(); } + @Override + protected LayerRenderer getElytraLayer() { + final LayerRenderer elytra = super.getElytraLayer(); + final ModelPonyElytra modelElytra = new ModelPonyElytra(); + return new LayerRenderer() { + + @Override + public void doRenderLayer(EntityLivingBase entityBase, float swing, float swingAmount, float ticks, float age, float yaw, float head, float scale) { + if (mainModel instanceof ModelHumanPlayer) { + elytra.doRenderLayer(entityBase, swing, swingAmount, ticks, age, yaw, head, scale); + return; + } + + EntityPonyModel entity = (EntityPonyModel) entityBase; + + ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST); + + if (itemstack.getItem() == Items.ELYTRA) { + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + + bindTexture(entity.getElytraTexture()); + + GlStateManager.pushMatrix(); + GlStateManager.translate(0.0F, 0.25F, 0.125F); + if (mainModel instanceof AbstractPonyModel) + ((AbstractPonyModel) mainModel).transform(BodyPart.BODY); + + modelElytra.setRotationAngles(swing, swingAmount, age, yaw, head, scale, entity); + modelElytra.render(entity, swing, swingAmount, age, yaw, head, scale); + + + GlStateManager.popMatrix(); + } + } + + @Override + public boolean shouldCombineTextures() { + return false; + } + + }; + } }