net.minecraft.client.renderer.texture.DynamicTexture Java Examples
The following examples show how to use
net.minecraft.client.renderer.texture.DynamicTexture.
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: LocatedTexture.java From IGW-mod with GNU General Public License v2.0 | 6 votes |
public LocatedTexture(ResourceLocation texture, int x, int y, int width, int height){ this.texture = texture; this.x = x; this.y = y; this.width = width; this.height = height; if(texture.getResourcePath().startsWith("server")) { try { BufferedImage image = ImageIO.read(new FileInputStream(new File(IGWMod.proxy.getSaveLocation() + File.separator + "igwmod" + File.separator + texture.getResourcePath().substring(7)))); DynamicTexture t = new DynamicTexture(image); textureId = t.getGlTextureId(); } catch(Exception e) { e.printStackTrace(); } } }
Example #2
Source File: GuiCustomizeWorld.java From YUNoMakeGoodMap with Apache License 2.0 | 6 votes |
private StructInfo getInfo(ResourceLocation res) { StructInfo ret = structInfo.get(res); if (ret != null) return ret; try { IResource ir = this.mc.getResourceManager().getResource(new ResourceLocation(res.getResourceDomain(), "structures/" + res.getResourcePath() + ".json")); ret = GSON.fromJson(new InputStreamReader(ir.getInputStream()), StructInfo.class); if (ret.logo != null) { ir = this.mc.getResourceManager().getResource(new ResourceLocation(res.getResourceDomain(), "structures/" + ret.logo)); if (ir != null) { BufferedImage l = ImageIO.read(ir.getInputStream()); ret.logoPath = this.mc.getTextureManager().getDynamicTextureLocation("platformlogo", new DynamicTexture(l)); ret.logoSize = new Dimension(l.getWidth(), l.getHeight()); } } } catch (IOException e) { //Ugh wish it had a 'hasResource' } if (ret == null) ret = new StructInfo(); if (ret.name == null) ret.name = res.toString(); structInfo.put(res, ret); return ret; }
Example #3
Source File: DynamicTextureWrapper.java From MediaMod with GNU General Public License v3.0 | 6 votes |
/** * Get resource location from url * * @param url - url to get the file from * @return ResourceLocation */ public static ResourceLocation getTexture(URL url) { init(); if (!URL_TEXTURES.containsKey(url)) { URL_TEXTURES.put(url, new WrappedResource(null)); queueImage(url); } WrappedResource wr = URL_TEXTURES.get(url); if (wr.location == null) { if (URL_IMAGES.get(url) != null && URL_IMAGES.get(url).image != null) { DynamicTexture texture = new DynamicTexture(URL_IMAGES.get(url).image); WrappedResource wr2 = new WrappedResource(FMLClientHandler.instance().getClient().getTextureManager().getDynamicTextureLocation(url.toString(), texture)); URL_TEXTURES.put(url, wr2); return wr2.location; } else { return FULLY_TRANSPARENT_TEXTURE; } } return wr.location; }
Example #4
Source File: CapeManager.java From seppuku with GNU General Public License v3.0 | 6 votes |
/** * Download and cache each cape for each user * TODO thread this */ protected void downloadCapes() { try { if (Minecraft.getMinecraft().getTextureManager() != null) { for (CapeUser user : this.capeUserList) { if (user != null) { final ResourceLocation cape = this.findResource(user.getCape()); if (cape == null) { final DynamicTexture texture = new DynamicTexture(ImageIO.read(new URL("http://seppuku.pw/files/" + user.getCape()))); if (texture != null) { final ResourceLocation location = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("seppuku/capes", texture); if (location != null) { this.capesMap.put(user.getCape(), location); } } } } } } } catch (Exception e) { e.printStackTrace(); } }
Example #5
Source File: FileManager.java From LiquidBounce with GNU General Public License v3.0 | 6 votes |
/** * Load background for background */ public void loadBackground() { if(backgroundFile.exists()) { try { final BufferedImage bufferedImage = ImageIO.read(new FileInputStream(backgroundFile)); if(bufferedImage == null) return; LiquidBounce.INSTANCE.setBackground(new ResourceLocation(LiquidBounce.CLIENT_NAME.toLowerCase() + "/background.png")); mc.getTextureManager().loadTexture(LiquidBounce.INSTANCE.getBackground(), new DynamicTexture(bufferedImage)); ClientUtils.getLogger().info("[FileManager] Loaded background."); }catch(final Exception e) { ClientUtils.getLogger().error("[FileManager] Failed to load background.", e); } } }
Example #6
Source File: WorldSaveRow.java From BoundingBoxOutlineReloaded with MIT License | 6 votes |
private DynamicTexture loadIcon() { if (this.iconFile == null || !this.iconFile.isFile()) { this.client.getTextureManager().deleteTexture(this.iconLocation); return null; } try (InputStream stream = new FileInputStream(this.iconFile)) { DynamicTexture texture = new DynamicTexture(NativeImage.read(stream)); this.client.getTextureManager().loadTexture(this.iconLocation, texture); return texture; } catch (Throwable exception) { LOGGER.error("Invalid icon for world {}", this.worldSummary.getFileName(), exception); this.iconFile = null; return null; } }
Example #7
Source File: GuiHyperiumScreen.java From Hyperium with GNU Lesser General Public License v3.0 | 6 votes |
private static boolean getCustomBackground() { if (dynamicBackgroundTexture != null) return true; if (customImage.exists()) { BufferedImage bufferedImage; try { bufferedImage = ImageIO.read(new FileInputStream(customImage)); } catch (Exception e) { e.printStackTrace(); return false; } if (bufferedImage != null && dynamicBackgroundTexture == null) { dynamicBackgroundTexture = Minecraft.getMinecraft().getRenderManager().renderEngine.getDynamicTextureLocation(customImage.getName(), new DynamicTexture(bufferedImage)); } } else { return false; } return true; }
Example #8
Source File: WidgetSchematicBrowser.java From litematica with GNU Lesser General Public License v3.0 | 6 votes |
protected void cacheSchematicData(DirectoryEntry entry) { File file = new File(entry.getDirectory(), entry.getName()); if (this.cachedData.containsKey(file) == false) { NBTTagCompound tag = NBTUtils.readNbtFromFile(file); CachedSchematicData data = null; if (tag != null) { ISchematic schematic = SchematicType.tryCreateSchematicFrom(file, tag); if (schematic != null) { SchematicMetadata metadata = schematic.getMetadata(); ResourceLocation iconName = new ResourceLocation(Reference.MOD_ID, file.getAbsolutePath()); DynamicTexture texture = this.createPreviewImage(iconName, metadata); data = new CachedSchematicData(tag, schematic, iconName, texture); } } this.cachedData.put(file, data); } }
Example #9
Source File: MapDownloader.java From ForgeHax with MIT License | 6 votes |
private void downloadMap(MapData data, String fileName, Integer scaledRes) { if (fileName == null) { fileName = data.mapName; } ResourceLocation location = findResourceLocation(data.mapName); if (location == null) { Helper.printMessage("Failed to find ResourceLocation"); return; } DynamicTexture texture = (DynamicTexture) MC.getTextureManager().getTexture(location); BufferedImage image = dynamicToImage(texture); if (scaledRes != null) { image = createResizedCopy(image, scaledRes, scaledRes, true); } saveImage(fileName, image); }
Example #10
Source File: WidgetSchematicBrowser.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
@Nullable private DynamicTexture createPreviewImage(ResourceLocation iconName, SchematicMetadata meta) { int[] previewImageData = meta.getPreviewImagePixelData(); if (previewImageData != null && previewImageData.length > 0) { try { int size = (int) Math.sqrt(previewImageData.length); if (size * size == previewImageData.length) { //BufferedImage buf = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB); //buf.setRGB(0, 0, size, size, previewImageData, 0, size); DynamicTexture tex = new DynamicTexture(size, size); this.mc.getTextureManager().loadTexture(iconName, tex); System.arraycopy(previewImageData, 0, tex.getTextureData(), 0, previewImageData.length); tex.updateDynamicTexture(); return tex; } } catch (Exception e) { } } return null; }
Example #11
Source File: NewThreadDownloadImageData.java From Et-Futurum with The Unlicense | 5 votes |
private void checkTextureUploaded() { if (!textureUploaded) if (bufferedImage != null) { if (textureLocation != null) deleteGlTexture(); TextureUtil.uploadTextureImage(super.getGlTextureId(), bufferedImage); if (imgDownload != null) { BufferedImage oldStyleImg = imgDownload.getOldSyleImage(); Minecraft.getMinecraft().getTextureManager().loadTexture(resLocationOld, new DynamicTexture(oldStyleImg)); } textureUploaded = true; } }
Example #12
Source File: CFont.java From ForgeHax with MIT License | 5 votes |
protected DynamicTexture setupTexture( Font font, boolean antiAlias, boolean fractionalMetrics, CharData[] chars) { BufferedImage img = generateFontImage(font, antiAlias, fractionalMetrics, chars); try { return new DynamicTexture(img); } catch (Exception e) { e.printStackTrace(); } return null; }
Example #13
Source File: WaifuESP.java From ForgeHax with MIT License | 5 votes |
@Override public void onLoad() { MC.addScheduledTask( () -> { try { BufferedImage image; if (waifuCache.exists()) { // TODO: download async image = getImage(waifuCache, ImageIO::read); // from cache } else { image = getImage(new URL(waifuUrl), ImageIO::read); // from internet if (image != null) { try { ImageIO.write(image, "png", waifuCache); } catch (IOException ex) { ex.printStackTrace(); } } } if (image == null) { LOGGER.warn("Failed to download waifu image"); return; } DynamicTexture dynamicTexture = new DynamicTexture(image); dynamicTexture.loadTexture(MC.getResourceManager()); waifu = MC.getTextureManager().getDynamicTextureLocation("WAIFU", dynamicTexture); } catch (Exception e) { e.printStackTrace(); } }); }
Example #14
Source File: MapMod.java From ForgeHax with MIT License | 5 votes |
private void updateHeldMapTexture(String url) { if (MC.player == null || !(MC.player.getHeldItemMainhand().getItem() instanceof ItemMap)) { return; } MC.addScheduledTask( () -> { // allows DynamicTexture to work ItemMap map = (ItemMap) MC.player.getHeldItemMainhand().getItem(); MapData heldMapData = map.getMapData(MC.player.getHeldItemMainhand(), MC.world); try { BufferedImage image = getImageFromUrl(url); DynamicTexture dynamicTexture = new DynamicTexture(image); dynamicTexture.loadTexture(MC.getResourceManager()); Map<ResourceLocation, ITextureObject> mapTextureObjects = FastReflection.Fields.TextureManager_mapTextureObjects.get(MC.getTextureManager()); ResourceLocation textureLocation = mapTextureObjects .keySet() .stream() .filter(k -> k.getResourcePath().contains(heldMapData.mapName)) .findFirst() .orElse(null); mapTextureObjects.put( textureLocation, dynamicTexture); // overwrite old texture with our custom one } catch (Exception e) { e.printStackTrace(); } }); }
Example #15
Source File: MapDownloader.java From ForgeHax with MIT License | 5 votes |
private BufferedImage dynamicToImage(DynamicTexture texture) { int[] data = texture.getTextureData(); BufferedImage image = new BufferedImage(128, 128, 2); image.setRGB(0, 0, image.getWidth(), image.getHeight(), data, 0, 128); return image; }
Example #16
Source File: WidgetSchematicBrowser.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
protected CachedSchematicData(NBTTagCompound tag, ISchematic schematic, ResourceLocation iconName, @Nullable DynamicTexture texture) { this.tag = tag; this.schematic = schematic; this.iconName = iconName; this.texture = texture; }
Example #17
Source File: GuiDownloadTofuTerrain.java From TofuCraftReload with MIT License | 5 votes |
public GuiDownloadTofuTerrain() { super(); this.mc = FMLClientHandler.instance().getClient(); this.viewportTexture = new DynamicTexture(256, 256); this.panoramaBackground = mc.getTextureManager().getDynamicTextureLocation("background", viewportTexture); this.prevTime = Minecraft.getSystemTime(); }
Example #18
Source File: DynamicTextureWrapper.java From MediaMod with GNU General Public License v3.0 | 5 votes |
/** * Initialize key components */ private static void init() { if (!INITIALIZED) { try { GLContext.getCapabilities(); } catch (RuntimeException ignored) { return; } FULLY_TRANSPARENT_TEXTURE = FMLClientHandler.instance().getClient().getTextureManager().getDynamicTextureLocation( "mediamod", new DynamicTexture(FULLY_TRANSPARENT_IMAGE)); INITIALIZED = true; } }
Example #19
Source File: ButtonBanner.java From SkyblockAddons with MIT License | 5 votes |
@Override public void drawButton(Minecraft mc, int mouseX, int mouseY) { if (bannerImage != null && banner == null) { // This means it was just loaded from the URL above. banner = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("banner", new DynamicTexture(bannerImage)); } if (banner != null) { // Could have not been loaded yet. float alphaMultiplier = 1F; if (main.getUtils().isFadingIn()) { long timeSinceOpen = System.currentTimeMillis() - timeOpened; int fadeMilis = 500; if (timeSinceOpen <= fadeMilis) { alphaMultiplier = (float) timeSinceOpen / fadeMilis; } } float scale = (float) WIDTH / bannerImage.getWidth(); // max width hovered = mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + WIDTH && mouseY < yPosition + bannerImage.getHeight() * scale; GlStateManager.enableBlend(); if (hovered) { GlStateManager.color(1, 1, 1, alphaMultiplier * 1); } else { GlStateManager.color(1, 1, 1, alphaMultiplier * 0.8F); } mc.getTextureManager().bindTexture(banner); GlStateManager.pushMatrix(); GlStateManager.scale(scale, scale, 1); drawModalRectWithCustomSizedTexture(Math.round(xPosition / scale), Math.round(yPosition / scale), 0, 0, width, height, width, height); GlStateManager.popMatrix(); } }
Example #20
Source File: Utils.java From SkyblockAddons with MIT License | 4 votes |
/** * * Enter a resource location, width, and height and this will * rescale that image in a new thread, and return a new dynamic * texture. * * While the image is processing in the other thread, it will * return the original image, but *at most* it should take a few * seconds. * * Once the image is processed the result is cached in the map, * and will not be re-done. If you need this resource location * to be scaled again, set the redo flag to true. * * @param resourceLocation The original image to scale. * @param width The width to scale to. * @param height The Height to scale to. * @param redo Whether to redo the scaling if it is already complete. * @return Either the scaled resource if it is complete, or the original resource if not. */ public ResourceLocation getScaledResource(ResourceLocation resourceLocation, int width, int height, boolean redo) { TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); if (!redo && rescaled.containsKey(resourceLocation)) { Object object = rescaled.get(resourceLocation); if (object instanceof ResourceLocation) { return (ResourceLocation) object; } else if (object instanceof BufferedImage) { String name = "sba_scaled_"+resourceLocation.getResourcePath().replace("/", "_").replace(".", "_"); ResourceLocation scaledResourceLocation = textureManager.getDynamicTextureLocation(name, new DynamicTexture((BufferedImage) object)); rescaled.put(resourceLocation, scaledResourceLocation); return scaledResourceLocation; } } if (rescaling.contains(resourceLocation)) return resourceLocation; // Not done yet. if (redo) { if (rescaled.containsKey(resourceLocation)) { Object removed = rescaled.remove(resourceLocation); if (removed instanceof ResourceLocation) { textureManager.deleteTexture((ResourceLocation)removed); } } } rescaling.add(resourceLocation); new Thread(() -> { try { BufferedImage originalImage = ImageIO.read(SkyblockAddonsGui.class.getClassLoader().getResourceAsStream("assets/"+resourceLocation.getResourceDomain()+"/"+resourceLocation.getResourcePath())); Image scaledImageAbstract = originalImage.getScaledInstance(width, height, Image.SCALE_SMOOTH); BufferedImage scaledImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics graphics = scaledImage.getGraphics(); graphics.drawImage(scaledImageAbstract, 0, 0, null); graphics.dispose(); rescaled.put(resourceLocation, scaledImage); rescaling.remove(resourceLocation); } catch (Exception ex) { ex.printStackTrace(); rescaled.put(resourceLocation, resourceLocation); rescaling.remove(resourceLocation); } }).start(); return resourceLocation; // Processing has started in another thread, but not done yet. }
Example #21
Source File: NotificationCenter.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
/** * Set the display image for this notification * * @param img Img to display */ void setImage(BufferedImage img) { Minecraft.getMinecraft().addScheduledTask(() -> { this.img = img != null ? new DynamicTexture(img) : null; }); }
Example #22
Source File: GlyphPage.java From ClientBase with MIT License | 4 votes |
public void setupTexture() { loadedTexture = new DynamicTexture(bufferedImage); }
Example #23
Source File: GuiCustom.java From Custom-Main-Menu with MIT License | 4 votes |
@Override public void initGui() { GlStateManager.disableTexture2D(); GlStateManager.enableBlend(); GlStateManager.disableAlpha(); GlStateManager.shadeModel(7425); GlStateManager.shadeModel(7424); GlStateManager.disableBlend(); GlStateManager.enableAlpha(); GlStateManager.enableTexture2D(); if (!loadedSplashText && guiConfig.splashText != null) { if (guiConfig.splashText.synced) { this.splashText = CustomMainMenu.INSTANCE.config.getGUI("mainmenu").splashText; } else { loadSplashTexts(); } loadedSplashText = true; } textLabels = new ArrayList<GuiCustomLabel>(); buttonCounter = 0; this.viewportTexture = new DynamicTexture(256, 256); this.field_110351_G = this.mc.getTextureManager().getDynamicTextureLocation("background", this.viewportTexture); Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); if (calendar.get(2) + 1 == 11 && calendar.get(5) == 9) { this.splashText = "Happy birthday, ez!"; } else if (calendar.get(2) + 1 == 6 && calendar.get(5) == 1) { this.splashText = "Happy birthday, Notch!"; } else if (calendar.get(2) + 1 == 12 && calendar.get(5) == 24) { this.splashText = "Merry X-mas!"; } else if (calendar.get(2) + 1 == 1 && calendar.get(5) == 1) { this.splashText = "Happy new year!"; } else if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31) { this.splashText = "OOoooOOOoooo! Spooky!"; } int idCounter = 6000; // Add Custom Buttons for (Button b : guiConfig.customButtons) { if (b.wrappedButtonID != -1) { this.buttonList.add(alignButton(b, new GuiCustomWrappedButton(b.wrappedButtonID, b.wrappedButtonID, b))); } else { this.buttonList.add(alignButton(b, new GuiCustomButton(idCounter, b))); idCounter++; } } // Add Labels for (Label t : guiConfig.customLabels) { textLabels.add(new GuiCustomLabel(this, t, modX(t.posX, t.alignment), modY(t.posY, t.alignment))); } }