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


Java IResource.getInputStream方法代码示例

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


在下文中一共展示了IResource.getInputStream方法的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: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: fromTTF

import net.minecraft.client.resources.IResource; //导入方法依赖的package包/类
/**
 * Create a GLFont from a TTF file
 *
 * @param trace
 *            The debugging tracer object
 * @param px
 *            The font pixel size
 * @param ttf
 *            The TTF file
 * @return The GLFont result
 * @throws FontException
 *             Any exception which occurs when reading the TTF file, brewing
 *             the buffer or creating the final font.
 */
public static GLFont fromTTF(ITracer trace, float px, ResourceLocation ttf) throws FontException {
	if (trace == null)
		throw new IllegalArgumentException("trace may not be null");
	if (ttf == null)
		throw new IllegalArgumentException("ttf may not be null");
	try {
		IResource metricResource = Minecraft.getMinecraft().getResourceManager().getResource(ttf);
		InputStream stream = metricResource.getInputStream();
		if (stream == null)
			throw new IOException("Could not open TTF file.");
		Font sysfont = Font.createFont(Font.TRUETYPE_FONT, stream);
		if (trace != null)
			trace.trace("GLFont.fromTTF", sysfont.getName());
		return fromFont(trace, sysfont.deriveFont(px));
	} catch (IOException ioex) {
		trace.trace("GLFont.fromTTF", ioex);
		throw new FontException("Can't perform I/O operation!", ioex);
	} catch (FontFormatException ffe) {
		trace.trace("GLFont.fromTTF", ffe);
		throw new FontException("Invalid TTF file!", ffe);
	}
}
 
开发者ID:AfterLifeLochie,项目名称:fontbox,代码行数:37,代码来源:GLFont.java

示例9: loadModelBlockDefinition

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

    try
    {
        inputstream = p_188636_2_.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 \'" + p_188636_1_ + "\' from: \'" + p_188636_2_.getResourceLocation() + "\' in resourcepack: \'" + p_188636_2_.getResourcePackName() + "\'", exception);
    }
    finally
    {
        IOUtils.closeQuietly(inputstream);
    }

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

示例10: readChangeLogs

import net.minecraft.client.resources.IResource; //导入方法依赖的package包/类
public static List<Changelog> readChangeLogs() {
	try {
		IResource resource = Minecraft.getMinecraft().getResourceManager().getResource(CHANGELOG);
		InputStream resourceStream = resource.getInputStream();
		try {
			Reader reader = new InputStreamReader(resourceStream);
			Gson gson = new Gson();
			return gson.fromJson(reader, LIST_TYPE);
		} finally {
			resourceStream.close();
		}
	} catch (Exception e) {
		Log.severe(e, "Failed to read changelog");
	}
	return ImmutableList.of();
}
 
开发者ID:OpenMods,项目名称:OpenBlocks,代码行数:17,代码来源:ChangelogBuilder.java

示例11: LocatedTexture

import net.minecraft.client.resources.IResource; //导入方法依赖的package包/类
public LocatedTexture(ResourceLocation texture, int x, int y, double scale){
    this(texture, x, y, 0, 0);
    try {
        BufferedImage bufferedimage;
        if(texture.getResourcePath().startsWith("server")) {
            bufferedimage = ImageIO.read(new FileInputStream(new File(IGWMod.proxy.getSaveLocation() + File.separator + "igwmod" + File.separator + texture.getResourcePath().substring(7))));
        } else {
            IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(texture);
            InputStream inputstream = iresource.getInputStream();
            bufferedimage = ImageIO.read(inputstream);
        }
        width = (int)(bufferedimage.getWidth() * scale);
        height = (int)(bufferedimage.getHeight() * scale);
    } catch(Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:MineMaarten,项目名称:IGW-mod,代码行数:18,代码来源:LocatedTexture.java

示例12: Parser

import net.minecraft.client.resources.IResource; //导入方法依赖的package包/类
public Parser(IResource from, IResourceManager manager) throws IOException
{
    this.manager = manager;
    this.objFrom = from.getResourceLocation();
    this.objStream = new InputStreamReader(from.getInputStream(), StandardCharsets.UTF_8);
    this.objReader = new BufferedReader(objStream);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:8,代码来源:TintedOBJModel.java

示例13: postInit

import net.minecraft.client.resources.IResource; //导入方法依赖的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);
		*/
	}
}
 
开发者ID:SolraBizna,项目名称:j6502,代码行数:34,代码来源:ClientProxy.java

示例14: validateSoundResource

import net.minecraft.client.resources.IResource; //导入方法依赖的package包/类
private boolean validateSoundResource(Sound p_184401_1_, ResourceLocation p_184401_2_)
{
    ResourceLocation resourcelocation = p_184401_1_.getSoundAsOggLocation();
    IResource iresource = null;
    boolean flag;

    try
    {
        iresource = this.mcResourceManager.getResource(resourcelocation);
        iresource.getInputStream();
        return true;
    }
    catch (FileNotFoundException var11)
    {
        LOGGER.warn("File {} does not exist, cannot add it to event {}", new Object[] {resourcelocation, p_184401_2_});
        flag = false;
    }
    catch (IOException ioexception)
    {
        LOGGER.warn("Could not load sound file {}, cannot add it to event {}", new Object[] {resourcelocation, p_184401_2_, ioexception});
        flag = false;
        return flag;
    }
    finally
    {
        IOUtils.closeQuietly((Closeable)iresource);
    }

    return flag;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:31,代码来源:SoundHandler.java

示例15: Parser

import net.minecraft.client.resources.IResource; //导入方法依赖的package包/类
public Parser(IResource from, IResourceManager manager) throws IOException
{
    this.manager = manager;
    this.objFrom = from.getResourceLocation();
    this.objStream = new InputStreamReader(from.getInputStream(), Charsets.UTF_8);
    this.objReader = new BufferedReader(objStream);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:8,代码来源:OBJModel.java


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