diff --git a/src/main/java/noppes/npcs/client/ImageDownloadAlt.java b/src/main/java/noppes/npcs/client/ImageDownloadAlt.java index 2274682e8..3a5b9ae6f 100644 --- a/src/main/java/noppes/npcs/client/ImageDownloadAlt.java +++ b/src/main/java/noppes/npcs/client/ImageDownloadAlt.java @@ -131,14 +131,13 @@ public class ImageDownloadAlt extends SimpleTexture connection.setRequestProperty("Content-Type", "image/png"); connection.setRequestProperty("Expect", "100-continue"); //connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20100101 Firefox/19.0"); + connection.setRequestProperty("User-Agent", "Mozilla/5.0"); - // Set user agent + // Modify Accept Redirect if (isImgurLink(url)) { - connection.setRequestProperty("User-Agent", "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)"); - } - else { - connection.setRequestProperty("User-Agent", "Mozilla/5.0"); + connection.setRequestProperty("Accept", "*/*"); } + connection.connect(); if (connection.getResponseCode() / 100 != 2) @@ -169,7 +168,7 @@ public class ImageDownloadAlt extends SimpleTexture } catch (Exception exception) { - ImageDownloadAlt.logger.error("Couldn\'t download http texture", exception); + ImageDownloadAlt.logger.error("Couldn\'t download http texture", exception); } finally { @@ -184,6 +183,7 @@ public class ImageDownloadAlt extends SimpleTexture this.imageThread.start(); } + // Check if the URL is an Imgur link private static boolean isImgurLink(URL url) { return url.getHost().endsWith("imgur.com"); diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java index a0f0a6ed1..689b17206 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java @@ -48,6 +48,9 @@ public class RenderNPCInterface extends RenderLiving{ public static RenderManager staticRenderManager; public ModelBase originalModel; + public static ResourceLocation steve64 = new ResourceLocation("customnpcs","textures/entity/64-Textures/humanmale/Steve.png"); + public static ResourceLocation alex = new ResourceLocation("customnpcs","textures/entity/64-Textures/humanfemale/Alex.png"); + public RenderNPCInterface(ModelBase model, float f){ super(model, f); this.originalModel = model; @@ -585,27 +588,39 @@ public class RenderNPCInterface extends RenderLiving{ } LastTextureTick = 0; } else if (npc.display.skinType == 2 || npc.display.skinType == 3) { - ResourceLocation location = new ResourceLocation("skins/" + (npc.display.modelType + npc.display.skinType + npc.display.url).hashCode()); + ResourceLocation location = new ResourceLocation("skins/" + (npc.display.skinType + npc.display.url).hashCode()); // If URL Empty Steve - if(npc.display.url.isEmpty()){ return AbstractClientPlayer.locationStevePng; } + if(npc.display.url.isEmpty()){ + return fallBackSkin(npc); + } // If URL Cached then grab it else if(ClientCacheHandler.isCachedNPC(location)){ try { - npc.textureLocation = ClientCacheHandler.getNPCTexture(npc.display.url, npc.display.modelType > 0 || npc.display.skinType == 3, location).getLocation(); + ResourceLocation loc = ClientCacheHandler.getNPCTexture(npc.display.url, npc.display.skinType == 3, location).getLocation(); + if(loc != null){ + npc.textureLocation = loc; + } else { + return fallBackSkin(npc); + } } catch(Exception ignored){} } // For New URL Requests do not spam it else if(LastTextureTick < 5) { //fixes request flood somewhat - return AbstractClientPlayer.locationStevePng; + return fallBackSkin(npc); } else { try { - npc.textureLocation = ClientCacheHandler.getNPCTexture(npc.display.url, npc.display.modelType > 0 || npc.display.skinType == 3, location).getLocation(); + ResourceLocation loc = ClientCacheHandler.getNPCTexture(npc.display.url, npc.display.skinType == 3, location).getLocation(); + if(loc != null){ + npc.textureLocation = loc; + } else { + return fallBackSkin(npc); + } LastTextureTick = 0; } catch(Exception ignored){} } } else { - return AbstractClientPlayer.locationStevePng; + return fallBackSkin(npc); } } return npc.textureLocation; @@ -653,4 +668,16 @@ public class RenderNPCInterface extends RenderLiving{ } } + + private ResourceLocation fallBackSkin(EntityNPCInterface npcInterface){ + switch (npcInterface.display.modelType){ + case 2: + return alex; + case 1: + return steve64; + default: + return AbstractClientPlayer.locationStevePng; + } + } + } diff --git a/src/main/resources/assets/customnpcs/textures/entity/64-Textures/humanfemale/Alex.png b/src/main/resources/assets/customnpcs/textures/entity/64-Textures/humanfemale/Alex.png new file mode 100644 index 000000000..5ef231b12 Binary files /dev/null and b/src/main/resources/assets/customnpcs/textures/entity/64-Textures/humanfemale/Alex.png differ diff --git a/src/main/resources/assets/customnpcs/textures/entity/64-Textures/humanmale/steve64.png b/src/main/resources/assets/customnpcs/textures/entity/64-Textures/humanmale/steve64.png new file mode 100644 index 000000000..c5426101d Binary files /dev/null and b/src/main/resources/assets/customnpcs/textures/entity/64-Textures/humanmale/steve64.png differ