Java Code Examples for net.minecraft.client.resources.IResourceManager#getResource()
The following examples show how to use
net.minecraft.client.resources.IResourceManager#getResource() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HarvesterAnimationStateMachine.java From EmergingTechnology with MIT License | 6 votes |
/** * Load a new instance of HarvesterAnimationStateMachine at specified location, * with specified custom parameters. */ @SideOnly(Side.CLIENT) public static HarvesterAnimationStateMachine load(IResourceManager manager, ResourceLocation location, ImmutableMap<String, ITimeValue> customParameters) { try (IResource resource = manager.getResource(location)) { ClipResolver clipResolver = new ClipResolver(); ParameterResolver parameterResolver = new ParameterResolver(customParameters); Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(clipResolver); TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(parameterResolver); HarvesterAnimationStateMachine asm = asmGson.fromJson( new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8), HarvesterAnimationStateMachine.class); clipResolver.asm = asm; parameterResolver.asm = asm; asm.initialize(); return asm; } catch (IOException | JsonParseException e) { FMLLog.log.error("Exception loading Animation State Machine {}, skipping", location, e); return missing; } finally { Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(null); TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(null); } }
Example 2
Source File: TextureDynamic.java From ExNihiloAdscensio with MIT License | 6 votes |
private BufferedImage tryLoadImage(IResourceManager manager, ResourceLocation location) { try { IResource res = manager.getResource(location); BufferedImage imgOutput = ImageIO.read(res.getInputStream()); return imgOutput; } catch (Exception e) { //ExNihilo.log.error("Failed to load image: " + location.toString()); return null; } }
Example 3
Source File: BaseTexture.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
protected BufferedImage loadImage(IResourceManager resourceManager, ResourceLocation location) throws IOException { InputStream inputstream = null; try { IResource iresource = resourceManager.getResource(location); inputstream = iresource.getInputStream(); return ImageIO.read(inputstream); } finally { if (inputstream != null) { inputstream.close(); } } }
Example 4
Source File: TextureDynamic.java From ExNihiloAdscensio with MIT License | 5 votes |
@Override public boolean hasCustomLoader(IResourceManager manager, ResourceLocation location) { try { manager.getResource(location); } catch (Exception e) { return true; } // ExNihiloAdscensio.log.info("Icon: " + template + " was overwritten by a texturepack or embedded resource."); return false; }
Example 5
Source File: GolemGuiTexture.java From Gadomancy with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void loadTexture(IResourceManager resourceManager) throws IOException { this.deleteGlTexture(); InputStream inputstream = null; try { IResource iresource = resourceManager.getResource(this.textureLocation); inputstream = iresource.getInputStream(); BufferedImage bufferedimage = manipulateImage(resourceManager, ImageIO.read(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("Failed reading metadata of: " + this.textureLocation, runtimeexception); } } TextureUtil.uploadTextureImageAllocate(this.getGlTextureId(), bufferedimage, flag, flag1); } finally { if (inputstream != null) { inputstream.close(); } } }