mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-25 13:57:59 +01:00
Add support for uploading elytras.
This commit is contained in:
parent
77b79e432c
commit
8971183121
10 changed files with 293 additions and 88 deletions
|
@ -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<Type, MinecraftProfileTexture> 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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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<EntityEquipmentSlot, ItemStack> 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<ItemStack> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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<String, ?> 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) {
|
||||
|
|
|
@ -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<M extends EntityPlayerModel> extends RenderLivingBase<M> {
|
||||
|
||||
/**
|
||||
* 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<EntityLivingBase> getElytraLayer() {
|
||||
final ModelElytra modelElytra = new ModelElytra();
|
||||
return new LayerRenderer<EntityLivingBase>() {
|
||||
@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
|
||||
|
|
|
@ -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"))
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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<EntityPonyModel> {
|
||||
|
||||
|
@ -26,4 +36,46 @@ public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel> {
|
|||
return pm.getModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LayerRenderer<EntityLivingBase> getElytraLayer() {
|
||||
final LayerRenderer<EntityLivingBase> elytra = super.getElytraLayer();
|
||||
final ModelPonyElytra modelElytra = new ModelPonyElytra();
|
||||
return new LayerRenderer<EntityLivingBase>() {
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue