mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-23 12:58:01 +01:00
Split duplicated code out to LocalTexture
This commit is contained in:
parent
b485f07d17
commit
01bdac7ed8
7 changed files with 407 additions and 412 deletions
118
src/hdskins/java/com/voxelmodpack/hdskins/LocalTexture.java
Normal file
118
src/hdskins/java/com/voxelmodpack/hdskins/LocalTexture.java
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
package com.voxelmodpack.hdskins;
|
||||||
|
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
|
import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public class LocalTexture {
|
||||||
|
|
||||||
|
private final TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
|
||||||
|
|
||||||
|
private DynamicTexture local;
|
||||||
|
private PreviewTexture remote;
|
||||||
|
|
||||||
|
private ResourceLocation remoteResource;
|
||||||
|
private ResourceLocation localResource;
|
||||||
|
|
||||||
|
private final IBlankSkinSupplier blank;
|
||||||
|
|
||||||
|
private final Type type;
|
||||||
|
|
||||||
|
public LocalTexture(GameProfile profile, Type type, IBlankSkinSupplier blank) {
|
||||||
|
this.blank = blank;
|
||||||
|
this.type = type;
|
||||||
|
|
||||||
|
String file = type.name().toLowerCase() + "s/preview_${profile.getName()}.png";
|
||||||
|
|
||||||
|
remoteResource = new ResourceLocation(file);
|
||||||
|
textureManager.deleteTexture(remoteResource);
|
||||||
|
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceLocation getTexture() {
|
||||||
|
if (hasRemote()) {
|
||||||
|
return remoteResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
return localResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
localResource = blank.getBlankSkin(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasRemote() {
|
||||||
|
return remote != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasLocal() {
|
||||||
|
return local != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean usingLocal() {
|
||||||
|
return !hasRemote() && hasLocal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean uploadComplete() {
|
||||||
|
return hasRemote() && remote.isTextureUploaded();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PreviewTexture getRemote() {
|
||||||
|
return remote;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemote(PreviewTextureManager ptm, SkinAvailableCallback callback) {
|
||||||
|
clearRemote();
|
||||||
|
|
||||||
|
remote = ptm.getPreviewTexture(remoteResource, type, blank.getBlankSkin(type), callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocal(File file) {
|
||||||
|
if (!file.exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
clearLocal();
|
||||||
|
|
||||||
|
try {
|
||||||
|
BufferedImage image = ImageIO.read(file);
|
||||||
|
BufferedImage bufferedImage = new ImageBufferDownloadHD().parseUserSkin(image);
|
||||||
|
|
||||||
|
local = new DynamicTextureImage(bufferedImage);
|
||||||
|
localResource = textureManager.getDynamicTextureLocation("localSkinPreview", local);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clearRemote() {
|
||||||
|
if (hasRemote()) {
|
||||||
|
remote = null;
|
||||||
|
textureManager.deleteTexture(remoteResource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearLocal() {
|
||||||
|
if (hasLocal()) {
|
||||||
|
local = null;
|
||||||
|
textureManager.deleteTexture(localResource);
|
||||||
|
localResource = blank.getBlankSkin(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IBlankSkinSupplier {
|
||||||
|
ResourceLocation getBlankSkin(Type type);
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,36 +4,27 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
import com.voxelmodpack.hdskins.DynamicTextureImage;
|
|
||||||
import com.voxelmodpack.hdskins.HDSkinManager;
|
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||||
import com.voxelmodpack.hdskins.ImageBufferDownloadHD;
|
import com.voxelmodpack.hdskins.LocalTexture;
|
||||||
import com.voxelmodpack.hdskins.PreviewTexture;
|
import com.voxelmodpack.hdskins.LocalTexture.IBlankSkinSupplier;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
|
||||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
|
||||||
import net.minecraft.client.resources.SkinManager;
|
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.EnumHand;
|
|
||||||
import net.minecraft.util.EnumHandSide;
|
import net.minecraft.util.EnumHandSide;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
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 implements IBlankSkinSupplier {
|
||||||
|
|
||||||
public static final ResourceLocation NO_SKIN = 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");
|
public static final ResourceLocation NO_ELYTRA = new ResourceLocation("textures/entity/elytra.png");
|
||||||
|
|
||||||
private Map<EntityEquipmentSlot, ItemStack> armors = Maps.newEnumMap(ImmutableMap.of(
|
private final Map<EntityEquipmentSlot, ItemStack> armour = Maps.newEnumMap(ImmutableMap.of(
|
||||||
EntityEquipmentSlot.HEAD, ItemStack.EMPTY,
|
EntityEquipmentSlot.HEAD, ItemStack.EMPTY,
|
||||||
EntityEquipmentSlot.CHEST, ItemStack.EMPTY,
|
EntityEquipmentSlot.CHEST, ItemStack.EMPTY,
|
||||||
EntityEquipmentSlot.LEGS, ItemStack.EMPTY,
|
EntityEquipmentSlot.LEGS, ItemStack.EMPTY,
|
||||||
|
@ -41,134 +32,56 @@ public class EntityPlayerModel extends EntityLivingBase {
|
||||||
EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY
|
EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY
|
||||||
));
|
));
|
||||||
|
|
||||||
private volatile PreviewTexture remoteSkinTexture;
|
protected final LocalTexture skin;
|
||||||
private ResourceLocation remoteSkinResource;
|
protected final LocalTexture elytra;
|
||||||
protected ResourceLocation localSkinResource;
|
|
||||||
private DynamicTexture localSkinTexture;
|
|
||||||
private volatile PreviewTexture remoteElytraTexture;
|
|
||||||
private ResourceLocation remoteElytraResource;
|
|
||||||
private ResourceLocation localElytraResource;
|
|
||||||
private DynamicTexture localElytraTexture;
|
|
||||||
private TextureManager textureManager;
|
|
||||||
public final GameProfile profile;
|
public final GameProfile profile;
|
||||||
|
|
||||||
protected boolean remoteSkin = false;
|
|
||||||
protected boolean hasLocalTexture = false;
|
|
||||||
protected boolean previewThinArms = false;
|
protected boolean previewThinArms = false;
|
||||||
|
|
||||||
public EntityPlayerModel(GameProfile profile) {
|
public EntityPlayerModel(GameProfile gameprofile) {
|
||||||
super(new DummyWorld());
|
super(new DummyWorld());
|
||||||
this.profile = profile;
|
profile = gameprofile;
|
||||||
this.textureManager = Minecraft.getMinecraft().getTextureManager();
|
|
||||||
this.remoteSkinResource = new ResourceLocation("skins/preview_" + this.profile.getName() + ".png");
|
skin = new LocalTexture(profile, Type.SKIN, this);
|
||||||
this.remoteElytraResource = new ResourceLocation("elytras/preview_" + this.profile.getName() + ".png");
|
elytra = new LocalTexture(profile, Type.ELYTRA, this);
|
||||||
this.localSkinResource = getBlankSkin();
|
|
||||||
this.localElytraResource = getBlankElytra();
|
|
||||||
this.textureManager.deleteTexture(this.remoteSkinResource);
|
|
||||||
this.textureManager.deleteTexture(this.remoteElytraResource);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadRemoteSkin(SkinManager.SkinAvailableCallback listener) {
|
public void reloadRemoteSkin(SkinManager.SkinAvailableCallback listener) {
|
||||||
this.remoteSkin = true;
|
HDSkinManager.getPreviewTextureManager(profile).thenAccept(ptm -> {
|
||||||
if (this.remoteSkinTexture != null) {
|
skin.setRemote(ptm, listener);
|
||||||
this.textureManager.deleteTexture(this.remoteSkinResource);
|
elytra.setRemote(ptm, listener);
|
||||||
}
|
|
||||||
if (this.remoteElytraTexture != null) {
|
|
||||||
this.textureManager.deleteTexture(this.remoteElytraResource);
|
|
||||||
}
|
|
||||||
|
|
||||||
HDSkinManager.getPreviewTextureManager(this.profile).thenAccept(ptm -> {
|
|
||||||
this.remoteSkinTexture = ptm.getPreviewTexture(this.remoteSkinResource, Type.SKIN, getBlankSkin(), listener);
|
|
||||||
this.remoteElytraTexture = ptm.getPreviewTexture(this.remoteElytraResource, Type.ELYTRA, getBlankElytra(), null);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocalTexture(File skinTextureFile, Type type) {
|
public void setLocalTexture(File skinTextureFile, Type type) {
|
||||||
if (skinTextureFile.exists()) {
|
|
||||||
if (type == Type.SKIN) {
|
if (type == Type.SKIN) {
|
||||||
this.remoteSkin = false;
|
skin.setLocal(skinTextureFile);
|
||||||
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);
|
|
||||||
assert bufferedImage != null;
|
|
||||||
} catch (IOException var4) {
|
|
||||||
this.localSkinResource = getBlankSkin();
|
|
||||||
var4.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.localSkinTexture = new DynamicTextureImage(bufferedImage);
|
|
||||||
this.localSkinResource = this.textureManager.getDynamicTextureLocation("localSkinPreview", this.localSkinTexture);
|
|
||||||
this.hasLocalTexture = true;
|
|
||||||
} else if (type == Type.ELYTRA) {
|
} else if (type == Type.ELYTRA) {
|
||||||
this.remoteSkin = false;
|
elytra.setLocal(skinTextureFile);
|
||||||
if (this.localElytraTexture != null) {
|
|
||||||
this.textureManager.deleteTexture(this.localElytraResource);
|
|
||||||
this.localElytraTexture = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
BufferedImage bufferedImage;
|
|
||||||
try {
|
|
||||||
bufferedImage = ImageIO.read(skinTextureFile);
|
|
||||||
} catch (IOException var4) {
|
|
||||||
this.localElytraResource = getBlankElytra();
|
|
||||||
var4.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.localElytraTexture = new DynamicTextureImage(bufferedImage);
|
|
||||||
this.localElytraResource = this.textureManager.getDynamicTextureLocation("localElytraPreview", this.localElytraTexture);
|
|
||||||
this.hasLocalTexture = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ResourceLocation getBlankSkin() {
|
@Override
|
||||||
return NO_SKIN;
|
public ResourceLocation getBlankSkin(Type type) {
|
||||||
}
|
return type == Type.SKIN ? NO_SKIN : NO_ELYTRA;
|
||||||
|
|
||||||
protected ResourceLocation getBlankElytra() {
|
|
||||||
return NO_ELYTRA;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUsingLocalTexture() {
|
public boolean isUsingLocalTexture() {
|
||||||
return !this.remoteSkin && this.hasLocalTexture;
|
return skin.usingLocal() || elytra.usingLocal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTextureSetupComplete() {
|
public boolean isTextureSetupComplete() {
|
||||||
return (this.remoteSkin && this.remoteSkinTexture != null) && this.remoteSkinTexture.isTextureUploaded();
|
return skin.uploadComplete() && elytra.uploadComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void releaseTextures() {
|
public void releaseTextures() {
|
||||||
if (this.localSkinTexture != null) {
|
skin.clearLocal();
|
||||||
this.textureManager.deleteTexture(this.localSkinResource);
|
elytra.clearLocal();
|
||||||
this.localSkinTexture = null;
|
|
||||||
this.localSkinResource = getBlankSkin();
|
|
||||||
this.hasLocalTexture = false;
|
|
||||||
}
|
|
||||||
if (this.localElytraTexture != null) {
|
|
||||||
this.textureManager.deleteTexture(this.localElytraResource);
|
|
||||||
this.localElytraTexture = null;
|
|
||||||
this.localElytraResource = getBlankElytra();
|
|
||||||
this.hasLocalTexture = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceLocation getSkinTexture() {
|
public LocalTexture getLocal(Type type) {
|
||||||
return this.remoteSkin ? (this.remoteSkinTexture != null ? this.remoteSkinResource
|
return type == Type.SKIN ? skin : elytra;
|
||||||
: DefaultPlayerSkin.getDefaultSkin(entityUniqueID)) : this.localSkinResource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResourceLocation getElytraTexture() {
|
|
||||||
return this.remoteSkin && this.remoteElytraTexture != null ? this.remoteElytraResource : localElytraResource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPreviewThinArms(boolean thinArms) {
|
public void setPreviewThinArms(boolean thinArms) {
|
||||||
|
@ -176,37 +89,26 @@ public class EntityPlayerModel extends EntityLivingBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean usesThinSkin() {
|
public boolean usesThinSkin() {
|
||||||
if (isTextureSetupComplete() && remoteSkinTexture.hasModel()) {
|
if (skin.uploadComplete() && skin.getRemote().hasModel()) {
|
||||||
return remoteSkinTexture.usesThinArms();
|
return skin.getRemote().usesThinArms();
|
||||||
}
|
}
|
||||||
|
|
||||||
return previewThinArms;
|
return previewThinArms;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void swingArm(EnumHand hand) {
|
|
||||||
super.swingArm(hand);
|
|
||||||
if (!this.isSwingInProgress || this.swingProgressInt >= 4 || this.swingProgressInt < 0) {
|
|
||||||
this.swingProgressInt = -1;
|
|
||||||
this.isSwingInProgress = true;
|
|
||||||
this.swingingHand = hand;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateModel() {
|
public void updateModel() {
|
||||||
this.prevSwingProgress = this.swingProgress;
|
prevSwingProgress = swingProgress;
|
||||||
if (this.isSwingInProgress) {
|
if (isSwingInProgress) {
|
||||||
++this.swingProgressInt;
|
++swingProgressInt;
|
||||||
if (this.swingProgressInt >= 8) {
|
if (swingProgressInt >= 8) {
|
||||||
this.swingProgressInt = 0;
|
swingProgressInt = 0;
|
||||||
this.isSwingInProgress = false;
|
isSwingInProgress = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.swingProgressInt = 0;
|
swingProgressInt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.swingProgress = this.swingProgressInt / 8.0F;
|
swingProgress = swingProgressInt / 8F;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -216,17 +118,16 @@ public class EntityPlayerModel extends EntityLivingBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<ItemStack> getArmorInventoryList() {
|
public Iterable<ItemStack> getArmorInventoryList() {
|
||||||
return armors.values();
|
return armour.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItemStackFromSlot(EntityEquipmentSlot slotIn) {
|
public ItemStack getItemStackFromSlot(EntityEquipmentSlot slotIn) {
|
||||||
return armors.get(slotIn);
|
return armour.get(slotIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setItemStackToSlot(EntityEquipmentSlot slotIn, ItemStack stack) {
|
public void setItemStackToSlot(EntityEquipmentSlot slotIn, ItemStack stack) {
|
||||||
armors.put(slotIn, stack);
|
armour.put(slotIn, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,13 @@ import com.google.common.base.Throwables;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
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.mumfrey.liteloader.util.log.LiteLoaderLogger;
|
import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
|
||||||
import com.voxelmodpack.hdskins.HDSkinManager;
|
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||||
import com.voxelmodpack.hdskins.skins.SkinServer;
|
|
||||||
import com.voxelmodpack.hdskins.skins.SkinUpload;
|
import com.voxelmodpack.hdskins.skins.SkinUpload;
|
||||||
import com.voxelmodpack.hdskins.skins.SkinUploadResponse;
|
import com.voxelmodpack.hdskins.skins.SkinUploadResponse;
|
||||||
import com.voxelmodpack.hdskins.upload.awt.ThreadOpenFilePNG;
|
import com.voxelmodpack.hdskins.upload.awt.ThreadOpenFilePNG;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Gui;
|
import net.minecraft.client.gui.Gui;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
@ -28,8 +29,6 @@ import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.Session;
|
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.lwjgl.BufferUtils;
|
import org.lwjgl.BufferUtils;
|
||||||
|
@ -72,16 +71,18 @@ public class GuiSkins extends GuiScreen {
|
||||||
private String uploadError;
|
private String uploadError;
|
||||||
private volatile String skinMessage = I18n.format("hdskins.choose");
|
private volatile String skinMessage = I18n.format("hdskins.choose");
|
||||||
private String skinUploadMessage = I18n.format("hdskins.request");
|
private String skinUploadMessage = I18n.format("hdskins.request");
|
||||||
|
|
||||||
private volatile boolean fetchingSkin;
|
private volatile boolean fetchingSkin;
|
||||||
private volatile boolean uploadingSkin;
|
private volatile boolean uploadingSkin;
|
||||||
private volatile boolean pendingRemoteSkinRefresh;
|
private volatile boolean pendingRemoteSkinRefresh;
|
||||||
private volatile boolean throttledByMojang;
|
private volatile boolean throttledByMojang;
|
||||||
|
|
||||||
private int refreshCounter = -1;
|
private int refreshCounter = -1;
|
||||||
private ThreadOpenFilePNG openFileThread;
|
private ThreadOpenFilePNG openFileThread;
|
||||||
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 float uploadOpacity = 0.0F;
|
private float uploadOpacity = 0;
|
||||||
|
|
||||||
private int lastMouseX = 0;
|
private int lastMouseX = 0;
|
||||||
|
|
||||||
|
@ -93,20 +94,22 @@ public class GuiSkins extends GuiScreen {
|
||||||
private boolean thinArmType = false;
|
private boolean thinArmType = false;
|
||||||
|
|
||||||
public GuiSkins() {
|
public GuiSkins() {
|
||||||
|
instance = this;
|
||||||
|
|
||||||
Minecraft minecraft = Minecraft.getMinecraft();
|
Minecraft minecraft = Minecraft.getMinecraft();
|
||||||
// this.screenTitle = manager;
|
|
||||||
GameProfile profile = minecraft.getSession().getProfile();
|
GameProfile profile = minecraft.getSession().getProfile();
|
||||||
|
|
||||||
this.localPlayer = getModel(profile);
|
localPlayer = getModel(profile);
|
||||||
this.remotePlayer = getModel(profile);
|
remotePlayer = getModel(profile);
|
||||||
RenderManager rm = Minecraft.getMinecraft().getRenderManager();
|
|
||||||
|
RenderManager rm = minecraft.getRenderManager();
|
||||||
rm.renderEngine = minecraft.getTextureManager();
|
rm.renderEngine = minecraft.getTextureManager();
|
||||||
rm.options = minecraft.gameSettings;
|
rm.options = minecraft.gameSettings;
|
||||||
rm.renderViewEntity = this.localPlayer;
|
rm.renderViewEntity = localPlayer;
|
||||||
this.reloadRemoteSkin();
|
|
||||||
this.fetchingSkin = true;
|
|
||||||
|
|
||||||
instance = this;
|
reloadRemoteSkin();
|
||||||
|
|
||||||
|
fetchingSkin = true;
|
||||||
|
|
||||||
panorama = new CubeMap(this);
|
panorama = new CubeMap(this);
|
||||||
initPanorama();
|
initPanorama();
|
||||||
|
@ -126,42 +129,44 @@ public class GuiSkins extends GuiScreen {
|
||||||
if (!(Keyboard.isKeyDown(Keyboard.KEY_LEFT) || Keyboard.isKeyDown(Keyboard.KEY_RIGHT))) {
|
if (!(Keyboard.isKeyDown(Keyboard.KEY_LEFT) || Keyboard.isKeyDown(Keyboard.KEY_RIGHT))) {
|
||||||
updateCounter++;
|
updateCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
panorama.update();
|
panorama.update();
|
||||||
|
|
||||||
this.localPlayer.updateModel();
|
localPlayer.updateModel();
|
||||||
this.remotePlayer.updateModel();
|
remotePlayer.updateModel();
|
||||||
if (this.fetchingSkin && this.remotePlayer.isTextureSetupComplete()) {
|
|
||||||
this.fetchingSkin = false;
|
if (fetchingSkin && remotePlayer.isTextureSetupComplete()) {
|
||||||
this.btnClear.enabled = true;
|
fetchingSkin = false;
|
||||||
|
btnClear.enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (this.skinLock) {
|
synchronized (skinLock) {
|
||||||
if (this.pendingSkinFile != null) {
|
if (pendingSkinFile != null) {
|
||||||
System.out.println("Set " + textureType + " " + this.pendingSkinFile);
|
System.out.println("Set " + textureType + " " + pendingSkinFile);
|
||||||
this.localPlayer.setLocalTexture(this.pendingSkinFile, textureType);
|
localPlayer.setLocalTexture(pendingSkinFile, textureType);
|
||||||
this.selectedSkin = this.pendingSkinFile;
|
selectedSkin = pendingSkinFile;
|
||||||
this.pendingSkinFile = null;
|
pendingSkinFile = null;
|
||||||
this.onSetLocalSkin(textureType);
|
onSetLocalSkin(textureType);
|
||||||
this.btnUpload.enabled = true;
|
btnUpload.enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.pendingRemoteSkinRefresh) {
|
if (pendingRemoteSkinRefresh) {
|
||||||
this.pendingRemoteSkinRefresh = false;
|
pendingRemoteSkinRefresh = false;
|
||||||
this.fetchingSkin = true;
|
fetchingSkin = true;
|
||||||
this.btnClear.enabled = false;
|
btnClear.enabled = false;
|
||||||
this.reloadRemoteSkin();
|
reloadRemoteSkin();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.throttledByMojang) {
|
if (throttledByMojang) {
|
||||||
if (this.refreshCounter == -1) {
|
if (refreshCounter == -1) {
|
||||||
this.refreshCounter = 200;
|
refreshCounter = 200;
|
||||||
} else if (this.refreshCounter > 0) {
|
} else if (refreshCounter > 0) {
|
||||||
--this.refreshCounter;
|
--refreshCounter;
|
||||||
} else {
|
} else {
|
||||||
this.refreshCounter = -1;
|
refreshCounter = -1;
|
||||||
this.throttledByMojang = false;
|
throttledByMojang = false;
|
||||||
this.reloadRemoteSkin();
|
reloadRemoteSkin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,49 +180,45 @@ public class GuiSkins extends GuiScreen {
|
||||||
|
|
||||||
private void reloadRemoteSkin() {
|
private void reloadRemoteSkin() {
|
||||||
try {
|
try {
|
||||||
this.remotePlayer.reloadRemoteSkin(this::onSetRemoteSkin);
|
remotePlayer.reloadRemoteSkin(this::onSetRemoteSkin);
|
||||||
} catch (Exception var2) {
|
} catch (Exception var2) {
|
||||||
var2.printStackTrace();
|
var2.printStackTrace();
|
||||||
this.throttledByMojang = true;
|
throttledByMojang = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
enableDnd();
|
|
||||||
|
|
||||||
panorama.init();
|
|
||||||
|
|
||||||
this.buttonList.clear();
|
|
||||||
this.buttonList.add(this.btnBrowse = new GuiButton(0, 30, this.height - 36, 60, 20, "Browse..."));
|
|
||||||
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.btnModeSkin = new GuiItemStackButton(4, 2, 2, skin));
|
|
||||||
skin = new ItemStack(Items.LEATHER_LEGGINGS);
|
|
||||||
Items.LEATHER_LEGGINGS.setColor(skin, 0xfff500);
|
|
||||||
this.buttonList.add(this.btnModeElytra = new GuiItemStackButton(5, 2, 52, new ItemStack(Items.ELYTRA)));
|
|
||||||
this.buttonList.add(this.btnModeSkinnySkin = new GuiItemStackButton(6, 2, 21, skin));
|
|
||||||
|
|
||||||
this.buttonList.add(this.btnAbout = new GuiButton(-1, this.width - 25, this.height - 25, 20, 20, "?"));
|
|
||||||
|
|
||||||
this.btnUpload.enabled = false;
|
|
||||||
this.btnBrowse.enabled = !this.mc.isFullScreen();
|
|
||||||
|
|
||||||
this.btnModeSkin.enabled = this.thinArmType;
|
|
||||||
this.btnModeSkinnySkin.enabled = !this.thinArmType;
|
|
||||||
this.btnModeElytra.enabled = this.textureType == SKIN;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void enableDnd() {
|
|
||||||
GLWindow.current().setDropTargetListener((FileDropListener) files -> {
|
GLWindow.current().setDropTargetListener((FileDropListener) files -> {
|
||||||
files.stream().findFirst().ifPresent(instance::loadLocalFile);
|
files.stream().findFirst().ifPresent(instance::loadLocalFile);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
panorama.init();
|
||||||
|
|
||||||
|
buttonList.clear();
|
||||||
|
buttonList.add(btnBrowse = new GuiButton(0, 30, height - 36, 60, 20, "Browse..."));
|
||||||
|
buttonList.add(btnUpload = new GuiButton(1, width / 2 - 24, height / 2 - 10, 48, 20, ">>"));
|
||||||
|
buttonList.add(btnClear = new GuiButton(2, width - 90, height - 36, 60, 20, "Clear"));
|
||||||
|
buttonList.add(btnBack = new GuiButton(3, width / 2 - 50, height - 36, 100, 20, "Close"));
|
||||||
|
|
||||||
|
ItemStack skin = new ItemStack(Items.LEATHER_LEGGINGS);
|
||||||
|
Items.LEATHER_LEGGINGS.setColor(skin, 0x3c5dcb);
|
||||||
|
buttonList.add(btnModeSkin = new GuiItemStackButton(4, 2, 2, skin));
|
||||||
|
skin = new ItemStack(Items.LEATHER_LEGGINGS);
|
||||||
|
Items.LEATHER_LEGGINGS.setColor(skin, 0xfff500);
|
||||||
|
buttonList.add(btnModeElytra = new GuiItemStackButton(5, 2, 52, new ItemStack(Items.ELYTRA)));
|
||||||
|
buttonList.add(btnModeSkinnySkin = new GuiItemStackButton(6, 2, 21, skin));
|
||||||
|
|
||||||
|
buttonList.add(btnAbout = new GuiButton(-1, width - 25, height - 25, 20, 20, "?"));
|
||||||
|
|
||||||
|
btnUpload.enabled = false;
|
||||||
|
btnBrowse.enabled = !mc.isFullScreen();
|
||||||
|
|
||||||
|
btnModeSkin.enabled = thinArmType;
|
||||||
|
btnModeSkinnySkin.enabled = !thinArmType;
|
||||||
|
btnModeElytra.enabled = textureType == SKIN;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -225,113 +226,105 @@ public class GuiSkins extends GuiScreen {
|
||||||
super.onGuiClosed();
|
super.onGuiClosed();
|
||||||
localPlayer.releaseTextures();
|
localPlayer.releaseTextures();
|
||||||
remotePlayer.releaseTextures();
|
remotePlayer.releaseTextures();
|
||||||
HDSkinManager.clearSkinCache();
|
HDSkinManager.INSTANCE.clearSkinCache();
|
||||||
|
|
||||||
GLWindow.current().clearDropTargetListener();
|
GLWindow.current().clearDropTargetListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onFileOpenDialogClosed(JFileChooser fileDialog, int dialogResult) {
|
private void onFileOpenDialogClosed(JFileChooser fileDialog, int dialogResult) {
|
||||||
this.openFileThread = null;
|
openFileThread = null;
|
||||||
this.btnBrowse.enabled = true;
|
btnBrowse.enabled = true;
|
||||||
if (dialogResult == 0) {
|
if (dialogResult == 0) {
|
||||||
this.loadLocalFile(fileDialog.getSelectedFile());
|
loadLocalFile(fileDialog.getSelectedFile());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadLocalFile(File skinFile) {
|
private void loadLocalFile(File skinFile) {
|
||||||
Minecraft.getMinecraft().addScheduledTask(localPlayer::releaseTextures);
|
Minecraft.getMinecraft().addScheduledTask(localPlayer::releaseTextures);
|
||||||
|
|
||||||
if (!skinFile.exists()) {
|
if (!skinFile.exists()) {
|
||||||
this.skinMessage = I18n.format("hdskins.error.unreadable");
|
skinMessage = I18n.format("hdskins.error.unreadable");
|
||||||
} else if (!FilenameUtils.isExtension(skinFile.getName(), new String[]{"png", "PNG"})) {
|
} else if (!FilenameUtils.isExtension(skinFile.getName(), new String[]{"png", "PNG"})) {
|
||||||
this.skinMessage = I18n.format("hdskins.error.ext");
|
skinMessage = I18n.format("hdskins.error.ext");
|
||||||
} else {
|
} else {
|
||||||
BufferedImage chosenImage;
|
|
||||||
try {
|
try {
|
||||||
chosenImage = ImageIO.read(skinFile);
|
BufferedImage chosenImage = ImageIO.read(skinFile);
|
||||||
} catch (IOException var6) {
|
|
||||||
this.skinMessage = I18n.format("hdskins.error.open");
|
|
||||||
var6.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chosenImage == null) {
|
if (chosenImage == null) {
|
||||||
this.skinMessage = I18n.format("hdskins.error.open");
|
skinMessage = I18n.format("hdskins.error.open");
|
||||||
} else if (isPowerOfTwo(chosenImage.getWidth())
|
} else if (!acceptsSkinDimensions(chosenImage.getWidth(), chosenImage.getHeight())) {
|
||||||
&& (chosenImage.getWidth() == chosenImage.getHeight() * 2
|
skinMessage = I18n.format("hdskins.error.invalid");
|
||||||
|| chosenImage.getWidth() == chosenImage.getHeight())
|
|
||||||
&& chosenImage.getWidth() <= MAX_SKIN_DIMENSION
|
|
||||||
&& chosenImage.getHeight() <= MAX_SKIN_DIMENSION) {
|
|
||||||
synchronized (this.skinLock) {
|
|
||||||
this.pendingSkinFile = skinFile;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.skinMessage = I18n.format("hdskins.error.invalid");
|
synchronized (skinLock) {
|
||||||
|
pendingSkinFile = skinFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (IOException var6) {
|
||||||
|
skinMessage = I18n.format("hdskins.error.open");
|
||||||
|
var6.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean acceptsSkinDimensions(int w, int h) {
|
||||||
|
return isPowerOfTwo(w) && w == h * 2 || w == h && w <= MAX_SKIN_DIMENSION && h <= MAX_SKIN_DIMENSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void actionPerformed(GuiButton guiButton) {
|
protected void actionPerformed(GuiButton guiButton) {
|
||||||
if (this.openFileThread == null && !this.uploadingSkin) {
|
if (openFileThread == null && !uploadingSkin) {
|
||||||
if (this.uploadError != null) {
|
if (uploadError != null) {
|
||||||
this.uploadError = null;
|
uploadError = null;
|
||||||
} else {
|
} else {
|
||||||
if (guiButton.id == this.btnBrowse.id) {
|
if (guiButton.id == btnBrowse.id) {
|
||||||
this.selectedSkin = null;
|
selectedSkin = null;
|
||||||
this.localPlayer.releaseTextures();
|
localPlayer.releaseTextures();
|
||||||
this.openFileThread = new ThreadOpenFilePNG(this.mc, I18n.format("hdskins.open.title"), this::onFileOpenDialogClosed);
|
openFileThread = new ThreadOpenFilePNG(mc, I18n.format("hdskins.open.title"), this::onFileOpenDialogClosed);
|
||||||
this.openFileThread.start();
|
openFileThread.start();
|
||||||
guiButton.enabled = false;
|
guiButton.enabled = false;
|
||||||
}
|
} else if (guiButton.id == btnUpload.id) {
|
||||||
|
if (selectedSkin != null) {
|
||||||
if (guiButton.id == this.btnUpload.id) {
|
punchServer("hdskins.upload", selectedSkin.toURI());
|
||||||
if (this.selectedSkin != null) {
|
btnUpload.enabled = false;
|
||||||
this.uploadSkin(this.mc.getSession(), this.selectedSkin);
|
|
||||||
this.btnUpload.enabled = false;
|
|
||||||
} else {
|
} else {
|
||||||
this.setUploadError(I18n.format("hdskins.error.select"));
|
setUploadError(I18n.format("hdskins.error.select"));
|
||||||
}
|
}
|
||||||
}
|
} else if (guiButton.id == btnClear.id && remotePlayer.isTextureSetupComplete()) {
|
||||||
|
punchServer("hdskins.request", null);
|
||||||
if (guiButton.id == this.btnClear.id && this.remotePlayer.isTextureSetupComplete()) {
|
btnUpload.enabled = selectedSkin != null;
|
||||||
this.clearUploadedSkin(this.mc.getSession());
|
} else if (guiButton.id == btnBack.id) {
|
||||||
this.btnUpload.enabled = this.selectedSkin != null;
|
mc.displayGuiScreen(new GuiMainMenu());
|
||||||
}
|
} else if (guiButton.id == btnModeSkin.id || guiButton.id == btnModeElytra.id || guiButton.id == btnModeSkinnySkin.id) {
|
||||||
|
|
||||||
if (guiButton.id == this.btnBack.id) {
|
|
||||||
this.mc.displayGuiScreen(new GuiMainMenu());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (guiButton.id == this.btnModeSkin.id || guiButton.id == this.btnModeElytra.id || guiButton.id == this.btnModeSkinnySkin.id) {
|
|
||||||
ItemStack stack;
|
ItemStack stack;
|
||||||
if (guiButton.id == this.btnModeSkin.id) {
|
|
||||||
this.thinArmType = false;
|
if (guiButton.id == btnModeSkin.id) {
|
||||||
this.textureType = SKIN;
|
thinArmType = false;
|
||||||
|
textureType = SKIN;
|
||||||
stack = ItemStack.EMPTY;
|
stack = ItemStack.EMPTY;
|
||||||
} else if (guiButton.id == this.btnModeSkinnySkin.id) {
|
} else if (guiButton.id == btnModeSkinnySkin.id) {
|
||||||
this.thinArmType = true;
|
thinArmType = true;
|
||||||
this.textureType = SKIN;
|
textureType = SKIN;
|
||||||
stack = ItemStack.EMPTY;
|
stack = ItemStack.EMPTY;
|
||||||
} else {
|
} else {
|
||||||
this.textureType = ELYTRA;
|
textureType = ELYTRA;
|
||||||
stack = new ItemStack(Items.ELYTRA);
|
stack = new ItemStack(Items.ELYTRA);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.btnModeSkin.enabled = thinArmType;
|
btnModeSkin.enabled = thinArmType;
|
||||||
this.btnModeSkinnySkin.enabled = !thinArmType;
|
btnModeSkinnySkin.enabled = !thinArmType;
|
||||||
this.btnModeElytra.enabled = this.textureType == SKIN;
|
btnModeElytra.enabled = textureType == SKIN;
|
||||||
|
|
||||||
guiButton.enabled = false;
|
guiButton.enabled = false;
|
||||||
// clear currently selected skin
|
// clear currently selected skin
|
||||||
this.selectedSkin = null;
|
selectedSkin = null;
|
||||||
this.localPlayer.releaseTextures();
|
localPlayer.releaseTextures();
|
||||||
|
|
||||||
// put on or take off the elytra
|
// put on or take off the elytra
|
||||||
this.localPlayer.setItemStackToSlot(EntityEquipmentSlot.CHEST, stack);
|
localPlayer.setItemStackToSlot(EntityEquipmentSlot.CHEST, stack);
|
||||||
this.remotePlayer.setItemStackToSlot(EntityEquipmentSlot.CHEST, stack);
|
remotePlayer.setItemStackToSlot(EntityEquipmentSlot.CHEST, stack);
|
||||||
|
|
||||||
this.localPlayer.setPreviewThinArms(thinArmType);
|
localPlayer.setPreviewThinArms(thinArmType);
|
||||||
this.remotePlayer.setPreviewThinArms(thinArmType);
|
remotePlayer.setPreviewThinArms(thinArmType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -340,16 +333,17 @@ public class GuiSkins extends GuiScreen {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void mouseClicked(int mouseX, int mouseY, int button) throws IOException {
|
protected void mouseClicked(int mouseX, int mouseY, int button) throws IOException {
|
||||||
if (this.uploadError != null) {
|
if (uploadError != null) {
|
||||||
this.uploadError = null;
|
uploadError = null;
|
||||||
} else {
|
} else {
|
||||||
super.mouseClicked(mouseX, mouseY, button);
|
super.mouseClicked(mouseX, mouseY, button);
|
||||||
byte top = 30;
|
|
||||||
int bottom = this.height - 40;
|
int bottom = height - 40;
|
||||||
int mid = this.width / 2;
|
int mid = width / 2;
|
||||||
if ((mouseX > 30 && mouseX < mid - 30 || mouseX > mid + 30 && mouseX < this.width - 30) && mouseY > top && mouseY < bottom) {
|
|
||||||
this.localPlayer.swingArm(EnumHand.MAIN_HAND);
|
if ((mouseX > 30 && mouseX < mid - 30 || mouseX > mid + 30 && mouseX < width - 30) && mouseY > 30 && mouseY < bottom) {
|
||||||
this.remotePlayer.swingArm(EnumHand.MAIN_HAND);
|
localPlayer.swingArm(EnumHand.MAIN_HAND);
|
||||||
|
remotePlayer.swingArm(EnumHand.MAIN_HAND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,15 +352,13 @@ public class GuiSkins extends GuiScreen {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
|
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
|
||||||
|
|
||||||
updateCounter -= (lastMouseX - mouseX);
|
updateCounter -= (lastMouseX - mouseX);
|
||||||
|
|
||||||
lastMouseX = mouseX;
|
lastMouseX = mouseX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void keyTyped(char keyChar, int keyCode) throws IOException {
|
protected void keyTyped(char keyChar, int keyCode) throws IOException {
|
||||||
if (this.openFileThread == null && !this.uploadingSkin) {
|
if (openFileThread == null && !uploadingSkin) {
|
||||||
|
|
||||||
if (keyCode == Keyboard.KEY_LEFT) {
|
if (keyCode == Keyboard.KEY_LEFT) {
|
||||||
updateCounter -= 5;
|
updateCounter -= 5;
|
||||||
|
@ -383,19 +375,17 @@ public class GuiSkins extends GuiScreen {
|
||||||
float deltaTime = panorama.getDelta(partialTick);
|
float deltaTime = panorama.getDelta(partialTick);
|
||||||
panorama.render(partialTick, zLevel);
|
panorama.render(partialTick, zLevel);
|
||||||
|
|
||||||
|
|
||||||
int top = 30;
|
|
||||||
int bottom = height - 40;
|
int bottom = height - 40;
|
||||||
int mid = width / 2;
|
int mid = width / 2;
|
||||||
int horizon = height / 2 + height / 5;
|
int horizon = height / 2 + height / 5;
|
||||||
|
|
||||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||||
|
|
||||||
Gui.drawRect(30, top, mid - 30, bottom, Integer.MIN_VALUE);
|
Gui.drawRect(30, 30, mid - 30, bottom, Integer.MIN_VALUE);
|
||||||
Gui.drawRect(mid + 30, top, width - 30, bottom, Integer.MIN_VALUE);
|
Gui.drawRect(mid + 30, 30, width - 30, bottom, Integer.MIN_VALUE);
|
||||||
|
|
||||||
drawGradientRect(30, horizon, mid - 30, bottom, 0x80FFFFFF, 0xffffff);
|
drawGradientRect(30, horizon, mid - 30, bottom, 0x80FFFFFF, 0xffffff);
|
||||||
drawGradientRect(mid + 30, horizon, this.width - 30, bottom, 0x80FFFFFF, 0xffffff);
|
drawGradientRect(mid + 30, horizon, width - 30, bottom, 0x80FFFFFF, 0xffffff);
|
||||||
|
|
||||||
super.drawScreen(mouseX, mouseY, partialTick);
|
super.drawScreen(mouseX, mouseY, partialTick);
|
||||||
|
|
||||||
|
@ -403,22 +393,22 @@ public class GuiSkins extends GuiScreen {
|
||||||
enableClipping(bottom);
|
enableClipping(bottom);
|
||||||
|
|
||||||
float yPos = height * 0.75F;
|
float yPos = height * 0.75F;
|
||||||
float xPos1 = width * 0.25F;
|
float xPos1 = width / 4;
|
||||||
float xPos2 = width * 0.75F;
|
float xPos2 = width * 0.75F;
|
||||||
float scale = height * 0.25F;
|
float scale = height / 4;
|
||||||
float lookX = mid - mouseX;
|
float lookX = mid - mouseX;
|
||||||
|
|
||||||
mc.getTextureManager().bindTexture(localPlayer.getSkinTexture());
|
mc.getTextureManager().bindTexture(localPlayer.getLocal(Type.SKIN).getTexture());
|
||||||
|
|
||||||
renderPlayerModel(localPlayer, xPos1, yPos, scale, horizon - mouseY, lookX, partialTick);
|
renderPlayerModel(localPlayer, xPos1, yPos, scale, horizon - mouseY, lookX, partialTick);
|
||||||
|
|
||||||
mc.getTextureManager().bindTexture(remotePlayer.getSkinTexture());
|
mc.getTextureManager().bindTexture(remotePlayer.getLocal(Type.SKIN).getTexture());
|
||||||
|
|
||||||
renderPlayerModel(remotePlayer, xPos2, yPos, scale, horizon - mouseY, lookX, partialTick);
|
renderPlayerModel(remotePlayer, xPos2, yPos, scale, horizon - mouseY, lookX, partialTick);
|
||||||
|
|
||||||
disableClipping();
|
disableClipping();
|
||||||
|
|
||||||
drawCenteredString(this.fontRenderer, I18n.format("hdskins.manager"), width / 2, 10, 0xffffff);
|
drawCenteredString(fontRenderer, I18n.format("hdskins.manager"), width / 2, 10, 0xffffff);
|
||||||
|
|
||||||
fontRenderer.drawStringWithShadow(I18n.format("hdskins.local"), 34, 34, 0xffffff);
|
fontRenderer.drawStringWithShadow(I18n.format("hdskins.local"), 34, 34, 0xffffff);
|
||||||
fontRenderer.drawStringWithShadow(I18n.format("hdskins.server"), width / 2 + 34, 34, 0xffffff);
|
fontRenderer.drawStringWithShadow(I18n.format("hdskins.server"), width / 2 + 34, 34, 0xffffff);
|
||||||
|
@ -427,110 +417,98 @@ public class GuiSkins extends GuiScreen {
|
||||||
enableBlend();
|
enableBlend();
|
||||||
depthMask(false);
|
depthMask(false);
|
||||||
|
|
||||||
// this is here so the next few things get blended properly
|
if (!localPlayer.isUsingLocalTexture()) {
|
||||||
//Gui.drawRect(0, 0, 1, 1, 0);
|
int opacity = fontRenderer.getStringWidth(skinMessage) / 2;
|
||||||
//this.drawGradientRect(30, this.height - 60, mid - 30, bottom, 1, 0xe0ffffff);
|
|
||||||
//this.drawGradientRect(mid + 30, this.height - 60, this.width - 30, bottom, 0, 0xE0FFFFFF);
|
|
||||||
|
|
||||||
int labelwidth = (this.width / 2 - 80) / 2;
|
Gui.drawRect(40, height / 2 - 12, width / 2 - 40, height / 2 + 12, 0xB0000000);
|
||||||
if (!this.localPlayer.isUsingLocalTexture()) {
|
fontRenderer.drawStringWithShadow(skinMessage, (int) (xPos1 - opacity), height / 2 - 4, 0xffffff);
|
||||||
int opacity = this.fontRenderer.getStringWidth(this.skinMessage) / 2;
|
|
||||||
Gui.drawRect(40, this.height / 2 - 12, this.width / 2 - 40, this.height / 2 + 12, 0xB0000000);
|
|
||||||
this.fontRenderer.drawStringWithShadow(this.skinMessage, (int) (xPos1 - opacity), this.height / 2 - 4, 0xffffff);
|
|
||||||
}
|
}
|
||||||
if (this.btnModeSkin.isMouseOver() || this.btnModeElytra.isMouseOver() || this.btnModeSkinnySkin.isMouseOver()) {
|
if (btnModeSkin.isMouseOver() || btnModeElytra.isMouseOver() || btnModeSkinnySkin.isMouseOver()) {
|
||||||
int y = Math.max(mouseY, 16);
|
int y = Math.max(mouseY, 16);
|
||||||
String text;
|
String text;
|
||||||
if (this.btnModeSkin.isMouseOver()) {
|
|
||||||
|
if (btnModeSkin.isMouseOver()) {
|
||||||
text = "hdskins.mode.skin";
|
text = "hdskins.mode.skin";
|
||||||
} else if (this.btnModeSkinnySkin.isMouseOver()) {
|
} else if (btnModeSkinnySkin.isMouseOver()) {
|
||||||
text = "hdskins.mode.skinny";
|
text = "hdskins.mode.skinny";
|
||||||
} else {
|
} else {
|
||||||
text = "hdskins.mode.elytra";
|
text = "hdskins.mode.elytra";
|
||||||
}
|
}
|
||||||
this.drawHoveringText(I18n.format(text), mouseX, y);
|
|
||||||
}
|
drawHoveringText(I18n.format(text), mouseX, y);
|
||||||
if (this.btnAbout.isMouseOver()) {
|
|
||||||
SkinServer gateway = HDSkinManager.INSTANCE.getGatewayServer();
|
|
||||||
this.drawHoveringText(Splitter.on("\r\n").splitToList(gateway.toString()), mouseX, mouseY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.fetchingSkin) {
|
if (btnAbout.isMouseOver()) {
|
||||||
String opacity1;
|
drawHoveringText(Splitter.on("\r\n").splitToList(HDSkinManager.INSTANCE.getGatewayServer().toString()), mouseX, mouseY);
|
||||||
if (this.throttledByMojang) {
|
}
|
||||||
opacity1 = TextFormatting.RED + I18n.format("hdskins.error.mojang");
|
|
||||||
String stringWidth = I18n.format("hdskins.error.mojang.wait");
|
|
||||||
int stringWidth1 = this.fontRenderer.getStringWidth(opacity1) / 2;
|
|
||||||
int stringWidth2 = this.fontRenderer.getStringWidth(stringWidth) / 2;
|
|
||||||
|
|
||||||
Gui.drawRect((int) (xPos2 - labelwidth), this.height / 2 - 16, this.width - 40, this.height / 2 + 16, 0xB0000000);
|
if (fetchingSkin) {
|
||||||
|
|
||||||
this.fontRenderer.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), this.height / 2 - 10, 0xffffff);
|
int lineHeight = throttledByMojang ? 16 : 12;
|
||||||
this.fontRenderer.drawStringWithShadow(stringWidth, (int) (xPos2 - stringWidth2), this.height / 2 + 2, 0xffffff);
|
|
||||||
|
Gui.drawRect((int) (xPos2 - width / 4 + 40), height / 2 - lineHeight, width - 40, height / 2 + lineHeight, 0xB0000000);
|
||||||
|
|
||||||
|
if (throttledByMojang) {
|
||||||
|
drawCenteredString(fontRenderer, I18n.format("hdskins.error.mojang"), (int)xPos2, height / 2 - 10, 0xffffff);
|
||||||
|
drawCenteredString(fontRenderer, I18n.format("hdskins.error.mojang.wait"), (int)xPos2, height / 2 + 2, 0xffffff);
|
||||||
} else {
|
} else {
|
||||||
opacity1 = I18n.format("hdskins.fetch");
|
drawCenteredString(fontRenderer, I18n.format("hdskins.fetch"), (int)xPos2, height / 2 - 4, 0xffffff);
|
||||||
int stringWidth1 = this.fontRenderer.getStringWidth(opacity1) / 2;
|
|
||||||
Gui.drawRect((int) (xPos2 - labelwidth), this.height / 2 - 12, this.width - 40, this.height / 2 + 12, 0xB0000000);
|
|
||||||
this.fontRenderer.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), this.height / 2 - 4, 0xffffff);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.uploadingSkin || this.uploadOpacity > 0.0F) {
|
if (uploadingSkin || uploadOpacity > 0) {
|
||||||
if (!this.uploadingSkin) {
|
if (!uploadingSkin) {
|
||||||
this.uploadOpacity -= deltaTime * 0.05F;
|
uploadOpacity -= deltaTime / 20;
|
||||||
} else if (this.uploadOpacity < 1.0F) {
|
} else if (uploadOpacity < 1) {
|
||||||
this.uploadOpacity += deltaTime * 0.1F;
|
uploadOpacity += deltaTime / 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.uploadOpacity > 1.0F) {
|
if (uploadOpacity > 1) {
|
||||||
this.uploadOpacity = 1.0F;
|
uploadOpacity = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int opacity = Math.min(180, (int) (this.uploadOpacity * 180.0F)) & 255;
|
int opacity = Math.min(180, (int) (uploadOpacity * 180)) & 255;
|
||||||
if (this.uploadOpacity > 0.0F) {
|
if (uploadOpacity > 0) {
|
||||||
Gui.drawRect(0, 0, this.width, this.height, opacity << 24);
|
Gui.drawRect(0, 0, width, height, opacity << 24);
|
||||||
if (this.uploadingSkin) {
|
if (uploadingSkin) {
|
||||||
this.drawCenteredString(this.fontRenderer, this.skinUploadMessage, this.width / 2, this.height / 2, opacity << 24 | 0xffffff);
|
drawCenteredString(fontRenderer, skinUploadMessage, width / 2, height / 2, opacity << 24 | 0xffffff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.uploadError != null) {
|
if (uploadError != null) {
|
||||||
Gui.drawRect(0, 0, this.width, this.height, 0xB0000000);
|
Gui.drawRect(0, 0, width, height, 0xB0000000);
|
||||||
this.drawCenteredString(this.fontRenderer, I18n.format("hdskins.failed"), this.width / 2, this.height / 2 - 10, 0xFFFFFF55);
|
drawCenteredString(fontRenderer, I18n.format("hdskins.failed"), width / 2, height / 2 - 10, 0xFFFFFF55);
|
||||||
this.drawCenteredString(this.fontRenderer, this.uploadError, this.width / 2, this.height / 2 + 2, 0xFFFF5555);
|
drawCenteredString(fontRenderer, uploadError, width / 2, height / 2 + 2, 0xFFFF5555);
|
||||||
}
|
}
|
||||||
|
|
||||||
depthMask(true);
|
depthMask(true);
|
||||||
enableDepth();
|
enableDepth();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderPlayerModel(EntityPlayerModel thePlayer, float xPosition, float yPosition, float scale, float mouseY, float mouseX,
|
private void renderPlayerModel(EntityPlayerModel thePlayer, float xPosition, float yPosition, float scale, float mouseY, float mouseX, float partialTick) {
|
||||||
float partialTick) {
|
|
||||||
enableColorMaterial();
|
enableColorMaterial();
|
||||||
pushMatrix();
|
pushMatrix();
|
||||||
translate(xPosition, yPosition, 300.0F);
|
translate(xPosition, yPosition, 300);
|
||||||
|
|
||||||
scale(-scale, scale, scale);
|
scale(-scale, scale, scale);
|
||||||
rotate(180.0F, 0.0F, 0.0F, 1.0F);
|
rotate(180, 0, 0, 1);
|
||||||
rotate(135.0F, 0.0F, 1.0F, 0.0F);
|
rotate(135, 0, 1, 0);
|
||||||
|
|
||||||
RenderHelper.enableStandardItemLighting();
|
RenderHelper.enableStandardItemLighting();
|
||||||
|
|
||||||
rotate(-135.0F, 0.0F, 1.0F, 0.0F);
|
rotate(-135, 0, 1, 0);
|
||||||
rotate(15.0F, 1.0F, 0.0F, 0.0F);
|
rotate(15, 1, 0, 0);
|
||||||
|
|
||||||
float rot = ((updateCounter + partialTick) * 2.5F) % 360;
|
rotate(((updateCounter + partialTick) * 2.5F) % 360, 0, 1, 0);
|
||||||
|
|
||||||
rotate(rot, 0, 1, 0);
|
thePlayer.rotationYawHead = (float)Math.atan(mouseX / 20) * 30;
|
||||||
|
thePlayer.rotationPitch = (float)Math.atan(mouseY / 40) * -20;
|
||||||
|
|
||||||
thePlayer.rotationYawHead = ((float) Math.atan(mouseX / 20)) * 30;
|
translate(0, thePlayer.getYOffset(), 0);
|
||||||
|
|
||||||
thePlayer.rotationPitch = -((float) Math.atan(mouseY / 40)) * 20;
|
|
||||||
translate(0.0D, thePlayer.getYOffset(), 0.0D);
|
|
||||||
|
|
||||||
RenderManager rm = Minecraft.getMinecraft().getRenderManager();
|
RenderManager rm = Minecraft.getMinecraft().getRenderManager();
|
||||||
rm.playerViewY = 180.0F;
|
rm.playerViewY = 180;
|
||||||
rm.renderEntity(thePlayer, 0, 0, 0, 0, 1, false);
|
rm.renderEntity(thePlayer, 0, 0, 0, 0, 1, false);
|
||||||
|
|
||||||
popMatrix();
|
popMatrix();
|
||||||
|
@ -539,18 +517,18 @@ public class GuiSkins extends GuiScreen {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableClipping(int yBottom) {
|
private void enableClipping(int yBottom) {
|
||||||
if (this.doubleBuffer == null) {
|
if (doubleBuffer == null) {
|
||||||
this.doubleBuffer = BufferUtils.createByteBuffer(32).asDoubleBuffer();
|
doubleBuffer = BufferUtils.createByteBuffer(32).asDoubleBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.doubleBuffer.clear();
|
doubleBuffer.clear();
|
||||||
this.doubleBuffer.put(0.0D).put(1.0D).put(0.0D).put((-30)).flip();
|
doubleBuffer.put(0).put(1).put(0).put(-30).flip();
|
||||||
|
|
||||||
GL11.glClipPlane(GL11.GL_CLIP_PLANE0, this.doubleBuffer);
|
GL11.glClipPlane(GL11.GL_CLIP_PLANE0, doubleBuffer);
|
||||||
this.doubleBuffer.clear();
|
doubleBuffer.clear();
|
||||||
this.doubleBuffer.put(0.0D).put(-1.0D).put(0.0D).put(yBottom).flip();
|
doubleBuffer.put(0).put(-1).put(0).put(yBottom).flip();
|
||||||
|
|
||||||
GL11.glClipPlane(GL11.GL_CLIP_PLANE1, this.doubleBuffer);
|
GL11.glClipPlane(GL11.GL_CLIP_PLANE1, doubleBuffer);
|
||||||
GL11.glEnable(GL11.GL_CLIP_PLANE0);
|
GL11.glEnable(GL11.GL_CLIP_PLANE0);
|
||||||
GL11.glEnable(GL11.GL_CLIP_PLANE1);
|
GL11.glEnable(GL11.GL_CLIP_PLANE1);
|
||||||
}
|
}
|
||||||
|
@ -564,47 +542,38 @@ public class GuiSkins extends GuiScreen {
|
||||||
return number != 0 && (number & number - 1) == 0;
|
return number != 0 && (number & number - 1) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearUploadedSkin(Session session) {
|
private void punchServer(String uploadMsg, @Nullable URI path) {
|
||||||
this.uploadingSkin = true;
|
uploadingSkin = true;
|
||||||
this.skinUploadMessage = I18n.format("hdskins.request");
|
skinUploadMessage = I18n.format(uploadMsg);
|
||||||
HDSkinManager.INSTANCE.getGatewayServer()
|
|
||||||
.uploadSkin(session, new SkinUpload(this.textureType, null, getMetadata()))
|
|
||||||
.thenAccept(this::onUploadComplete)
|
|
||||||
.exceptionally(this::onFailure);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void uploadSkin(Session session, @Nullable File skinFile) {
|
|
||||||
this.uploadingSkin = true;
|
|
||||||
this.skinUploadMessage = I18n.format("hdskins.upload");
|
|
||||||
URI path = skinFile == null ? null : skinFile.toURI();
|
|
||||||
HDSkinManager.INSTANCE.getGatewayServer()
|
HDSkinManager.INSTANCE.getGatewayServer()
|
||||||
.uploadSkin(session, new SkinUpload(this.textureType, path, getMetadata()))
|
.uploadSkin(mc.getSession(), new SkinUpload(textureType, path, getMetadata()))
|
||||||
.thenAccept(this::onUploadComplete)
|
.thenAccept(this::onUploadComplete)
|
||||||
.exceptionally(this::onFailure);
|
.exceptionally(this::onUploadFailure);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> getMetadata() {
|
private Map<String, String> getMetadata() {
|
||||||
return ImmutableMap.of("model", this.thinArmType ? "slim" : "default");
|
return ImmutableMap.of("model", thinArmType ? "slim" : "default");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUploadError(@Nullable String error) {
|
private void setUploadError(@Nullable String error) {
|
||||||
this.uploadError = error;
|
uploadError = error;
|
||||||
this.btnUpload.enabled = true;
|
btnUpload.enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Void onFailure(Throwable t) {
|
private Void onUploadFailure(Throwable t) {
|
||||||
t = Throwables.getRootCause(t);
|
t = Throwables.getRootCause(t);
|
||||||
LogManager.getLogger().warn("Upload failed", t);
|
LogManager.getLogger().warn("Upload failed", t);
|
||||||
this.setUploadError(t.toString());
|
setUploadError(t.toString());
|
||||||
this.uploadingSkin = false;
|
uploadingSkin = false;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onUploadComplete(SkinUploadResponse response) {
|
private void onUploadComplete(SkinUploadResponse response) {
|
||||||
LiteLoaderLogger.info("Upload completed with: %s", response);
|
LiteLoaderLogger.info("Upload completed with: %s", response);
|
||||||
this.uploadingSkin = false;
|
uploadingSkin = false;
|
||||||
this.pendingRemoteSkinRefresh = true;
|
pendingRemoteSkinRefresh = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
|
@ -16,6 +16,8 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||||
|
@ -31,7 +33,7 @@ public class RenderPlayerModel<M extends EntityPlayerModel> extends RenderLiving
|
||||||
private static final ModelPlayer THIN = new ModelPlayer(0, true);
|
private static final ModelPlayer THIN = new ModelPlayer(0, true);
|
||||||
|
|
||||||
public RenderPlayerModel(RenderManager renderer) {
|
public RenderPlayerModel(RenderManager renderer) {
|
||||||
super(renderer, FAT, 0.0F);
|
super(renderer, FAT, 0);
|
||||||
this.addLayer(this.getElytraLayer());
|
this.addLayer(this.getElytraLayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,14 +46,14 @@ public class RenderPlayerModel<M extends EntityPlayerModel> extends RenderLiving
|
||||||
ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||||
|
|
||||||
if (itemstack.getItem() == Items.ELYTRA) {
|
if (itemstack.getItem() == Items.ELYTRA) {
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
GlStateManager.color(1, 1, 1, 1);
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||||
|
|
||||||
bindTexture(entity.getElytraTexture());
|
bindTexture(entity.getLocal(Type.ELYTRA).getTexture());
|
||||||
|
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
GlStateManager.translate(0.0F, 0.0F, 0.125F);
|
GlStateManager.translate(0, 0, 0.125F);
|
||||||
|
|
||||||
modelElytra.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entity);
|
modelElytra.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entity);
|
||||||
modelElytra.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
|
modelElytra.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
|
||||||
|
@ -69,18 +71,18 @@ public class RenderPlayerModel<M extends EntityPlayerModel> extends RenderLiving
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ResourceLocation getEntityTexture(M var1) {
|
protected ResourceLocation getEntityTexture(M entity) {
|
||||||
return var1.getSkinTexture();
|
return entity.getLocal(Type.SKIN).getTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canRenderName(M targetEntity) {
|
protected boolean canRenderName(M entity) {
|
||||||
return Minecraft.getMinecraft().player != null && super.canRenderName(targetEntity);
|
return Minecraft.getMinecraft().player != null && super.canRenderName(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean setBrightness(M entitylivingbaseIn, float partialTicks, boolean p_177092_3_) {
|
protected boolean setBrightness(M entity, float partialTicks, boolean combineTextures) {
|
||||||
return Minecraft.getMinecraft().world != null && super.setBrightness(entitylivingbaseIn, partialTicks, p_177092_3_);
|
return Minecraft.getMinecraft().world != null && super.setBrightness(entity, partialTicks, combineTextures);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelPlayer getEntityModel(M entity) {
|
public ModelPlayer getEntityModel(M entity) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.minelittlepony.hdskins.gui;
|
package com.minelittlepony.hdskins.gui;
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
|
import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
@ -20,19 +21,22 @@ public class EntityPonyModel extends EntityPlayerModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ResourceLocation getBlankSkin() {
|
public ResourceLocation getBlankSkin(Type type) {
|
||||||
|
if (type == Type.SKIN) {
|
||||||
return wet ? NO_SKIN_SEAPONY : NO_SKIN_PONY;
|
return wet ? NO_SKIN_SEAPONY : NO_SKIN_PONY;
|
||||||
}
|
}
|
||||||
|
return super.getBlankSkin(type);
|
||||||
|
}
|
||||||
|
|
||||||
public void setWet(boolean wet) {
|
public void setWet(boolean wet) {
|
||||||
this.wet = wet;
|
this.wet = wet;
|
||||||
|
|
||||||
if (wet && localSkinResource == NO_SKIN_PONY) {
|
if (wet && skin.getTexture() == NO_SKIN_PONY) {
|
||||||
localSkinResource = NO_SKIN_SEAPONY;
|
skin.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wet && localSkinResource == NO_SKIN_SEAPONY) {
|
if (!wet && skin.getTexture() == NO_SKIN_SEAPONY) {
|
||||||
localSkinResource = NO_SKIN_PONY;
|
skin.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class GuiSkinsMineLP extends GuiSkins {
|
||||||
protected void onSetLocalSkin(Type type) {
|
protected void onSetLocalSkin(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 == Type.SKIN) {
|
if (type == Type.SKIN) {
|
||||||
ponyManager.removePony(localPlayer.getSkinTexture());
|
ponyManager.removePony(localPlayer.getLocal(Type.SKIN).getTexture());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.minelittlepony.pony.data.Pony;
|
||||||
import com.minelittlepony.pony.data.PonyRace;
|
import com.minelittlepony.pony.data.PonyRace;
|
||||||
import com.minelittlepony.render.layer.LayerPonyElytra;
|
import com.minelittlepony.render.layer.LayerPonyElytra;
|
||||||
import com.minelittlepony.render.RenderPony;
|
import com.minelittlepony.render.RenderPony;
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
import com.voxelmodpack.hdskins.gui.RenderPlayerModel;
|
import com.voxelmodpack.hdskins.gui.RenderPlayerModel;
|
||||||
|
|
||||||
import net.minecraft.client.model.ModelBase;
|
import net.minecraft.client.model.ModelBase;
|
||||||
|
@ -77,7 +78,7 @@ public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel> implemen
|
||||||
return super.getEntityModel(playermodel);
|
return super.getEntityModel(playermodel);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean canWet = playermodel.wet && (loc == playermodel.getBlankSkin() || race == PonyRace.SEAPONY);
|
boolean canWet = playermodel.wet && (loc == playermodel.getBlankSkin(Type.SKIN) || race == PonyRace.SEAPONY);
|
||||||
|
|
||||||
playerModel = canWet ? PlayerModels.SEAPONY.getModel(slim) : thePony.getModel(true);
|
playerModel = canWet ? PlayerModels.SEAPONY.getModel(slim) : thePony.getModel(true);
|
||||||
playerModel.apply(thePony.getMetadata());
|
playerModel.apply(thePony.getMetadata());
|
||||||
|
@ -108,7 +109,7 @@ public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel> implemen
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ResourceLocation getElytraTexture(EntityPonyModel entity) {
|
protected ResourceLocation getElytraTexture(EntityPonyModel entity) {
|
||||||
return entity.getElytraTexture();
|
return entity.getLocal(Type.ELYTRA).getTexture();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue