本文整理匯總了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;
}
示例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: 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);
}
}
示例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);
}
示例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_;
}
示例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);
}
}
示例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";
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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));
}
示例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);
}
}
}
示例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);
}
示例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;
}
示例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);
}
}