| 1 | package net.minecraft.client.renderer.texture;
|
| 2 |
|
| 3 | import java.awt.image.BufferedImage;
|
| 4 | import java.io.IOException;
|
| 5 | import java.io.InputStream;
|
| 6 | import net.minecraft.client.resources.IResource;
|
| 7 | import net.minecraft.client.resources.IResourceManager;
|
| 8 | import net.minecraft.client.resources.data.TextureMetadataSection;
|
| 9 | import net.minecraft.util.ResourceLocation;
|
| 10 | import org.apache.logging.log4j.LogManager;
|
| 11 | import org.apache.logging.log4j.Logger;
|
| 12 |
|
| 13 | public class SimpleTexture extends AbstractTexture
|
| 14 | {
|
| 15 | private static final Logger logger = LogManager.getLogger();
|
| 16 | protected final ResourceLocation textureLocation;
|
| 17 |
|
| 18 | public SimpleTexture(ResourceLocation textureResourceLocation)
|
| 19 | {
|
| 20 | this.textureLocation = textureResourceLocation;
|
| 21 | }
|
| 22 |
|
| 23 | public void loadTexture(IResourceManager resourceManager) throws IOException
|
| 24 | {
|
| 25 | this.deleteGlTexture();
|
| 26 | InputStream inputstream = null;
|
| 27 |
|
| 28 | try
|
| 29 | {
|
| 30 | IResource iresource = resourceManager.getResource(this.textureLocation);
|
| 31 | inputstream = iresource.getInputStream();
|
| 32 | BufferedImage bufferedimage = TextureUtil.readBufferedImage(inputstream);
|
| 33 | boolean flag = false;
|
| 34 | boolean flag1 = false;
|
| 35 |
|
| 36 | if (iresource.hasMetadata())
|
| 37 | {
|
| 38 | try
|
| 39 | {
|
| 40 | TextureMetadataSection texturemetadatasection = (TextureMetadataSection)iresource.getMetadata("texture");
|
| 41 |
|
| 42 | if (texturemetadatasection != null)
|
| 43 | {
|
| 44 | flag = texturemetadatasection.getTextureBlur();
|
| 45 | flag1 = texturemetadatasection.getTextureClamp();
|
| 46 | }
|
| 47 | }
|
| 48 | catch (RuntimeException runtimeexception)
|
| 49 | {
|
| 50 | logger.warn((String)("Failed reading metadata of: " + this.textureLocation), (Throwable)runtimeexception);
|
| 51 | }
|
| 52 | }
|
| 53 |
|
| 54 | TextureUtil.uploadTextureImageAllocate(this.getGlTextureId(), bufferedimage, flag, flag1);
|
| 55 | }
|
| 56 | finally
|
| 57 | {
|
| 58 | if (inputstream != null)
|
| 59 | {
|
| 60 | inputstream.close();
|
| 61 | }
|
| 62 | }
|
| 63 | }
|
| 64 | }
|
| 65 |
|