当前位置: 首页>>代码示例>>Java>>正文


Java IResource类代码示例

本文整理汇总了Java中net.minecraft.client.resources.IResource的典型用法代码示例。如果您正苦于以下问题:Java IResource类的具体用法?Java IResource怎么用?Java IResource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IResource类属于net.minecraft.client.resources包,在下文中一共展示了IResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadModelFromResources

import net.minecraft.client.resources.IResource; //导入依赖的package包/类
/**
 * Load a model from a resource location.
 * Texture override is optional, it is used instead of the texture location generated from the modelResource.
 * Should be supplied in mods but not in the animator.
 * Null if not supplied
 */
public static <T extends ModelObj> T loadModelFromResources(String entityName, ResourceLocation modelResource, ResourceLocation textureOverride, Class<T> clazz)
{
	T model = null;
	
	try {
		IResource res = Minecraft.getMinecraft().getResourceManager().getResource(modelResource);
		
		File tmpFile = new File(entityName + ".obm");
		InputStream is = res.getInputStream();
		OutputStream os = new FileOutputStream(tmpFile);
		IOUtils.copy(is, os);
		is.close();
		os.close();
		model = FileLoader.fromFile(tmpFile, textureOverride, clazz);
		if(textureOverride != null) 
			model.setTexture(textureOverride);
		tmpFile.delete();
	} catch (IOException e) {
		System.out.println("Could not load " + entityName + " model from resource");
		e.printStackTrace();
	}

	return model;
}
 
开发者ID:ObsidianSuite,项目名称:ObsidianSuite,代码行数:31,代码来源:FileLoader.java

示例2: checkTestSuccess

import net.minecraft.client.resources.IResource; //导入依赖的package包/类
/**
 * Checks if the test resource is registered, if not stop the game and throw a
 * {@link RuntimeException}.
 */
