當前位置: 首頁>>代碼示例>>Java>>正文


Java TextureUtil.readBufferedImage方法代碼示例

本文整理匯總了Java中net.minecraft.client.renderer.texture.TextureUtil.readBufferedImage方法的典型用法代碼示例。如果您正苦於以下問題:Java TextureUtil.readBufferedImage方法的具體用法?Java TextureUtil.readBufferedImage怎麽用?Java TextureUtil.readBufferedImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.client.renderer.texture.TextureUtil的用法示例。


在下文中一共展示了TextureUtil.readBufferedImage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadTexture

import net.minecraft.client.renderer.texture.TextureUtil; //導入方法依賴的package包/類
public void loadTexture(IResourceManager resourceManager) throws IOException
{
    this.deleteGlTexture();
    InputStream inputstream = Shaders.getShaderPackResourceStream(this.texturePath);

    if (inputstream == null)
    {
        throw new FileNotFoundException("Shader texture not found: " + this.texturePath);
    }
    else
    {
        try
        {
            BufferedImage bufferedimage = TextureUtil.readBufferedImage(inputstream);
            TextureMetadataSection texturemetadatasection = this.loadTextureMetadataSection();
            TextureUtil.uploadTextureImageAllocate(this.getGlTextureId(), bufferedimage, texturemetadatasection.getTextureBlur(), texturemetadatasection.getTextureClamp());
        }
        finally
        {
            IOUtils.closeQuietly(inputstream);
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:24,代碼來源:SimpleShaderTexture.java

示例2: FriendEntry

import net.minecraft.client.renderer.texture.TextureUtil; //導入方法依賴的package包/類
public FriendEntry(String username, String status, String rank) {
	this.username = username;
	this.status = status;
	this.rank = rank;
	this.headLocation = new ResourceLocation("rewimod/" + username + "/head");

	try {
		URL obj = new URL("https://minotar.net/helm/" + username + "/32.png");
		HttpURLConnection con = (HttpURLConnection) obj.openConnection();

		// optional default is GET
		con.setRequestMethod("GET");

		//add request header
		con.setRequestProperty("User-Agent", "Minecraft");

		InputStream stream = con.getInputStream();
		this.headImage = TextureUtil.readBufferedImage(stream);
	} catch (Exception ex) {
	}
}
 
開發者ID:CreepPlaysDE,項目名稱:RewiMod,代碼行數:22,代碼來源:FriendEntry.java

示例3: convertTextureToGrayScale

import net.minecraft.client.renderer.texture.TextureUtil; //導入方法依賴的package包/類
public static void convertTextureToGrayScale() throws IOException
{
    IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager();
    try
    {
        BufferedImage vanillaCreeperTextureData = TextureUtil.readBufferedImage(resourceManager.getResource(vanillaCreeperTexture).getInputStream());

        // Do the conversion to grayscale
        BufferedImage creeperTextureData = new BufferedImage(vanillaCreeperTextureData.getWidth(), vanillaCreeperTextureData.getHeight(), BufferedImage.TYPE_USHORT_GRAY);
        Graphics g = creeperTextureData.getGraphics();
        g.drawImage(vanillaCreeperTextureData, 0, 0, null);
        g.dispose();

        DynamicTexture dynamicGrayscaleCreeperTexture = new DynamicTexture(creeperTextureData);

        grayscaleCreeperTexture = new ResourceLocation(ChameleonCreepersMod.MODID, "textures/entity/creeper/chameleoncreeper.png");
        Minecraft.getMinecraft().getTextureManager().loadTexture(grayscaleCreeperTexture, dynamicGrayscaleCreeperTexture);
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
}
 
開發者ID:VelocityRa,項目名稱:ChameleonCreepersMod,代碼行數:24,代碼來源:RenderChameleonCreeper.java

示例4: getLogoTexture

import net.minecraft.client.renderer.texture.TextureUtil; //導入方法依賴的package包/類
@Override
public ResourceLocation getLogoTexture() {
    if (logoTexture == null) {
        if (logoBytes != null || logo != null) {
            try {
                InputStream in;
                if (logoBytes == null) {
                    in = new URL(getModFile().toURI().toURL().toString() + '/' + logo).openStream();
                } else {
                    in = new ByteArrayInputStream(logoBytes);
                }
                BufferedImage image = TextureUtil.readBufferedImage(in);
                DynamicTexture texture = new DynamicTexture(image);
                this.logoTexture = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("mods/" + getModID(), texture);
                in.close();
                logoBytes = null;
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        } else {
            logoTexture = new ResourceLocation("textures/misc/unknown_server.png");
        }
    }
    return logoTexture;
}
 
開發者ID:OpenModLoader,項目名稱:OpenModLoader,代碼行數:26,代碼來源:ManifestModInfo.java

示例5: drawDefaultBackground

import net.minecraft.client.renderer.texture.TextureUtil; //導入方法依賴的package包/類
@Override
public void drawDefaultBackground() {
	super.drawDefaultBackground();
	ResourceLocation location = new ResourceLocation(HarshenCastle.MODID, "textures/gui/category/" + this.mode.getName().toLowerCase()  + ".png");
	this.mc.getTextureManager().bindTexture(location);
       try {
   		BufferedImage i = TextureUtil.readBufferedImage(Minecraft.getMinecraft().getResourceManager().getResource(location).getInputStream());
		this.drawModalRectWithCustomSizedTexture(50, 50, 0, scroll, this.width - 100, this.height - 100, this.width - 100, (this.width - 100) * ((float)i.getHeight() / i.getWidth()));
       } catch (IOException e) {
		e.printStackTrace();
	}
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:13,代碼來源:GuiBookScreen.java

示例6: getBufferedImage

import net.minecraft.client.renderer.texture.TextureUtil; //導入方法依賴的package包/類
@Nullable
private BufferedImage getBufferedImage(@Nonnull ResourceLocation textureResourceLocation) {
    BufferedImage skinImage = null;
    try {
        IResource skin = Minecraft.getMinecraft().getResourceManager().getResource(textureResourceLocation);
        skinImage = TextureUtil.readBufferedImage(skin.getInputStream());
        MineLittlePony.logger.debug("Obtained skin from resource location {}", textureResourceLocation);
        // this.checkSkin(skinImage);
    } catch (IOException e) {

        try {
            ITextureObject e2 = Minecraft.getMinecraft().getTextureManager().getTexture(textureResourceLocation);
            if (e2 instanceof ThreadDownloadImageData) {

                skinImage = PonyFields.downloadedImage.get((ThreadDownloadImageData) e2);
                if (skinImage != null) {
                    MineLittlePony.logger.debug("Successfully reflected downloadedImage from texture object", e);
                    // this.checkSkin(skinImage);
                }
            } else if (e2 instanceof ThreadDownloadImageETag) {
                skinImage = ((ThreadDownloadImageETag) e2).getBufferedImage();
            } else if (e2 instanceof DynamicTextureImage) {
                skinImage = ((DynamicTextureImage) e2).getImage();
            }
        } catch (Exception ignored) {

        }
    }

    return skinImage;
}
 
開發者ID:MineLittlePony,項目名稱:MineLittlePony,代碼行數:32,代碼來源:Pony.java

示例7: getImage

import net.minecraft.client.renderer.texture.TextureUtil; //導入方法依賴的package包/類
@Nullable
private static BufferedImage getImage(ResourceLocation res) {

    try (InputStream in = mc.getResourceManager().getResource(res).getInputStream()) {
        return TextureUtil.readBufferedImage(in);
    } catch (IOException e) {
        return null;
    }
}
 
開發者ID:MineLittlePony,項目名稱:MineLittlePony,代碼行數:10,代碼來源:ImageLoader.java

示例8: getPackImage

import net.minecraft.client.renderer.texture.TextureUtil; //導入方法依賴的package包/類
@Override
public BufferedImage getPackImage() throws IOException {
    InputStream in = null;
    if (mod.getLogoTexture() == null) {
        in = Minecraft.getMinecraft().getResourceManager().getResource(ICON_MISSING).getInputStream();
    } else {
        in = Minecraft.getMinecraft().getResourceManager().getResource(mod.getLogoTexture()).getInputStream();
    }
    return TextureUtil.readBufferedImage(in);
}
 
開發者ID:OpenModLoader,項目名稱:OpenModLoader,代碼行數:11,代碼來源:OMLFileResourcePack.java

示例9: loadTextures

import net.minecraft.client.renderer.texture.TextureUtil; //導入方法依賴的package包/類
@SideOnly(Side.CLIENT)
public static void loadTextures(IResourceManager resourceManager) {
	try {
		grassBuffer = TextureUtil.readImageData(resourceManager, grassColormap);
		
		
		BufferedImage bufferedimage = TextureUtil.readBufferedImage(resourceManager.getResource(cloudResourceLocation).getInputStream());
        cloudTextureWidth = bufferedimage.getWidth();
        cloudTextureHeight = bufferedimage.getHeight();
        
        int[] cloudPixels = new int[256 * 256];
        bufferedimage.getRGB(0, 0, cloudTextureWidth, cloudTextureHeight, cloudPixels, 0, cloudTextureWidth);
        
        // For low or high res clouds
        float scale = cloudTextureWidth / 256; 
        
        for (int x = 0; x < 256; x++) {
        	for (int y = 0; y < 256; y++) {
        		cloudBuffer[x + 256 * y] = ((cloudPixels[(int) (x * scale + 256 * y * scale)] >> 24) & 0xff) > 0;
        	}
        }
        
		
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
開發者ID:tyronx,項目名稱:vintagecraft,代碼行數:28,代碼來源:VCraftWorld.java

示例10: setSkyBrightnessAndContrast

import net.minecraft.client.renderer.texture.TextureUtil; //導入方法依賴的package包/類
public static void setSkyBrightnessAndContrast(float nightSkyContrast, int nightSkyBrightness) {
  	ResourceLocation nightSkyTexLoc = nightSkies[VintageCraft.proxy.getNightSkyType()];
  	
  	try {
  		
	BufferedImage bufferedimage = TextureUtil.readBufferedImage(Minecraft.getMinecraft().getResourceManager().getResource(nightSkyTexLoc).getInputStream());
   	RescaleOp op = new RescaleOp(nightSkyContrast, nightSkyBrightness, null);
   	op.filter(bufferedimage, bufferedimage);
   	nightSkyTex = new DynamicTexture(bufferedimage);
   	
} catch (IOException e) {
	return;
}	
  }
 
開發者ID:tyronx,項目名稱:vintagecraft,代碼行數:15,代碼來源:RenderSkyVC.java

示例11: verify

import net.minecraft.client.renderer.texture.TextureUtil; //導入方法依賴的package包/類
private Object verify(Object obj){
	if(obj instanceof String) AbyssalCraftAPI.getInternalNDHandler().verifyImageURL((String)obj);
	if(!(obj instanceof ResourceLocation)) return obj;
	if(FMLCommonHandler.instance().getSide().isServer()) return obj;
	ResourceLocation res = (ResourceLocation)obj;
	if(res.toString().equals("abyssalcraft:textures/gui/necronomicon/missing.png")) return obj;
	try {
		TextureUtil.readBufferedImage(Minecraft.getMinecraft().getResourceManager().getResource(res).getInputStream());
	} catch (IOException e) {
		return new ResourceLocation("abyssalcraft", "textures/gui/necronomicon/missing.png");
	}
	return res;
}
 
開發者ID:Shinoow,項目名稱:AbyssalCraft,代碼行數:14,代碼來源:NecroData.java

示例12: getPackImage

import net.minecraft.client.renderer.texture.TextureUtil; //導入方法依賴的package包/類
public BufferedImage getPackImage() throws IOException
{
    return TextureUtil.readBufferedImage(this.getInputStreamByName("pack.png"));
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:5,代碼來源:AbstractResourcePack.java

示例13: getPackImage

import net.minecraft.client.renderer.texture.TextureUtil; //導入方法依賴的package包/類
public BufferedImage getPackImage() throws IOException
{
    return TextureUtil.readBufferedImage(DefaultResourcePack.class.getResourceAsStream("/" + (new ResourceLocation("pack.png")).getResourcePath()));
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:5,代碼來源:DefaultResourcePack.java

示例14: loadTextureFromServer

import net.minecraft.client.renderer.texture.TextureUtil; //導入方法依賴的package包/類
protected void loadTextureFromServer()
{
    this.imageThread = new Thread("Texture Downloader #" + threadDownloadCounter.incrementAndGet())
    {
        public void run()
        {
            HttpURLConnection httpurlconnection = null;
            ThreadDownloadImageData.logger.debug("Downloading http texture from {} to {}", new Object[] {ThreadDownloadImageData.this.imageUrl, ThreadDownloadImageData.this.cacheFile});

            try
            {
                httpurlconnection = (HttpURLConnection)(new URL(ThreadDownloadImageData.this.imageUrl)).openConnection(Minecraft.getMinecraft().getProxy());
                httpurlconnection.setDoInput(true);
                httpurlconnection.setDoOutput(false);
                httpurlconnection.connect();

                if (httpurlconnection.getResponseCode() / 100 == 2)
                {
                    BufferedImage bufferedimage;

                    if (ThreadDownloadImageData.this.cacheFile != null)
                    {
                        FileUtils.copyInputStreamToFile(httpurlconnection.getInputStream(), ThreadDownloadImageData.this.cacheFile);
                        bufferedimage = ImageIO.read(ThreadDownloadImageData.this.cacheFile);
                    }
                    else
                    {
                        bufferedimage = TextureUtil.readBufferedImage(httpurlconnection.getInputStream());
                    }

                    if (ThreadDownloadImageData.this.imageBuffer != null)
                    {
                        bufferedimage = ThreadDownloadImageData.this.imageBuffer.parseUserSkin(bufferedimage);
                    }

                    ThreadDownloadImageData.this.setBufferedImage(bufferedimage);
                    return;
                }
            }
            catch (Exception exception)
            {
                ThreadDownloadImageData.logger.error((String)"Couldn\'t download http texture", (Throwable)exception);
                return;
            }
            finally
            {
                if (httpurlconnection != null)
                {
                    httpurlconnection.disconnect();
                }
            }
        }
    };
    this.imageThread.setDaemon(true);
    this.imageThread.start();
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:57,代碼來源:ThreadDownloadImageData.java

示例15: readFontTexture

import net.minecraft.client.renderer.texture.TextureUtil; //導入方法依賴的package包/類
private void readFontTexture()
{
    IResource iresource = null;
    BufferedImage bufferedimage;

    try
    {
        iresource = getResource(this.locationFontTexture);
        bufferedimage = TextureUtil.readBufferedImage(iresource.getInputStream());
    }
    catch (IOException ioexception)
    {
        throw new RuntimeException(ioexception);
    }
    finally
    {
        IOUtils.closeQuietly((Closeable)iresource);
    }

    int lvt_3_1_ = bufferedimage.getWidth();
    int lvt_4_1_ = bufferedimage.getHeight();
    int[] lvt_5_1_ = new int[lvt_3_1_ * lvt_4_1_];
    bufferedimage.getRGB(0, 0, lvt_3_1_, lvt_4_1_, lvt_5_1_, 0, lvt_3_1_);
    int lvt_6_1_ = lvt_4_1_ / 16;
    int lvt_7_1_ = lvt_3_1_ / 16;
    boolean lvt_8_1_ = true;
    float lvt_9_1_ = 8.0F / (float)lvt_7_1_;

    for (int lvt_10_1_ = 0; lvt_10_1_ < 256; ++lvt_10_1_)
    {
        int j1 = lvt_10_1_ % 16;
        int k1 = lvt_10_1_ / 16;

        if (lvt_10_1_ == 32)
        {
            this.charWidth[lvt_10_1_] = 4;
        }

        int l1;

        for (l1 = lvt_7_1_ - 1; l1 >= 0; --l1)
        {
            int i2 = j1 * lvt_7_1_ + l1;
            boolean flag1 = true;

            for (int j2 = 0; j2 < lvt_6_1_ && flag1; ++j2)
            {
                int k2 = (k1 * lvt_7_1_ + j2) * lvt_3_1_;

                if ((lvt_5_1_[i2 + k2] >> 24 & 255) != 0)
                {
                    flag1 = false;
                }
            }

            if (!flag1)
            {
                break;
            }
        }

        ++l1;
        this.charWidth[lvt_10_1_] = (int)(0.5D + (double)((float)l1 * lvt_9_1_)) + 1;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:66,代碼來源:FontRenderer.java


注:本文中的net.minecraft.client.renderer.texture.TextureUtil.readBufferedImage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。