Class UIExternalTexture

java.lang.Object
io.github.thecsdev.tcdcommons.api.client.gui.util.UITexture
io.github.thecsdev.tcdcommons.api.client.gui.util.UIExternalTexture
All Implemented Interfaces:
Closeable, AutoCloseable

public final class UIExternalTexture extends UITexture implements Closeable
A UITexture that is loaded from an external source outside of the vanilla game's resource manager.
  • Field Details

    • FALLBACK_TEXTURE

      public static final UITexture FALLBACK_TEXTURE
      A UITexture typically used when loading an external texture results in an Exception being raised.
    • TEXTURE_CACHE

      @Deprecated(since="3.7", forRemoval=true) public static final com.google.common.cache.Cache<Object,UIExternalTexture> TEXTURE_CACHE
      Deprecated, for removal: This API element is subject to removal in a future version.
      Holds cached UIExternalTextures obtained from remote resources such as the world-wide-web.
  • Constructor Details

  • Method Details

    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • finalize

      protected final void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • isClosed

      public final boolean isClosed()
      Returns true if close() was called on this UIExternalTexture.
    • getNativeWidth

      public final int getNativeWidth()
      Returns the width of the NativeImage.
      See Also:
      • NativeImage.getWidth()
    • getNativeHeight

      public final int getNativeHeight()
      Returns the height of the NativeImage.
      See Also:
      • NativeImage.getHeight()
    • getNativeColor

      public final int getNativeColor(int x, int y) throws IllegalArgumentException
      Returns the color of a given pixel on the NativeImage.
      Parameters:
      x - The X coordinate of the target pixel.
      y - The Y coordinate of the target pixel.
      Throws:
      IllegalArgumentException - If the pixel coordinates are "out of bounds".
      See Also:
    • loadTextureAsync

      @Experimental public static final void loadTextureAsync(byte[] pngBytes, Consumer<UIExternalTexture> onReady, Consumer<Exception> onError) throws NullPointerException
      Asynchronously loads a UIExternalTexture using a Byte array.
      Parameters:
      pngBytes - The image's byte data. Must be in "png" format.
      onReady - A Consumer that is invoked on successful load.
      onError - A Consumer that is invoked if an Exception is raised.
      Throws:
      NullPointerException - If an argument is null.
    • loadTextureAsync

      @Deprecated(since="3.7", forRemoval=true) public static final void loadTextureAsync(URL textureUrl, net.minecraft.util.thread.ReentrantThreadExecutor<?> minecraftClientOrServer, Consumer<UIExternalTexture> onReady, Consumer<Exception> onError) throws NullPointerException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Asynchronously loads a "png" image hosted on the WWW.
      Parameters:
      textureUrl - The URL that points to the "png" image.
      minecraftClientOrServer - An instance of the current MinecraftClient or the MinecraftServer.
      onReady - A Consumer that is invoked once the image is successfully obtained.
      onError - A Consumer that is invoked in the event fetching the image fails.
      Throws:
      NullPointerException - If a non-Nullable argument is null.
    • loadTextureAsync

      @Deprecated(since="3.7", forRemoval=true) public static final void loadTextureAsync(Callable<net.minecraft.client.texture.NativeImage> nativeImageSupplier, net.minecraft.util.thread.ReentrantThreadExecutor<?> minecraftClientOrServer, Consumer<UIExternalTexture> onReady, Consumer<Exception> onError) throws NullPointerException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Asynchronously loads a "png" image using the Callable "NativeImage supplier".
      Parameters:
      nativeImageSupplier - Use this to load the NativeImage. Executes asynchronously.
      minecraftClientOrServer - An instance of the current MinecraftClient or the MinecraftServer.
      onReady - A Consumer that is invoked once the image is successfully obtained.
      onError - A Consumer that is invoked in the event fetching the image fails.
      Throws:
      NullPointerException - If a non-Nullable argument is null.