本文整理汇总了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);
}
}
}
示例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) {
}
}
示例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();
}
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
}
示例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);
}
示例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();
}
}
示例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;
}
}
示例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;
}
示例12: getPackImage
import net.minecraft.client.renderer.texture.TextureUtil; //导入方法依赖的package包/类
public BufferedImage getPackImage() throws IOException
{
return TextureUtil.readBufferedImage(this.getInputStreamByName("pack.png"));
}
示例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()));
}
示例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();
}
示例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;
}
}