public ResourceLocation register(TextureManager manager, String prefix) { ResourceLocation location = new ResourceLocation(String.format("dynamic_o/%s_%d", prefix, textureCounter)); textureCounter++; manager.loadTexture(location, this); return location; }
private static boolean loadTexture(ResourceLocation loc, File file) { try { BufferedImage image = ImageIO.read(file); Minecraft.getMinecraft().renderEngine.loadTexture(loc, new TextureImageBased(loc, image)); return true; } catch (IOException e) { //noop } return false; }
public Panorama(String id, String suffix, int zoom) { this.id = id; this.textureLocation = new ResourceLocation(TerrariumEarth.MODID, "panorama_" + id.hashCode() + "_" + suffix); this.zoom = zoom; this.stitchedWidth = (1 << this.zoom) * BASE_PANORAMA_WIDTH; this.stitchedHeight = this.stitchedWidth / 2; this.texture = new DynamicTexture(this.stitchedWidth, this.stitchedHeight); MC.getTextureManager().loadTexture(this.textureLocation, this.texture); Thread thread = new Thread(this::loadTiles); thread.setName("Panorama Load Thread"); thread.setDaemon(true); thread.start(); }
@Override public Optional<ResourceLocation> loadSkinPackImage(String imageName, InputStream is) { try { BufferedImage image = ImageIO.read(is); ResourceLocation loc = new ResourceLocation("ancientwarfare:skinpack/" + imageName); TextureImageBased tex = new TextureImageBased(loc, image); Minecraft.getMinecraft().renderEngine.loadTexture(loc, tex); return Optional.of(loc); } catch (IOException e) { AncientWarfareNPC.LOG.error("Error reading image {}", imageName); } return Optional.empty(); }
private @Nonnull ResourceLocation getArmoredTexture(EntityHorse horse) { String s = horseArmorTextures[horse.getHorseArmorType().ordinal()]; ResourceLocation resourcelocation = textureCache.get(s); if (resourcelocation == null) { resourcelocation = new ResourceLocation("Layered:" + s); Minecraft.getMinecraft().getTextureManager().loadTexture(resourcelocation, new LayeredTexture(textureName, s)); textureCache.put(s, resourcelocation); } return resourcelocation; }
private static boolean loadTextureFromAssets(ResourceLocation loc, String path) { //noinspection ConstantConditions String fullPath = "assets/" + AncientWarfareCore.MOD_ID + "/" + path; File source = Loader.instance().activeModContainer().getSource(); if (source.isFile()) { try (FileSystem fs = FileSystems.newFileSystem(source.toPath(), null)) { InputStream inputstream = fs.provider().newInputStream(fs.getPath(fullPath)); Minecraft.getMinecraft().renderEngine.loadTexture(loc, new TextureImageBased(loc, ImageIO.read(inputstream))); return true; } catch (IOException e) { //noop } } else if (source.isDirectory()) { File file = source.toPath().resolve(fullPath).toFile(); if (loadTexture(loc, file)) { return true; } } return false; } }
/** * Attempts to download a resource from the web and load it into the game. If the resource * can not be downloaded successfully. * * @param url The URL to download the resource from. This should be the raw/source url. * @param outputResource The ResourceLocation to use for the newly downloaded resource. * @param defaultResource The default texture to use, on the chance that it fails to * download a texture. This must be a valid texture, or else you will get a missing * texture. * @param buffer A special buffer to use when downloading the image. It is okay to pass * null for this if you don't want anything fancy. * @return The downloaded image data. */ public static ThreadDownloadImageData downloadResource (String url, ResourceLocation outputResource, ResourceLocation defaultResource, IImageBuffer buffer) { final TextureManager manager = Minecraft.getMinecraft().getTextureManager(); ThreadDownloadImageData imageData = (ThreadDownloadImageData) manager.getTexture(outputResource); if (imageData == null) { imageData = new ThreadDownloadImageData(null, url, defaultResource, buffer); manager.loadTexture(outputResource, imageData); } return imageData; }
Minecraft.getMinecraft().getTextureManager().loadTexture(Laptop.ICON_TEXTURES, new DynamicTexture(atlas));
public TextureImageRenderer(final ResourceLocation location) { this.location = location; final TextureManager manager = Minecraft.getMinecraft().getTextureManager(); final ITextureObject image = manager.getTexture(location); if (image instanceof ImageTexture) { this.texture = (ImageTexture) image; } else { if (image != null && image.getGlTextureId() != -1) { TextureUtil.deleteTexture(image.getGlTextureId()); } this.texture = new ImageTexture(location); manager.loadTexture(location, texture); } }
@Override public CachedImage load(Image image) { ITextureObject textureObj = Minecraft.getMinecraft().getTextureManager().getTexture(resource); if(textureObj != null) { return new CachedImage(textureObj.getGlTextureId(), 0, 0, false); } else { AbstractTexture texture = new SimpleTexture(resource); if(Minecraft.getMinecraft().getTextureManager().loadTexture(resource, texture)) { return new CachedImage(texture.getGlTextureId(), 0, 0, false); } return new CachedImage(TextureUtil.MISSING_TEXTURE.getGlTextureId(), 0, 0, false); } } }
private void doInventoryRendering(ItemStack item, HeraldryData heraldryData, IHeraldryItem heraldryItem) { Minecraft.getMinecraft().getTextureManager().bindTexture(map_overlay); BattlegearRenderHelper.renderTexturedQuad(0, 0, itemRenderer.zLevel, 16, 16); //IIcon icon = heraldryItem.getBaseIcon(item); itemRenderer.zLevel += 100; glPushMatrix(); RefreshableTexture currentCrest = new RefreshableTexture(32, 32); currentCrest.refreshWith(heraldryData, false); ResourceLocation crestLocation = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("gui_crest", currentCrest); ITextureObject texture = Minecraft.getMinecraft().getTextureManager().getTexture(crestLocation); if(texture == null){ texture = new HeraldryTextureSmall(heraldryData); Minecraft.getMinecraft().getTextureManager().loadTexture(crestLocation, texture); } Minecraft.getMinecraft().getTextureManager().bindTexture(crestLocation); BattlegearRenderHelper.renderTexturedQuad(2, 2, itemRenderer.zLevel, 12, 12); glPopMatrix(); itemRenderer.zLevel -=100; } }
if(texture == null){ texture = new HeraldryTextureSmall(heraldryData); Minecraft.getMinecraft().getTextureManager().loadTexture(crestLocation, texture);