mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 18:05:10 +00:00
Proper Reformating
This commit is contained in:
1 parent
ce75880aba
commit
180d257024
1179 files changed
+59847
-61583
No files matched your search
@@ -22,8 +22,7 @@ import java.net.URL;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ImageDownloadAlt extends SimpleTexture
|
||||
{
|
||||
public class ImageDownloadAlt extends SimpleTexture {
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private static final AtomicInteger threadDownloadCounter = new AtomicInteger(0);
|
||||
private final File cacheFile;
|
||||
@@ -33,22 +32,17 @@ public class ImageDownloadAlt extends SimpleTexture
|
||||
private Thread imageThread;
|
||||
private boolean textureUploaded;
|
||||
|
||||
public ImageDownloadAlt(File file, String url, ResourceLocation resource, IImageBuffer buffer)
|
||||
{
|
||||
public ImageDownloadAlt(File file, String url, ResourceLocation resource, IImageBuffer buffer) {
|
||||
super(resource);
|
||||
this.cacheFile = file;
|
||||
this.imageUrl = url;
|
||||
this.imageBuffer = buffer;
|
||||
}
|
||||
|
||||
private void checkTextureUploaded()
|
||||
{
|
||||
if (!this.textureUploaded)
|
||||
{
|
||||
if (this.bufferedImage != null)
|
||||
{
|
||||
if (this.textureLocation != null)
|
||||
{
|
||||
private void checkTextureUploaded() {
|
||||
if (!this.textureUploaded) {
|
||||
if (this.bufferedImage != null) {
|
||||
if (this.textureLocation != null) {
|
||||
this.deleteGlTexture();
|
||||
}
|
||||
|
||||
@@ -58,74 +52,57 @@ public class ImageDownloadAlt extends SimpleTexture
|
||||
}
|
||||
}
|
||||
|
||||
public int getGlTextureId()
|
||||
{
|
||||
public int getGlTextureId() {
|
||||
this.checkTextureUploaded();
|
||||
return super.getGlTextureId();
|
||||
}
|
||||
|
||||
public void setBufferedImage(BufferedImage p_147641_1_)
|
||||
{
|
||||
public void setBufferedImage(BufferedImage p_147641_1_) {
|
||||
this.bufferedImage = p_147641_1_;
|
||||
|
||||
if (this.imageBuffer != null)
|
||||
{
|
||||
if (this.imageBuffer != null) {
|
||||
this.imageBuffer.func_152634_a();
|
||||
}
|
||||
}
|
||||
|
||||
public BufferedImage getBufferedImage(){
|
||||
public BufferedImage getBufferedImage() {
|
||||
return this.bufferedImage;
|
||||
}
|
||||
|
||||
public void loadTexture(IResourceManager resourceManager) throws IOException
|
||||
{
|
||||
if (this.bufferedImage == null && this.textureLocation != null)
|
||||
{
|
||||
public void loadTexture(IResourceManager resourceManager) throws IOException {
|
||||
if (this.bufferedImage == null && this.textureLocation != null) {
|
||||
super.loadTexture(resourceManager);
|
||||
}
|
||||
|
||||
if (this.imageThread == null)
|
||||
{
|
||||
if (this.cacheFile != null && this.cacheFile.isFile())
|
||||
{
|
||||
logger.debug("Loading http texture from local cache ({})", new Object[] {this.cacheFile});
|
||||
if (this.imageThread == null) {
|
||||
if (this.cacheFile != null && this.cacheFile.isFile()) {
|
||||
logger.debug("Loading http texture from local cache ({})", new Object[]{this.cacheFile});
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
this.bufferedImage = ImageIO.read(this.cacheFile);
|
||||
|
||||
if (this.imageBuffer != null)
|
||||
{
|
||||
if (this.imageBuffer != null) {
|
||||
this.setBufferedImage(this.imageBuffer.parseUserSkin(this.bufferedImage));
|
||||
}
|
||||
}
|
||||
catch (IOException ioexception)
|
||||
{
|
||||
} catch (IOException ioexception) {
|
||||
logger.error("Couldn\'t load skin " + this.cacheFile, ioexception);
|
||||
this.loadTextureFromServer();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.loadTextureFromServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadTextureFromServer()
|
||||
{
|
||||
this.imageThread = new Thread("Texture Downloader #" + threadDownloadCounter.incrementAndGet())
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
protected void loadTextureFromServer() {
|
||||
this.imageThread = new Thread("Texture Downloader #" + threadDownloadCounter.incrementAndGet()) {
|
||||
public void run() {
|
||||
HttpURLConnection connection = null;
|
||||
ImageDownloadAlt.logger.debug("Downloading http texture from {} to {}", new Object[] {ImageDownloadAlt.this.imageUrl, ImageDownloadAlt.this.cacheFile});
|
||||
ImageDownloadAlt.logger.debug("Downloading http texture from {} to {}", new Object[]{ImageDownloadAlt.this.imageUrl, ImageDownloadAlt.this.cacheFile});
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
URL url = new URL(ImageDownloadAlt.this.imageUrl);
|
||||
connection = (HttpURLConnection)(url).openConnection(Minecraft.getMinecraft().getProxy());
|
||||
connection = (HttpURLConnection) (url).openConnection(Minecraft.getMinecraft().getProxy());
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(false);
|
||||
connection.setRequestProperty("Content-Type", "image/png");
|
||||
@@ -140,40 +117,29 @@ public class ImageDownloadAlt extends SimpleTexture
|
||||
|
||||
connection.connect();
|
||||
|
||||
if (connection.getResponseCode() / 100 != 2)
|
||||
{
|
||||
if (connection.getResponseCode() / 100 != 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
BufferedImage bufferedimage;
|
||||
|
||||
if (ImageDownloadAlt.this.cacheFile != null)
|
||||
{
|
||||
if (ImageDownloadAlt.this.cacheFile != null) {
|
||||
FileUtils.copyInputStreamToFile(connection.getInputStream(), ImageDownloadAlt.this.cacheFile);
|
||||
bufferedimage = ImageIO.read(ImageDownloadAlt.this.cacheFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
bufferedimage = ImageIO.read(connection.getInputStream());
|
||||
}
|
||||
|
||||
if (ImageDownloadAlt.this.imageBuffer != null)
|
||||
{
|
||||
if (ImageDownloadAlt.this.imageBuffer != null) {
|
||||
bufferedimage = ImageDownloadAlt.this.imageBuffer.parseUserSkin(bufferedimage);
|
||||
}
|
||||
|
||||
ImageDownloadAlt.this.setBufferedImage(bufferedimage);
|
||||
}
|
||||
catch (MalformedURLException ignored) {
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
} catch (MalformedURLException ignored) {
|
||||
} catch (Exception exception) {
|
||||
ImageDownloadAlt.logger.error("Couldn\'t download http texture", exception);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (connection != null)
|
||||
{
|
||||
} finally {
|
||||
if (connection != null) {
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user