本文整理汇总了Java中net.minecraft.client.resources.IResourceManager.getResource方法的典型用法代码示例。如果您正苦于以下问题:Java IResourceManager.getResource方法的具体用法?Java IResourceManager.getResource怎么用?Java IResourceManager.getResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.client.resources.IResourceManager
的用法示例。
在下文中一共展示了IResourceManager.getResource方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadNSMap1
import net.minecraft.client.resources.IResourceManager; //导入方法依赖的package包/类
public static void loadNSMap1(IResourceManager manager, ResourceLocation location, int width, int height, int[] aint, int offset, int defaultColor)
{
boolean flag = false;
try
{
IResource iresource = manager.getResource(location);
BufferedImage bufferedimage = ImageIO.read(iresource.getInputStream());
if (bufferedimage != null && bufferedimage.getWidth() == width && bufferedimage.getHeight() == height)
{
bufferedimage.getRGB(0, 0, width, height, aint, offset, width);
flag = true;
}
}
catch (IOException var10)
{
;
}
if (!flag)
{
Arrays.fill(aint, offset, offset + width * height, defaultColor);
}
}
示例2: readImageData
import net.minecraft.client.resources.IResourceManager; //导入方法依赖的package包/类
public static int[] readImageData(IResourceManager resourceManager, ResourceLocation imageLocation) throws IOException
{
IResource iresource = null;
int[] aint1;
try
{
iresource = resourceManager.getResource(imageLocation);
BufferedImage bufferedimage = readBufferedImage(iresource.getInputStream());
int i = bufferedimage.getWidth();
int j = bufferedimage.getHeight();
int[] aint = new int[i * j];
bufferedimage.getRGB(0, 0, i, j, aint, 0, i);
aint1 = aint;
}
finally
{
IOUtils.closeQuietly((Closeable)iresource);
}
return aint1;
}
示例3: postInit
import net.minecraft.client.resources.IResourceManager; //导入方法依赖的package包/类
@Override
public void postInit(FMLPostInitializationEvent event) {
byte[] defaultBIOSImage = null;
IResourceManager rm = Minecraft.getMinecraft().getResourceManager();
try {
IResource res = rm.getResource(new ResourceLocation("ocmos", "ocmosbios.cabe"));
InputStream stream = res.getInputStream();
byte[] buf = new byte[4096];
int len = stream.read(buf);
if(len <= 6)
MainClass.logger.error("ocmosbios.cabe is too small to possibly be valid");
else {
defaultBIOSImage = Arrays.copyOf(buf, len);
MainClass.logger.info("Found ocmosbios.cabe");
}
}
catch(IOException e) {
MainClass.logger.error("IOException while loading ocmosbios.cabe", e);
}
if(defaultBIOSImage != null) {
MainClass.setDefaultBIOSImage(defaultBIOSImage);
Items.registerEEPROM("EEPROM (OCMOS BIOS)", defaultBIOSImage, null, false);
// TODO: Get this to work some day, behind a config option
/*
ItemStack stack = new ItemStack(Items.get("eeprom").item());
NBTTagCompound compound = new NBTTagCompound();
compound.setByteArray("oc:eeprom", defaultBIOSImage);
compound.setString("oc:label", "EEPROM (OCMOS BIOS)");
stack.setTagCompound(compound);
GameRegistry.addShapelessRecipe(stack, Items.get("eeprom").item(), net.minecraft.init.Items.feather);
*/
}
}
示例4: hasResource
import net.minecraft.client.resources.IResourceManager; //导入方法依赖的package包/类
public static boolean hasResource(IResourceManager p_hasResource_0_, ResourceLocation p_hasResource_1_)
{
try
{
IResource iresource = p_hasResource_0_.getResource(p_hasResource_1_);
return iresource != null;
}
catch (IOException var3)
{
return false;
}
}
示例5: loadShader
import net.minecraft.client.resources.IResourceManager; //导入方法依赖的package包/类
public static ShaderLoader loadShader(IResourceManager resourceManager, ShaderLoader.ShaderType type, String filename) throws IOException
{
ShaderLoader shaderloader = (ShaderLoader)type.getLoadedShaders().get(filename);
if (shaderloader == null)
{
ResourceLocation resourcelocation = new ResourceLocation("shaders/program/" + filename + type.getShaderExtension());
IResource iresource = resourceManager.getResource(resourcelocation);
try
{
byte[] abyte = IOUtils.toByteArray((InputStream)(new BufferedInputStream(iresource.getInputStream())));
ByteBuffer bytebuffer = BufferUtils.createByteBuffer(abyte.length);
bytebuffer.put(abyte);
bytebuffer.position(0);
int i = OpenGlHelper.glCreateShader(type.getShaderMode());
OpenGlHelper.glShaderSource(i, bytebuffer);
OpenGlHelper.glCompileShader(i);
if (OpenGlHelper.glGetShaderi(i, OpenGlHelper.GL_COMPILE_STATUS) == 0)
{
String s = StringUtils.trim(OpenGlHelper.glGetShaderInfoLog(i, 32768));
JsonException jsonexception = new JsonException("Couldn\'t compile " + type.getShaderName() + " program: " + s);
jsonexception.setFilenameAndFlush(resourcelocation.getResourcePath());
throw jsonexception;
}
shaderloader = new ShaderLoader(type, i, filename);
type.getLoadedShaders().put(filename, shaderloader);
}
finally
{
IOUtils.closeQuietly((Closeable)iresource);
}
}
return shaderloader;
}
示例6: readImageData
import net.minecraft.client.resources.IResourceManager; //导入方法依赖的package包/类
public static int[] readImageData(IResourceManager resourceManager, ResourceLocation imageLocation) throws IOException
{
IResource iresource = null;
Object i;
try
{
iresource = resourceManager.getResource(imageLocation);
BufferedImage bufferedimage = readBufferedImage(iresource.getInputStream());
if (bufferedimage != null)
{
int j = bufferedimage.getWidth();
int i1 = bufferedimage.getHeight();
int[] aint1 = new int[j * i1];
bufferedimage.getRGB(0, 0, j, i1, aint1, 0, j);
int[] aint = aint1;
return aint;
}
i = null;
}
finally
{
IOUtils.closeQuietly((Closeable)iresource);
}
return (int[])i;
}
示例7: loadTexture
import net.minecraft.client.resources.IResourceManager; //导入方法依赖的package包/类
public void loadTexture(IResourceManager resourceManager) throws IOException
{
this.deleteGlTexture();
IResource iresource = null;
try
{
iresource = resourceManager.getResource(this.textureLocation);
BufferedImage bufferedimage = TextureUtil.readBufferedImage(iresource.getInputStream());
boolean flag = false;
boolean flag1 = false;
if (iresource.hasMetadata())
{
try
{
TextureMetadataSection texturemetadatasection = (TextureMetadataSection)iresource.getMetadata("texture");
if (texturemetadatasection != null)
{
flag = texturemetadatasection.getTextureBlur();
flag1 = texturemetadatasection.getTextureClamp();
}
}
catch (RuntimeException runtimeexception)
{
LOG.warn("Failed reading metadata of: {}", new Object[] {this.textureLocation, runtimeexception});
}
}
TextureUtil.uploadTextureImageAllocate(this.getGlTextureId(), bufferedimage, flag, flag1);
}
finally
{
IOUtils.closeQuietly((Closeable)iresource);
}
}
示例8: loadTexture
import net.minecraft.client.resources.IResourceManager; //导入方法依赖的package包/类
public void loadTexture(IResourceManager resourceManager) throws IOException
{
this.deleteGlTexture();
InputStream inputstream = null;
try
{
IResource iresource = resourceManager.getResource(this.textureLocation);
inputstream = iresource.getInputStream();
BufferedImage bufferedimage = TextureUtil.readBufferedImage(inputstream);
boolean flag = false;
boolean flag1 = false;
if (iresource.hasMetadata())
{
try
{
TextureMetadataSection texturemetadatasection = (TextureMetadataSection)iresource.getMetadata("texture");
if (texturemetadatasection != null)
{
flag = texturemetadatasection.getTextureBlur();
flag1 = texturemetadatasection.getTextureClamp();
}
}
catch (RuntimeException runtimeexception)
{
logger.warn((String)("Failed reading metadata of: " + this.textureLocation), (Throwable)runtimeexception);
}
}
TextureUtil.uploadTextureImageAllocate(this.getGlTextureId(), bufferedimage, flag, flag1);
}
finally
{
if (inputstream != null)
{
inputstream.close();
}
}
}
示例9: loadResource
import net.minecraft.client.resources.IResourceManager; //导入方法依赖的package包/类
public static IResource loadResource(IResourceManager manager, ResourceLocation location) throws IOException
{
resManager = manager;
resLocation = location;
return manager.getResource(location);
}
示例10: getResourceStream
import net.minecraft.client.resources.IResourceManager; //导入方法依赖的package包/类
public static InputStream getResourceStream(IResourceManager p_getResourceStream_0_, ResourceLocation p_getResourceStream_1_) throws IOException
{
IResource iresource = p_getResourceStream_0_.getResource(p_getResourceStream_1_);
return iresource == null ? null : iresource.getInputStream();
}
示例11: loadTexture
import net.minecraft.client.resources.IResourceManager; //导入方法依赖的package包/类
public void loadTexture(IResourceManager resourceManager) throws IOException
{
this.deleteGlTexture();
InputStream inputstream = null;
try
{
IResource iresource = resourceManager.getResource(this.textureLocation);
inputstream = iresource.getInputStream();
BufferedImage bufferedimage = TextureUtil.readBufferedImage(inputstream);
boolean flag = false;
boolean flag1 = false;
if (iresource.hasMetadata())
{
try
{
TextureMetadataSection texturemetadatasection = (TextureMetadataSection)iresource.getMetadata("texture");
if (texturemetadatasection != null)
{
flag = texturemetadatasection.getTextureBlur();
flag1 = texturemetadatasection.getTextureClamp();
}
}
catch (RuntimeException runtimeexception)
{
logger.warn((String)("Failed reading metadata of: " + this.textureLocation), (Throwable)runtimeexception);
}
}
if (Config.isShaders())
{
ShadersTex.loadSimpleTexture(this.getGlTextureId(), bufferedimage, flag, flag1, resourceManager, this.textureLocation, this.getMultiTexID());
}
else
{
TextureUtil.uploadTextureImageAllocate(this.getGlTextureId(), bufferedimage, flag, flag1);
}
}
finally
{
if (inputstream != null)
{
inputstream.close();
}
}
}
示例12: generateMipmaps
import net.minecraft.client.resources.IResourceManager; //导入方法依赖的package包/类
private boolean generateMipmaps(IResourceManager resourceManager, final TextureAtlasSprite texture)
{
ResourceLocation resourcelocation = this.getResourceLocation(texture);
IResource iresource = null;
label9:
{
boolean flag;
if (texture.hasCustomLoader(resourceManager, resourcelocation)) break label9;
try
{
iresource = resourceManager.getResource(resourcelocation);
texture.loadSpriteFrames(iresource, this.mipmapLevels + 1);
break label9;
}
catch (RuntimeException runtimeexception)
{
LOGGER.error("Unable to parse metadata from {}", new Object[] {resourcelocation, runtimeexception});
flag = false;
}
catch (IOException ioexception)
{
LOGGER.error("Using missing texture, unable to load {}", new Object[] {resourcelocation, ioexception});
flag = false;
return flag;
}
finally
{
IOUtils.closeQuietly((Closeable)iresource);
}
return flag;
}
try
{
texture.generateMipmaps(this.mipmapLevels);
return true;
}
catch (Throwable throwable)
{
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Applying mipmap");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Sprite being mipmapped");
crashreportcategory.setDetail("Sprite name", new ICrashReportDetail<String>()
{
public String call() throws Exception
{
return texture.getIconName();
}
});
crashreportcategory.setDetail("Sprite size", new ICrashReportDetail<String>()
{
public String call() throws Exception
{
return texture.getIconWidth() + " x " + texture.getIconHeight();
}
});
crashreportcategory.setDetail("Sprite frames", new ICrashReportDetail<String>()
{
public String call() throws Exception
{
return texture.getFrameCount() + " frames";
}
});
crashreportcategory.addCrashSection("Mipmap levels", Integer.valueOf(this.mipmapLevels));
throw new ReportedException(crashreport);
}
}
示例13: loadTexture
import net.minecraft.client.resources.IResourceManager; //导入方法依赖的package包/类
public void loadTexture(IResourceManager resourceManager) throws IOException
{
this.deleteGlTexture();
IResource iresource = null;
try
{
iresource = resourceManager.getResource(this.textureLocation);
BufferedImage bufferedimage = TextureUtil.readBufferedImage(iresource.getInputStream());
boolean flag = false;
boolean flag1 = false;
if (iresource.hasMetadata())
{
try
{
TextureMetadataSection texturemetadatasection = (TextureMetadataSection)iresource.getMetadata("texture");
if (texturemetadatasection != null)
{
flag = texturemetadatasection.getTextureBlur();
flag1 = texturemetadatasection.getTextureClamp();
}
}
catch (RuntimeException runtimeexception)
{
LOG.warn("Failed reading metadata of: {}", new Object[] {this.textureLocation, runtimeexception});
}
}
if (Config.isShaders())
{
ShadersTex.loadSimpleTexture(this.getGlTextureId(), bufferedimage, flag, flag1, resourceManager, this.textureLocation, this.getMultiTexID());
}
else
{
TextureUtil.uploadTextureImageAllocate(this.getGlTextureId(), bufferedimage, flag, flag1);
}
}
finally
{
IOUtils.closeQuietly((Closeable)iresource);
}
}