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
A
UITexture
that is loaded from an external
source outside of the vanilla game's resource manager.-
Field Summary
Modifier and TypeFieldDescriptionstatic final UITexture
static final com.google.common.cache.Cache
<Object, UIExternalTexture> Deprecated, for removal: This API element is subject to removal in a future version.Fields inherited from class io.github.thecsdev.tcdcommons.api.client.gui.util.UITexture
TEXTURE_UV_DEBUG
-
Constructor Summary
ConstructorDescriptionUIExternalTexture
(net.minecraft.client.texture.NativeImage image) Creates aUIExternalTexture
instance using aNativeImage
that has been loaded from an external source. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
close()
protected final void
finalize()
final int
getNativeColor
(int x, int y) Returns the color of a given pixel on theNativeImage
.final int
Returns the height of theNativeImage
.final int
Returns the width of theNativeImage
.final boolean
isClosed()
static final void
loadTextureAsync
(byte[] pngBytes, Consumer<UIExternalTexture> onReady, Consumer<Exception> onError) Asynchronously loads aUIExternalTexture
using aByte
array.static final void
loadTextureAsync
(URL textureUrl, net.minecraft.util.thread.ReentrantThreadExecutor<?> minecraftClientOrServer, Consumer<UIExternalTexture> onReady, Consumer<Exception> onError) Deprecated, for removal: This API element is subject to removal in a future version.static final void
loadTextureAsync
(Callable<net.minecraft.client.texture.NativeImage> nativeImageSupplier, net.minecraft.util.thread.ReentrantThreadExecutor<?> minecraftClientOrServer, Consumer<UIExternalTexture> onReady, Consumer<Exception> onError) Deprecated, for removal: This API element is subject to removal in a future version.Methods inherited from class io.github.thecsdev.tcdcommons.api.client.gui.util.UITexture
drawTexture, drawTexture, equals, getTexture, getTextureID, getTextureSize, getTextureUVs, hashCode
-
Field Details
-
FALLBACK_TEXTURE
-
TEXTURE_CACHE
@Deprecated(since="3.7", forRemoval=true) public static final com.google.common.cache.Cache<Object,UIExternalTexture> TEXTURE_CACHEDeprecated, for removal: This API element is subject to removal in a future version.Holds cachedUIExternalTexture
s obtained from remote resources such as the world-wide-web.
-
-
Constructor Details
-
UIExternalTexture
public UIExternalTexture(net.minecraft.client.texture.NativeImage image) throws NullPointerException, IllegalStateException Creates aUIExternalTexture
instance using aNativeImage
that has been loaded from an external source.- Throws:
NullPointerException
- When the argument isnull
.IllegalStateException
- If this constructor is executed "off-thread".- See Also:
-
-
Method Details
-
close
public final void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
finalize
-
isClosed
public final boolean isClosed() -
getNativeWidth
public final int getNativeWidth()Returns the width of theNativeImage
.- See Also:
-
getNativeHeight
public final int getNativeHeight()Returns the height of theNativeImage
.- See Also:
-
getNativeColor
Returns the color of a given pixel on theNativeImage
.- 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 aUIExternalTexture
using aByte
array.- Parameters:
pngBytes
- The image's byte data. Must be in "png" format.onReady
- AConsumer
that is invoked on successful load.onError
- AConsumer
that is invoked if anException
is raised.- Throws:
NullPointerException
- If an argument isnull
.
-
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
- TheURL
that points to the "png" image.minecraftClientOrServer
- An instance of the current MinecraftClient or the MinecraftServer.onReady
- AConsumer
that is invoked once the image is successfully obtained.onError
- AConsumer
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 theCallable
"NativeImage
supplier".- Parameters:
nativeImageSupplier
- Use this to load theNativeImage
. Executes asynchronously.minecraftClientOrServer
- An instance of the current MinecraftClient or the MinecraftServer.onReady
- AConsumer
that is invoked once the image is successfully obtained.onError
- AConsumer
that is invoked in the event fetching the image fails.- Throws:
NullPointerException
- If a non-Nullable
argument is null.
-