The problem childs

This commit is contained in:
Sollace 2018-08-01 12:00:27 +02:00
parent e6f5d3caa6
commit bf83ff68ae
19 changed files with 389 additions and 353 deletions

View file

@ -123,7 +123,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
return Optional.empty(); return Optional.empty();
} }
ResourceLocation skin = this.resources.getPlayerTexture(profile1, type); ResourceLocation skin = resources.getPlayerTexture(profile1, type);
if (skin != null) { if (skin != null) {
return Optional.of(skin); return Optional.of(skin);
} }
@ -156,11 +156,11 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
return Optional.empty(); return Optional.empty();
} }
if (!this.skinCache.containsKey(profile.getId())) { if (!skinCache.containsKey(profile.getId())) {
this.skinCache.put(profile.getId(), Maps.newHashMap()); skinCache.put(profile.getId(), Maps.newHashMap());
} }
skin = this.skinCache.get(profile.getId()).get(type); skin = skinCache.get(profile.getId()).get(type);
if (skin == null) { if (skin == null) {
if (loadIfAbsent && getProfileData(profile).containsKey(type)) { if (loadIfAbsent && getProfileData(profile).containsKey(type)) {
skinCache.get(profile.getId()).put(type, LOADING); skinCache.get(profile.getId()).put(type, LOADING);
@ -243,20 +243,20 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
if (st == null) { if (st == null) {
throw new IllegalArgumentException("class is not annotated with @ServerType"); throw new IllegalArgumentException("class is not annotated with @ServerType");
} }
this.skinServerTypes.put(st.value(), type); skinServerTypes.put(st.value(), type);
} }
public Class<? extends SkinServer> getSkinServerClass(String type) { public Class<? extends SkinServer> getSkinServerClass(String type) {
return this.skinServerTypes.get(type); return skinServerTypes.get(type);
} }
public void addSkinServer(SkinServer skinServer) { public void addSkinServer(SkinServer skinServer) {
this.skinServers.add(skinServer); skinServers.add(skinServer);
} }
@Deprecated @Deprecated
public SkinServer getGatewayServer() { public SkinServer getGatewayServer() {
return this.skinServers.get(0); return skinServers.get(0);
} }
public void setEnabled(boolean enabled) { public void setEnabled(boolean enabled) {
@ -319,6 +319,6 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
@Override @Override
public void onResourceManagerReload(IResourceManager resourceManager) { public void onResourceManagerReload(IResourceManager resourceManager) {
this.resources.onResourceManagerReload(resourceManager); resources.onResourceManagerReload(resourceManager);
} }
} }

View file

@ -96,14 +96,14 @@ public class GuiSkins extends GuiScreen {
// this.screenTitle = manager; // 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.getMinecraft().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(); reloadRemoteSkin();
this.fetchingSkin = true; fetchingSkin = true;
instance = this; instance = this;
@ -127,40 +127,40 @@ public class GuiSkins extends GuiScreen {
} }
panorama.update(); panorama.update();
this.localPlayer.updateModel(); localPlayer.updateModel();
this.remotePlayer.updateModel(); remotePlayer.updateModel();
if (this.fetchingSkin && this.remotePlayer.isTextureSetupComplete()) { if (fetchingSkin && remotePlayer.isTextureSetupComplete()) {
this.fetchingSkin = false; fetchingSkin = false;
this.btnClear.enabled = true; 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();
} }
} }
@ -174,10 +174,10 @@ 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;
} }
} }
@ -188,28 +188,28 @@ public class GuiSkins extends GuiScreen {
panorama.init(); panorama.init();
this.buttonList.clear(); buttonList.clear();
this.buttonList.add(this.btnBrowse = new GuiButton(0, 30, this.height - 36, 60, 20, "Browse...")); buttonList.add(btnBrowse = new GuiButton(0, 30, height - 36, 60, 20, "Browse..."));
this.buttonList.add(this.btnUpload = new GuiButton(1, this.width / 2 - 24, this.height / 2 - 10, 48, 20, ">>")); buttonList.add(btnUpload = new GuiButton(1, width / 2 - 24, height / 2 - 10, 48, 20, ">>"));
this.buttonList.add(this.btnClear = new GuiButton(2, this.width - 90, this.height - 36, 60, 20, "Clear")); buttonList.add(btnClear = new GuiButton(2, width - 90, height - 36, 60, 20, "Clear"));
this.buttonList.add(this.btnBack = new GuiButton(3, this.width / 2 - 50, this.height - 36, 100, 20, "Close")); buttonList.add(btnBack = new GuiButton(3, width / 2 - 50, height - 36, 100, 20, "Close"));
ItemStack skin = new ItemStack(Items.LEATHER_LEGGINGS); ItemStack skin = new ItemStack(Items.LEATHER_LEGGINGS);
Items.LEATHER_LEGGINGS.setColor(skin, 0x3c5dcb); Items.LEATHER_LEGGINGS.setColor(skin, 0x3c5dcb);
this.buttonList.add(this.btnModeSkin = new GuiItemStackButton(4, 2, 2, skin)); buttonList.add(btnModeSkin = new GuiItemStackButton(4, 2, 2, skin));
skin = new ItemStack(Items.LEATHER_LEGGINGS); skin = new ItemStack(Items.LEATHER_LEGGINGS);
Items.LEATHER_LEGGINGS.setColor(skin, 0xfff500); Items.LEATHER_LEGGINGS.setColor(skin, 0xfff500);
this.buttonList.add(this.btnModeElytra = new GuiItemStackButton(5, 2, 52, new ItemStack(Items.ELYTRA))); buttonList.add(btnModeElytra = new GuiItemStackButton(5, 2, 52, new ItemStack(Items.ELYTRA)));
this.buttonList.add(this.btnModeSkinnySkin = new GuiItemStackButton(6, 2, 21, skin)); buttonList.add(btnModeSkinnySkin = new GuiItemStackButton(6, 2, 21, skin));
this.buttonList.add(this.btnAbout = new GuiButton(-1, this.width - 25, this.height - 25, 20, 20, "?")); buttonList.add(btnAbout = new GuiButton(-1, width - 25, height - 25, 20, 20, "?"));
this.btnUpload.enabled = false; btnUpload.enabled = false;
this.btnBrowse.enabled = !this.mc.isFullScreen(); btnBrowse.enabled = !mc.isFullScreen();
this.btnModeSkin.enabled = this.thinArmType; btnModeSkin.enabled = thinArmType;
this.btnModeSkinnySkin.enabled = !this.thinArmType; btnModeSkinnySkin.enabled = !thinArmType;
this.btnModeElytra.enabled = this.textureType == SKIN; btnModeElytra.enabled = textureType == SKIN;
} }
@ -230,107 +230,107 @@ public class GuiSkins extends GuiScreen {
} }
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; BufferedImage chosenImage;
try { try {
chosenImage = ImageIO.read(skinFile); chosenImage = ImageIO.read(skinFile);
} catch (IOException var6) { } catch (IOException var6) {
this.skinMessage = I18n.format("hdskins.error.open"); skinMessage = I18n.format("hdskins.error.open");
var6.printStackTrace(); var6.printStackTrace();
return; 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 (isPowerOfTwo(chosenImage.getWidth())
&& (chosenImage.getWidth() == chosenImage.getHeight() * 2 && (chosenImage.getWidth() == chosenImage.getHeight() * 2
|| chosenImage.getWidth() == chosenImage.getHeight()) || chosenImage.getWidth() == chosenImage.getHeight())
&& chosenImage.getWidth() <= MAX_SKIN_DIMENSION && chosenImage.getWidth() <= MAX_SKIN_DIMENSION
&& chosenImage.getHeight() <= MAX_SKIN_DIMENSION) { && chosenImage.getHeight() <= MAX_SKIN_DIMENSION) {
synchronized (this.skinLock) { synchronized (skinLock) {
this.pendingSkinFile = skinFile; pendingSkinFile = skinFile;
} }
} else { } else {
this.skinMessage = I18n.format("hdskins.error.invalid"); skinMessage = I18n.format("hdskins.error.invalid");
} }
} }
} }
@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;
} }
if (guiButton.id == this.btnUpload.id) { if (guiButton.id == btnUpload.id) {
if (this.selectedSkin != null) { if (selectedSkin != null) {
this.uploadSkin(this.mc.getSession(), this.selectedSkin); uploadSkin(mc.getSession(), selectedSkin);
this.btnUpload.enabled = false; btnUpload.enabled = false;
} else { } else {
this.setUploadError(I18n.format("hdskins.error.select")); setUploadError(I18n.format("hdskins.error.select"));
} }
} }
if (guiButton.id == this.btnClear.id && this.remotePlayer.isTextureSetupComplete()) { if (guiButton.id == btnClear.id && remotePlayer.isTextureSetupComplete()) {
this.clearUploadedSkin(this.mc.getSession()); clearUploadedSkin(mc.getSession());
this.btnUpload.enabled = this.selectedSkin != null; btnUpload.enabled = selectedSkin != null;
} }
if (guiButton.id == this.btnBack.id) { if (guiButton.id == btnBack.id) {
this.mc.displayGuiScreen(new GuiMainMenu()); mc.displayGuiScreen(new GuiMainMenu());
} }
if (guiButton.id == this.btnModeSkin.id || guiButton.id == this.btnModeElytra.id || guiButton.id == this.btnModeSkinnySkin.id) { if (guiButton.id == btnModeSkin.id || guiButton.id == btnModeElytra.id || guiButton.id == btnModeSkinnySkin.id) {
ItemStack stack; ItemStack stack;
if (guiButton.id == this.btnModeSkin.id) { if (guiButton.id == btnModeSkin.id) {
this.thinArmType = false; thinArmType = false;
this.textureType = SKIN; 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);
} }
} }
@ -339,16 +339,16 @@ 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; 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) { if ((mouseX > 30 && mouseX < mid - 30 || mouseX > mid + 30 && mouseX < width - 30) && mouseY > top && mouseY < bottom) {
this.localPlayer.swingArm(EnumHand.MAIN_HAND); localPlayer.swingArm(EnumHand.MAIN_HAND);
this.remotePlayer.swingArm(EnumHand.MAIN_HAND); remotePlayer.swingArm(EnumHand.MAIN_HAND);
} }
} }
@ -358,14 +358,14 @@ 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;
@ -394,7 +394,7 @@ public class GuiSkins extends GuiScreen {
Gui.drawRect(mid + 30, top, width - 30, bottom, Integer.MIN_VALUE); Gui.drawRect(mid + 30, top, 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);
@ -417,7 +417,7 @@ public class GuiSkins extends GuiScreen {
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);
@ -431,73 +431,73 @@ public class GuiSkins extends GuiScreen {
//this.drawGradientRect(30, this.height - 60, mid - 30, bottom, 1, 0xe0ffffff); //this.drawGradientRect(30, this.height - 60, mid - 30, bottom, 1, 0xe0ffffff);
//this.drawGradientRect(mid + 30, this.height - 60, this.width - 30, bottom, 0, 0xE0FFFFFF); //this.drawGradientRect(mid + 30, this.height - 60, this.width - 30, bottom, 0, 0xE0FFFFFF);
int labelwidth = (this.width / 2 - 80) / 2; int labelwidth = (width / 2 - 80) / 2;
if (!this.localPlayer.isUsingLocalTexture()) { if (!localPlayer.isUsingLocalTexture()) {
int opacity = this.fontRenderer.getStringWidth(this.skinMessage) / 2; int opacity = fontRenderer.getStringWidth(skinMessage) / 2;
Gui.drawRect(40, this.height / 2 - 12, this.width / 2 - 40, this.height / 2 + 12, 0xB0000000); Gui.drawRect(40, height / 2 - 12, width / 2 - 40, height / 2 + 12, 0xB0000000);
this.fontRenderer.drawStringWithShadow(this.skinMessage, (int) (xPos1 - opacity), this.height / 2 - 4, 0xffffff); fontRenderer.drawStringWithShadow(skinMessage, (int) (xPos1 - opacity), 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); this.drawHoveringText(I18n.format(text), mouseX, y);
} }
if (this.btnAbout.isMouseOver()) { if (btnAbout.isMouseOver()) {
SkinServer gateway = HDSkinManager.INSTANCE.getGatewayServer(); SkinServer gateway = HDSkinManager.INSTANCE.getGatewayServer();
this.drawHoveringText(Splitter.on("\r\n").splitToList(gateway.toString()), mouseX, mouseY); this.drawHoveringText(Splitter.on("\r\n").splitToList(gateway.toString()), mouseX, mouseY);
} }
if (this.fetchingSkin) { if (fetchingSkin) {
String opacity1; String opacity1;
if (this.throttledByMojang) { if (throttledByMojang) {
opacity1 = TextFormatting.RED + I18n.format("hdskins.error.mojang"); opacity1 = TextFormatting.RED + I18n.format("hdskins.error.mojang");
String stringWidth = I18n.format("hdskins.error.mojang.wait"); String stringWidth = I18n.format("hdskins.error.mojang.wait");
int stringWidth1 = this.fontRenderer.getStringWidth(opacity1) / 2; int stringWidth1 = fontRenderer.getStringWidth(opacity1) / 2;
int stringWidth2 = this.fontRenderer.getStringWidth(stringWidth) / 2; int stringWidth2 = fontRenderer.getStringWidth(stringWidth) / 2;
Gui.drawRect((int) (xPos2 - labelwidth), this.height / 2 - 16, this.width - 40, this.height / 2 + 16, 0xB0000000); Gui.drawRect((int) (xPos2 - labelwidth), height / 2 - 16, width - 40, height / 2 + 16, 0xB0000000);
this.fontRenderer.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), this.height / 2 - 10, 0xffffff); fontRenderer.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), height / 2 - 10, 0xffffff);
this.fontRenderer.drawStringWithShadow(stringWidth, (int) (xPos2 - stringWidth2), this.height / 2 + 2, 0xffffff); fontRenderer.drawStringWithShadow(stringWidth, (int) (xPos2 - stringWidth2), height / 2 + 2, 0xffffff);
} else { } else {
opacity1 = I18n.format("hdskins.fetch"); opacity1 = I18n.format("hdskins.fetch");
int stringWidth1 = this.fontRenderer.getStringWidth(opacity1) / 2; int stringWidth1 = fontRenderer.getStringWidth(opacity1) / 2;
Gui.drawRect((int) (xPos2 - labelwidth), this.height / 2 - 12, this.width - 40, this.height / 2 + 12, 0xB0000000); Gui.drawRect((int) (xPos2 - labelwidth), height / 2 - 12, width - 40, height / 2 + 12, 0xB0000000);
this.fontRenderer.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), this.height / 2 - 4, 0xffffff); fontRenderer.drawStringWithShadow(opacity1, (int) (xPos2 - stringWidth1), height / 2 - 4, 0xffffff);
} }
} }
if (this.uploadingSkin || this.uploadOpacity > 0.0F) { if (uploadingSkin || uploadOpacity > 0.0F) {
if (!this.uploadingSkin) { if (!uploadingSkin) {
this.uploadOpacity -= deltaTime * 0.05F; uploadOpacity -= deltaTime * 0.05F;
} else if (this.uploadOpacity < 1.0F) { } else if (uploadOpacity < 1.0F) {
this.uploadOpacity += deltaTime * 0.1F; uploadOpacity += deltaTime * 0.1F;
} }
if (this.uploadOpacity > 1.0F) { if (uploadOpacity > 1.0F) {
this.uploadOpacity = 1.0F; uploadOpacity = 1.0F;
} }
int opacity = Math.min(180, (int) (this.uploadOpacity * 180.0F)) & 255; int opacity = Math.min(180, (int) (uploadOpacity * 180.0F)) & 255;
if (this.uploadOpacity > 0.0F) { if (uploadOpacity > 0.0F) {
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);
@ -519,11 +519,11 @@ public class GuiSkins extends GuiScreen {
rotate(-135.0F, 0.0F, 1.0F, 0.0F); rotate(-135.0F, 0.0F, 1.0F, 0.0F);
rotate(15.0F, 1.0F, 0.0F, 0.0F); rotate(15.0F, 1.0F, 0.0F, 0.0F);
float rot = ((updateCounter + partialTick) * 2.5F) % 360; float rot = (updateCounter + partialTick) * 2.5F % 360;
rotate(rot, 0, 1, 0); rotate(rot, 0, 1, 0);
thePlayer.rotationYawHead = ((float) Math.atan(mouseX / 20)) * 30; thePlayer.rotationYawHead = (float) Math.atan(mouseX / 20) * 30;
thePlayer.rotationPitch = -((float) Math.atan(mouseY / 40)) * 20; thePlayer.rotationPitch = -((float) Math.atan(mouseY / 40)) * 20;
translate(0.0D, thePlayer.getYOffset(), 0.0D); translate(0.0D, thePlayer.getYOffset(), 0.0D);
@ -538,18 +538,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.0D).put(1.0D).put(0.0D).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.0D).put(-1.0D).put(0.0D).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 +564,47 @@ public class GuiSkins extends GuiScreen {
} }
private void clearUploadedSkin(Session session) { private void clearUploadedSkin(Session session) {
this.uploadingSkin = true; uploadingSkin = true;
this.skinUploadMessage = I18n.format("hdskins.request"); skinUploadMessage = I18n.format("hdskins.request");
HDSkinManager.INSTANCE.getGatewayServer() HDSkinManager.INSTANCE.getGatewayServer()
.uploadSkin(session, null, this.textureType, getMetadata()) .uploadSkin(session, null, textureType, getMetadata())
.thenAccept(this::onUploadComplete) .thenAccept(this::onUploadComplete)
.exceptionally(this::onFailure); .exceptionally(this::onFailure);
} }
private void uploadSkin(Session session, @Nullable File skinFile) { private void uploadSkin(Session session, @Nullable File skinFile) {
this.uploadingSkin = true; uploadingSkin = true;
this.skinUploadMessage = I18n.format("hdskins.upload"); skinUploadMessage = I18n.format("hdskins.upload");
URI path = skinFile == null ? null : skinFile.toURI(); URI path = skinFile == null ? null : skinFile.toURI();
HDSkinManager.INSTANCE.getGatewayServer() HDSkinManager.INSTANCE.getGatewayServer()
.uploadSkin(session, path, this.textureType, getMetadata()) .uploadSkin(session, path, textureType, getMetadata())
.thenAccept(this::onUploadComplete) .thenAccept(this::onUploadComplete)
.exceptionally(this::onFailure); .exceptionally(this::onFailure);
} }
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 onFailure(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 {

View file

@ -147,7 +147,9 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
setHead(0, 0, 0); setHead(0, 0, 0);
} }
if (isSleeping) ponySleep(); if (isSleeping) {
ponySleep();
}
animateWears(); animateWears();
@ -275,8 +277,8 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
float forward = ROTATE_270 - ROTATE_90/3; float forward = ROTATE_270 - ROTATE_90/3;
float down = ROTATE_90; float down = ROTATE_90;
float leftX = down + MathHelper.sin((move / 3) + 2*PI/3) / 2; float leftX = down + MathHelper.sin(move / 3 + 2*PI/3) / 2;
float leftY = -forward - MathHelper.sin((move / 3) + 2*PI/3); float leftY = -forward - MathHelper.sin(move / 3 + 2*PI/3);
float rightX = down + MathHelper.sin(move / 3) / 2; float rightX = down + MathHelper.sin(move / 3) / 2;
@ -338,7 +340,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
bipedLeftArm.rotateAngleX = MathHelper.cos(baseRotation + angle) * scale; bipedLeftArm.rotateAngleX = MathHelper.cos(baseRotation + angle) * scale;
bipedRightArm.rotateAngleX = MathHelper.cos(baseRotation + PI + angle / 2) * scale; bipedRightArm.rotateAngleX = MathHelper.cos(baseRotation + PI + angle / 2) * scale;
bipedLeftLeg.rotateAngleX = MathHelper.cos(baseRotation + PI - (angle * 0.4f)) * scale; bipedLeftLeg.rotateAngleX = MathHelper.cos(baseRotation + PI - angle * 0.4f) * scale;
bipedRightLeg.rotateAngleX = MathHelper.cos(baseRotation + angle / 5) * scale; bipedRightLeg.rotateAngleX = MathHelper.cos(baseRotation + angle / 5) * scale;
bipedLeftArm.rotateAngleY = 0; bipedLeftArm.rotateAngleY = 0;
@ -349,8 +351,12 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
} }
protected float getLegOutset() { protected float getLegOutset() {
if (isSleeping) return 3.6f; if (isSleeping) {
if (isCrouching()) return 1; return 3.6f;
}
if (isCrouching()) {
return 1;
}
return 5; return 5;
} }
@ -386,7 +392,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
swag -= (float)Math.pow(swing, 2); swag -= (float)Math.pow(swing, 2);
} }
float mult = 1 - swag/2; float mult = 1 - swag/2;
arm.rotateAngleX = arm.rotateAngleX * mult - (PI / 10) * swag; arm.rotateAngleX = arm.rotateAngleX * mult - PI / 10 * swag;
arm.rotateAngleZ = -reflect * (PI / 15); arm.rotateAngleZ = -reflect * (PI / 15);
if (isSneak) { if (isSneak) {
arm.rotationPointX -= reflect * 2; arm.rotationPointX -= reflect * 2;
@ -395,7 +401,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
arm.rotateAngleY = 0; arm.rotateAngleY = 0;
break; break;
case BLOCK: case BLOCK:
arm.rotateAngleX = (arm.rotateAngleX / 2 - 0.9424779F) - 0.3F; arm.rotateAngleX = arm.rotateAngleX / 2 - 0.9424779F - 0.3F;
arm.rotateAngleY = reflect * PI / 9; arm.rotateAngleY = reflect * PI / 9;
arm.rotationPointX += reflect; arm.rotationPointX += reflect;
arm.rotationPointZ += 3; arm.rotationPointZ += 3;
@ -411,7 +417,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
} }
protected void aimBow(ModelRenderer arm, float ticks) { protected void aimBow(ModelRenderer arm, float ticks) {
arm.rotateAngleX = ROTATE_270 + bipedHead.rotateAngleX + (MathHelper.sin(ticks * 0.067F) * 0.05F); arm.rotateAngleX = ROTATE_270 + bipedHead.rotateAngleX + MathHelper.sin(ticks * 0.067F) * 0.05F;
arm.rotateAngleY = bipedHead.rotateAngleY - 0.06F; arm.rotateAngleY = bipedHead.rotateAngleY - 0.06F;
arm.rotateAngleZ = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; arm.rotateAngleZ = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
if (isSneak) { if (isSneak) {
@ -457,7 +463,9 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}. * @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
*/ */
protected void swingArms(float ticks) { protected void swingArms(float ticks) {
if (isSleeping) return; if (isSleeping) {
return;
}
float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F; float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
float sin = MathHelper.sin(ticks * 0.067F) * 0.05F; float sin = MathHelper.sin(ticks * 0.067F) * 0.05F;
@ -516,6 +524,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
AbstractPonyRenderer.shiftRotationPoint(bipedLeftLeg, 0, 2, -8); AbstractPonyRenderer.shiftRotationPoint(bipedLeftLeg, 0, 2, -8);
} }
@Override
public void init(float yOffset, float stretch) { public void init(float yOffset, float stretch) {
boxList.clear(); boxList.clear();
@ -817,7 +826,9 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
} }
protected void renderLegs(float scale) { protected void renderLegs(float scale) {
if (!isSneak) bipedBody.postRender(scale); if (!isSneak) {
bipedBody.postRender(scale);
}
bipedLeftArm.render(scale); bipedLeftArm.render(scale);
bipedRightArm.render(scale); bipedRightArm.render(scale);
@ -834,7 +845,9 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
@Override @Override
public void transform(BodyPart part) { public void transform(BodyPart part) {
if (isRiding) translate(0, -0.4F, -0.2F); if (isRiding) {
translate(0, -0.4F, -0.2F);
}
if (isSleeping) { if (isSleeping) {
rotate(90, 1, 0, 0); rotate(90, 1, 0, 0);
@ -876,7 +889,9 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
ModelRenderer result; ModelRenderer result;
do { do {
result = boxList.get(randomI); result = boxList.get(randomI);
if (!result.cubeList.isEmpty()) return result; if (!result.cubeList.isEmpty()) {
return result;
}
index = (index + 1) % boxList.size(); index = (index + 1) % boxList.size();
} while (index != randomI); } while (index != randomI);

View file

@ -52,6 +52,7 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor {
super.renderLegs(scale); super.renderLegs(scale);
} }
@Override
public <T extends ModelBiped & IModel> void synchroniseLegs(T mainModel) { public <T extends ModelBiped & IModel> void synchroniseLegs(T mainModel) {
copyModelAngles(mainModel.bipedRightArm, bipedRightArm); copyModelAngles(mainModel.bipedRightArm, bipedRightArm);
copyModelAngles(mainModel.bipedLeftArm, bipedLeftArm); copyModelAngles(mainModel.bipedLeftArm, bipedLeftArm);
@ -100,6 +101,7 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor {
snout.isHidden = true; snout.isHidden = true;
} }
@Override
public void showFeet(boolean show) { public void showFeet(boolean show) {
bipedRightArm.showModel = show; bipedRightArm.showModel = show;
bipedLeftArm.showModel = show; bipedLeftArm.showModel = show;
@ -107,15 +109,18 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor {
bipedLeftLeg.showModel = show; bipedLeftLeg.showModel = show;
} }
@Override
public void showLegs(boolean isPony) { public void showLegs(boolean isPony) {
bipedBody.showModel = true; bipedBody.showModel = true;
} }
@Override
public void showSaddle(boolean isPony) { public void showSaddle(boolean isPony) {
flankGuard.showModel = !isPony; flankGuard.showModel = !isPony;
saddle.showModel = isPony; saddle.showModel = isPony;
} }
@Override
public void showHead(boolean show) { public void showHead(boolean show) {
bipedHead.showModel = show; bipedHead.showModel = show;
} }

View file

@ -55,7 +55,7 @@ public class PonyElytra extends ModelBase {
float velY = 1; float velY = 1;
if (entity.motionY < 0) { if (entity.motionY < 0) {
Vec3d motion = (new Vec3d(entity.motionX, entity.motionY, entity.motionZ)).normalize(); Vec3d motion = new Vec3d(entity.motionX, entity.motionY, entity.motionZ).normalize();
velY = 1 - (float) Math.pow(-motion.y, 1.5); velY = 1 - (float) Math.pow(-motion.y, 1.5);
} }

View file

@ -92,13 +92,13 @@ public class PonyTail extends PlaneRenderer implements IModelPart {
super(model); super(model);
this.index = index; this.index = index;
offsetY = ((float)index)/4 + 0.063f; offsetY = (float)index/4 + 0.063f;
init(yOffset, stretch); init(yOffset, stretch);
} }
public void init(float yOffset, float stretch) { public void init(float yOffset, float stretch) {
int texX = (index % 2) * 4; int texX = index % 2 * 4;
around(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z); around(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z);

View file

@ -42,24 +42,33 @@ public class ModelSkeletonPony extends ModelMobPony {
super.setLivingAnimations(entity, move, swing, ticks); super.setLivingAnimations(entity, move, swing, ticks);
} }
@Override
protected float getLegOutset() { protected float getLegOutset() {
if (isSleeping()) return 2.6f; if (isSleeping()) {
if (isCrouching()) return 0; return 2.6f;
}
if (isCrouching()) {
return 0;
}
return 4; return 4;
} }
@Override
protected int getArmWidth() { protected int getArmWidth() {
return 2; return 2;
} }
@Override
protected int getArmDepth() { protected int getArmDepth() {
return 2; return 2;
} }
@Override
protected float getLegRotationX() { protected float getLegRotationX() {
return 3; return 3;
} }
@Override
protected float getArmRotationY() { protected float getArmRotationY() {
return 8; return 8;
} }

View file

@ -26,8 +26,9 @@ public class ModelWitchPony extends ModelZebra {
super(false); super(false);
} }
@Override
public void setLivingAnimations(EntityLivingBase entity, float move, float swing, float ticks) { public void setLivingAnimations(EntityLivingBase entity, float move, float swing, float ticks) {
EntityWitch witch = ((EntityWitch) entity); EntityWitch witch = (EntityWitch) entity;
leftArmPose = ArmPose.EMPTY; leftArmPose = ArmPose.EMPTY;
rightArmPose = witch.getHeldItemMainhand().isEmpty() ? ArmPose.EMPTY : ArmPose.ITEM; rightArmPose = witch.getHeldItemMainhand().isEmpty() ? ArmPose.EMPTY : ArmPose.ITEM;
@ -48,8 +49,12 @@ public class ModelWitchPony extends ModelZebra {
if (rightArmPose != ArmPose.EMPTY) { if (rightArmPose != ArmPose.EMPTY) {
float rot = (float)(Math.tan(ticks / 7) + Math.sin(ticks / 3)); float rot = (float)(Math.tan(ticks / 7) + Math.sin(ticks / 3));
if (rot > 1) rot = 1; if (rot > 1) {
if (rot < -1) rot = -1; rot = 1;
}
if (rot < -1) {
rot = -1;
}
float legDrinkingAngle = -1 * PI/3 + rot; float legDrinkingAngle = -1 * PI/3 + rot;
@ -60,7 +65,9 @@ public class ModelWitchPony extends ModelZebra {
bipedRightArm.offsetZ = 0.1f; bipedRightArm.offsetZ = 0.1f;
bipedRightArmwear.offsetZ = 0.1f; bipedRightArmwear.offsetZ = 0.1f;
if (rot > 0) rot = 0; if (rot > 0) {
rot = 0;
}
bipedHead.rotateAngleX = -rot / 2; bipedHead.rotateAngleX = -rot / 2;
bipedHeadwear.rotateAngleX = -rot / 2; bipedHeadwear.rotateAngleX = -rot / 2;