本文整理汇总了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;
}
示例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();
}
}
示例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_;
}
示例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));
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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_;
}
示例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();
}
示例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();
}
}
示例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);
}
示例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);
*/
}
}
示例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;
}
示例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);
}