public static void checkTestSuccess() {
    try {
        IResource resource = Minecraft.getMinecraft().getResourceManager().getResource(new
                ResourceLocation
                ("novous_test_linker:test_resource"));
        if (resource instanceof LinkedResourceManager.LinkedStreamResource) {
            InputStream stream = resource.getInputStream();
            String yesString = IOUtils.toString(stream);
            if (!yesString.equals("yes")) {
                throw new RuntimeException();
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
        throw new RuntimeException();
    }
}
 
开发者ID:PizzaCrust,项目名称:Novous,代码行数:22,代码来源:TestResourceLinker.java

示例3: loadNSMap1

import net.minecraft.client.resources.IResource; //导入依赖的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);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:26,代码来源:ShadersTex.java

示例4: loadMultipartMBD

import net.minecraft.client.resources.IResource; //导入依赖的package包/类
private ModelBlockDefinition loadMultipartMBD(ResourceLocation location, ResourceLocation fileIn)
{
    List<ModelBlockDefinition> list = Lists.<ModelBlockDefinition>newArrayList();

    try
    {
        for (IResource iresource : this.resourceManager.getAllResources(fileIn))
        {
            list.add(this.loadModelBlockDefinition(location, iresource));
        }
    }
    catch (IOException ioexception)
    {
        throw new RuntimeException("Encountered an exception when loading model definition of model " + fileIn, ioexception);
    }

    return new ModelBlockDefinition(list);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:19,代码来源:ModelBakery.java

示例5: loadModelBlockDefinition

import net.minecraft.client.resources.IResource; //导入依赖的package包/类
private ModelBlockDefinition loadModelBlockDefinition(ResourceLocation location, IResource resource)
{
    InputStream inputstream = null;
    ModelBlockDefinition lvt_4_1_;

    try
    {
        inputstream = resource.getInputStream();
        lvt_4_1_ = ModelBlockDefinition.parseFromReader(new InputStreamReader(inputstream, Charsets.UTF_8));
    }
    catch (Exception exception)
    {
        throw new RuntimeException("Encountered an exception when loading model definition of \'" + location + "\' from: \'" + resource.getResourceLocation() + "\' in resourcepack: \'" + resource.getResourcePackName() + "\'", exception);
    }
    finally
    {
        IOUtils.closeQuietly(inputstream);
    }

    return lvt_4_1_;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:22,代码来源:ModelBakery.java

示例6: readGlyphSizes

import net.minecraft.client.resources.IResource; //导入依赖的package包/类
private void readGlyphSizes()
{
    IResource iresource = null;

    try
    {
        iresource = this.getResource(new ResourceLocation("font/glyph_sizes.bin"));
        iresource.getInputStream().read(this.glyphWidth);
    }
    catch (IOException ioexception)
    {
        throw new RuntimeException(ioexception);
    }
    finally
    {
        IOUtils.closeQuietly((Closeable)iresource);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:19,代码来源:FontRenderer.java

示例7: GuiMainMenu

import net.minecraft.client.resources.IResource; //导入依赖的package包/类
public GuiMainMenu() {
	this.openGLWarning2 = MORE_INFO_TEXT;
	IResource iresource = null;
	
	this.splashText = "uhoh";

	this.splashText = Splashes.getSplashes()[new Random().nextInt(Splashes.getSplashes().length)];

	this.updateCounter = RANDOM.nextFloat();
	this.openGLWarning1 = "";

	if (!GLContext.getCapabilities().OpenGL20 && !OpenGlHelper.areShadersSupported()) {
		this.openGLWarning1 = I18n.format("title.oldgl1", new Object[0]);
		this.openGLWarning2 = I18n.format("title.oldgl2", new Object[0]);
		this.openGLWarningLink = "https://help.mojang.com/customer/portal/articles/325948?ref=game";
	}

	String s1 = System.getProperty("java.version");

	if (s1 != null && (s1.startsWith("1.6") || s1.startsWith("1.7"))) {
		this.openGLWarning1 = I18n.format("title.oldjava1", new Object[0]);
		this.openGLWarning2 = I18n.format("title.oldjava2", new Object[0]);
		this.openGLWarningLink = "https://help.mojang.com/customer/portal/articles/2636196?ref=game";
	}
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:26,代码来源:GuiMainMenu.java

示例8: readImageData

import net.minecraft.client.resources.IResource; //导入依赖的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;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:23,代码来源:TextureUtil.java

示例9: readGlyphSizes

import net.minecraft.client.resources.IResource; //导入依赖的package包/类
private void readGlyphSizes()
{
    IResource iresource = null;

    try
    {
        iresource = getResource(new ResourceLocation("font/glyph_sizes.bin"));
        iresource.getInputStream().read(this.glyphWidth);
    }
    catch (IOException ioexception)
    {
        throw new RuntimeException(ioexception);
    }
    finally
    {
        IOUtils.closeQuietly((Closeable)iresource);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:19,代码来源:FontRenderer.java

示例10: load

import net.minecraft.client.resources.IResource; //导入依赖的package包/类
public boolean load(final IResourceManager manager, final ResourceLocation oldlocation) {
    ResourceLocation location = new ResourceLocation(this.baseIcon);
    location = this.completeResourceLocation(location);
    try {
        final int mipmapLevels = Minecraft.getMinecraft().gameSettings.mipmapLevels;
        final int anisotropicFiltering = Minecraft.getMinecraft().gameSettings.anisotropicFiltering;
        final IResource iresource = manager.getResource(location);
        final BufferedImage[] abufferedimage = new BufferedImage[1 + mipmapLevels];
        abufferedimage[0] = ImageIO.read(iresource.getInputStream());
        final AnimationMetadataSection animationmetadatasection = (AnimationMetadataSection)iresource.getMetadata("animation");
        abufferedimage[0] = this.processImage(abufferedimage[0], animationmetadatasection);
        this.loadSprite(abufferedimage, animationmetadatasection, anisotropicFiltering > 1.0f);
    }
    catch (RuntimeException runtimeexception) {
        FMLClientHandler.instance().trackBrokenTexture(location, runtimeexception.getMessage());
        return true;
    }
    catch (IOException ioexception1) {
        FMLClientHandler.instance().trackMissingTexture(location);
        return true;
    }
    return false;
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:24,代码来源:TextureDerived.java

示例11: altLoadSprite

import net.minecraft.client.resources.IResource; //导入依赖的package包/类
public void altLoadSprite(final IResource par1Resource) throws IOException {
    this.setFramesTextureData((List)Lists.newArrayList());
    this.frameCounter = 0;
    this.tickCounter = 0;
    final InputStream inputstream = par1Resource.getInputStream();
    final BufferedImage bufferedimage = ImageIO.read(inputstream);
    this.height = bufferedimage.getHeight() / this.grid_h;
    this.width = bufferedimage.getWidth() / this.grid_w;
    if (this.height < this.grid_h || this.width < this.grid_w) {
        throw new RuntimeException("Texture too small, must be at least " + this.grid_w + " pixels wide and " + this.grid_h + " pixels tall");
    }
    if (this.grid_x < 0 || this.grid_x >= this.grid_w) {
        throw new RuntimeException("GridTextureIcon called with an invalid grid_x");
    }
    if (this.grid_y < 0 || this.grid_y >= this.grid_h) {
        throw new RuntimeException("GridTextureIcon called with an invalid grid_y");
    }
    final int[] aint = new int[this.height * this.width];
    bufferedimage.getRGB(this.grid_x * this.width, this.grid_y * this.height, this.width, this.height, aint, 0, this.width);
    if (this.height != this.width) {
        throw new RuntimeException("broken aspect ratio, must be in ratio: " + this.grid_w + ":" + this.grid_h);
    }
    this.framesTextureData.add(this.prepareAnisotropicFiltering(aint, this.width, this.height, Minecraft.getMinecraft().gameSettings.mipmapLevels, Minecraft.getMinecraft().gameSettings.anisotropicFiltering > 1.0f));
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:25,代码来源:TextureMultiIcon.java

示例12: preInit

import net.minecraft.client.resources.IResource; //导入依赖的package包/类
@Override
public void preInit(@Nonnull final FMLPreInitializationEvent event) {
	super.preInit(event);
	
	// Extract the preset config files present in the JAR
	final IResourceManager manager = Minecraft.getMinecraft().getResourceManager();

	for(final String preset : presetFiles) {
		final String name = preset + ".presets";
		try {
			final IResource r = manager.getResource(new ResourceLocation(Presets.MOD_ID, "data/" + name));
			try(final InputStream stream = r.getInputStream()) {
				Streams.copy(stream, new File(Presets.dataDirectory(), name));
			}
		} catch(final Throwable t) {
			Presets.log().error("Unable to extract preset file " + name, t);
		}
	}
}
 
开发者ID:OreCruncher,项目名称:DynamicSurroundings,代码行数:20,代码来源:ProxyClient.java

示例13: loadMBD

import net.minecraft.client.resources.IResource; //导入依赖的package包/类
public ModelBlockDefinition loadMBD(ResourceLocation file) {
    List<ModelBlockDefinition> list = new ArrayList<>();

    try {
        for (IResource resource : modelLoader.resourceManager.getAllResources(file)) {
            list.add(load(resource.getInputStream()));
        }
    } catch (FileNotFoundException ignore) {
    } catch (IOException e) {
        throw new RuntimeException("Encountered an exception when loading model definition of model " + file, e);
    }
    if (list.isEmpty()) {
        return null;
    }
    return new ModelBlockDefinition(list);
}
 
开发者ID:TheCBProject,项目名称:CodeChickenLib,代码行数:17,代码来源:CCBlockStateLoader.java

示例14: get

import net.minecraft.client.resources.IResource; //导入依赖的package包/类
public static TemplateLibrary get(String path)
{
    TemplateLibrary lib = LIBRARIES.get(path);
    if (lib == null)
    {
        try
        {
            lib = new TemplateLibrary();

            IResource res = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation(path));
            InputStream stream = res.getInputStream();
            lib.parseLibrary(stream);

            LIBRARIES.put(path, lib);
        }
        catch (IOException | ParserConfigurationException | SAXException e)
        {
            // TODO: Fail
        }
    }

    return lib;
}
 
开发者ID:gigaherz,项目名称:Guidebook,代码行数:24,代码来源:TemplateLibrary.java

示例15: autosize

import net.minecraft.client.resources.IResource; //导入依赖的package包/类
private void autosize() {
    Pair<Integer, Integer> cached = size_cache.get(resource);
    if (cached != null) {
        width = cached.getLeft();
        height = cached.getRight();
        return;
    }

    IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager();
    IResource iresource = null;
    InputStream is = null;
    try {
        iresource = resourceManager.getResource(resource);
        is = iresource.getInputStream();
        BufferedImage bufferedimage = ImageIO.read(is);
        this.width = bufferedimage.getWidth();
        this.height = bufferedimage.getHeight();
        size_cache.put(resource, Pair.of(width, height));
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        FzUtil.closeNoisily("reading size of image", is);
    }
}
 
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:25,代码来源:ImgWord.java


注:本文中的net.minecraft.client.resources.IResource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。