aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander/yacl3/gui/image
diff options
context:
space:
mode:
authorisXander <xander@isxander.dev>2024-10-19 19:22:45 +0100
committerisXander <xander@isxander.dev>2024-10-19 19:22:45 +0100
commite73a08e6672fb380cab8db71340158969c5ef56b (patch)
treedd08a311f4eff9a91b465ef1854caa1286fc6f9a /src/main/java/dev/isxander/yacl3/gui/image
parent519ac2fc0e23587defcf4a8259979961d35d0ce2 (diff)
downloadYetAnotherConfigLib-e73a08e6672fb380cab8db71340158969c5ef56b.tar.gz
YetAnotherConfigLib-e73a08e6672fb380cab8db71340158969c5ef56b.tar.bz2
YetAnotherConfigLib-e73a08e6672fb380cab8db71340158969c5ef56b.zip
3.6.0
Diffstat (limited to 'src/main/java/dev/isxander/yacl3/gui/image')
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/image/YACLImageReloadListener.java10
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/image/impl/AnimatedDynamicTextureImage.java17
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/image/impl/DynamicTextureImage.java3
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/image/impl/ResourceTextureImage.java3
4 files changed, 16 insertions, 17 deletions
diff --git a/src/main/java/dev/isxander/yacl3/gui/image/YACLImageReloadListener.java b/src/main/java/dev/isxander/yacl3/gui/image/YACLImageReloadListener.java
index fb0695c..235d1d4 100644
--- a/src/main/java/dev/isxander/yacl3/gui/image/YACLImageReloadListener.java
+++ b/src/main/java/dev/isxander/yacl3/gui/image/YACLImageReloadListener.java
@@ -29,19 +29,20 @@ public class YACLImageReloadListener
public @NotNull CompletableFuture<Void> reload(
PreparationBarrier preparationBarrier,
@NotNull ResourceManager resourceManager,
- @NotNull ProfilerFiller preparationsProfiler,
+ //? if <1.21.2 {
+ /*@NotNull ProfilerFiller preparationsProfiler,
@NotNull ProfilerFiller reloadProfiler,
+ *///?}
@NotNull Executor backgroundExecutor,
@NotNull Executor gameExecutor
) {
- return prepare(resourceManager, preparationsProfiler, backgroundExecutor)
+ return prepare(resourceManager, backgroundExecutor)
.thenCompose(preparationBarrier::wait)
- .thenCompose(suppliers -> apply(suppliers, reloadProfiler, gameExecutor));
+ .thenCompose(suppliers -> apply(suppliers, gameExecutor));
}
private CompletableFuture<List<Optional<SupplierPreparation>>> prepare(
ResourceManager manager,
- ProfilerFiller profiler,
Executor executor
) {
Map<ResourceLocation, Resource> imageResources = manager.listResources(
@@ -72,7 +73,6 @@ public class YACLImageReloadListener
private CompletableFuture<Void> apply(
List<Optional<SupplierPreparation>> suppliers,
- ProfilerFiller profiler,
Executor executor
) {
return CompletableFuture.allOf(suppliers.stream()
diff --git a/src/main/java/dev/isxander/yacl3/gui/image/impl/AnimatedDynamicTextureImage.java b/src/main/java/dev/isxander/yacl3/gui/image/impl/AnimatedDynamicTextureImage.java
index 39ddb55..1dd52f2 100644
--- a/src/main/java/dev/isxander/yacl3/gui/image/impl/AnimatedDynamicTextureImage.java
+++ b/src/main/java/dev/isxander/yacl3/gui/image/impl/AnimatedDynamicTextureImage.java
@@ -7,7 +7,7 @@ import com.mojang.blaze3d.platform.NativeImage;
import com.twelvemonkeys.imageio.plugins.webp.WebPImageReaderSpi;
import dev.isxander.yacl3.debug.DebugProperties;
import dev.isxander.yacl3.gui.image.ImageRendererFactory;
-import dev.isxander.yacl3.impl.utils.YACLConstants;
+import dev.isxander.yacl3.gui.utils.GuiUtils;
import net.minecraft.CrashReport;
import net.minecraft.CrashReportCategory;
import net.minecraft.ReportedException;
@@ -16,7 +16,6 @@ import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager;
-import net.minecraft.util.FastColor;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
@@ -71,7 +70,8 @@ public class AnimatedDynamicTextureImage extends DynamicTextureImage {
GlStateManager._texParameter(GlConst.GL_TEXTURE_2D, GlConst.GL_TEXTURE_MIN_FILTER, GlConst.GL_LINEAR);
}
- graphics.blit(
+ GuiUtils.blitGuiTex(
+ graphics,
uniqueLocation,
0, 0,
frameWidth * currentCol, frameHeight * currentRow,
@@ -251,19 +251,16 @@ public class AnimatedDynamicTextureImage extends DynamicTextureImage {
for (int w = 0; w < bi.getWidth(); w++) {
for (int h = 0; h < bi.getHeight(); h++) {
- int rgb = bi.getRGB(w, h);
- int r = FastColor.ARGB32.red(rgb);
- int g = FastColor.ARGB32.green(rgb);
- int b = FastColor.ARGB32.blue(rgb);
- int a = FastColor.ARGB32.alpha(rgb);
+ int argb = bi.getRGB(w, h);
int col = i % cols;
int row = (int) Math.floor(i / (double)cols);
- image.setPixelRGBA(
+ GuiUtils.setPixelARGB(
+ image,
frameWidth * col + w + xOffset,
frameHeight * row + h + yOffset,
- FastColor.ABGR32.color(a, b, g, r) // NativeImage uses ABGR for some reason
+ argb
);
}
}
diff --git a/src/main/java/dev/isxander/yacl3/gui/image/impl/DynamicTextureImage.java b/src/main/java/dev/isxander/yacl3/gui/image/impl/DynamicTextureImage.java
index 2d2abb9..edfaebc 100644
--- a/src/main/java/dev/isxander/yacl3/gui/image/impl/DynamicTextureImage.java
+++ b/src/main/java/dev/isxander/yacl3/gui/image/impl/DynamicTextureImage.java
@@ -7,6 +7,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import dev.isxander.yacl3.debug.DebugProperties;
import dev.isxander.yacl3.gui.image.ImageRenderer;
import dev.isxander.yacl3.gui.image.ImageRendererFactory;
+import dev.isxander.yacl3.gui.utils.GuiUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.texture.DynamicTexture;
@@ -51,7 +52,7 @@ public class DynamicTextureImage implements ImageRenderer {
GlStateManager._texParameter(GlConst.GL_TEXTURE_2D, GlConst.GL_TEXTURE_MIN_FILTER, GlConst.GL_LINEAR);
}
- graphics.blit(uniqueLocation, 0, 0, 0, 0, this.width, this.height, this.width, this.height);
+ GuiUtils.blitGuiTex(graphics, uniqueLocation, 0, 0, 0, 0, this.width, this.height, this.width, this.height);
graphics.pose().popPose();
diff --git a/src/main/java/dev/isxander/yacl3/gui/image/impl/ResourceTextureImage.java b/src/main/java/dev/isxander/yacl3/gui/image/impl/ResourceTextureImage.java
index abbeec7..baaa4b1 100644
--- a/src/main/java/dev/isxander/yacl3/gui/image/impl/ResourceTextureImage.java
+++ b/src/main/java/dev/isxander/yacl3/gui/image/impl/ResourceTextureImage.java
@@ -5,6 +5,7 @@ import com.mojang.blaze3d.platform.GlStateManager;
import dev.isxander.yacl3.debug.DebugProperties;
import dev.isxander.yacl3.gui.image.ImageRenderer;
import dev.isxander.yacl3.gui.image.ImageRendererFactory;
+import dev.isxander.yacl3.gui.utils.GuiUtils;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.resources.ResourceLocation;
@@ -38,7 +39,7 @@ public class ResourceTextureImage implements ImageRenderer {
GlStateManager._texParameter(GlConst.GL_TEXTURE_2D, GlConst.GL_TEXTURE_MIN_FILTER, GlConst.GL_LINEAR);
}
- graphics.blit(location, 0, 0, this.u, this.v, this.width, this.height, this.textureWidth, this.textureHeight);
+ GuiUtils.blitGuiTex(graphics, location, 0, 0, this.u, this.v, this.width, this.height, this.textureWidth, this.textureHeight);
graphics.pose().popPose();