Refactoed 1.21.5 to work with new gif api

This commit is contained in:
2026-03-23 21:05:22 +01:00
parent df102fff84
commit 9fbeac628c
7 changed files with 32 additions and 27 deletions
+1 -1
Submodule common updated: eb40ece9f6...2b6194223a
@@ -42,11 +42,10 @@ public class IdentifierUtils {
} }
SaturnClient.client.execute(() -> {
NativeImageBackedTexture texture = new NativeImageBackedTexture(nativeImage); NativeImageBackedTexture texture = new NativeImageBackedTexture(nativeImage);
SaturnClient.client.getTextureManager().registerTexture(identifier, texture);
SaturnClient.client.execute(() -> });
SaturnClient.client.getTextureManager().registerTexture(identifier, texture)
);
} catch (Exception e) { } catch (Exception e) {
SaturnClient.LOGGER.error("Failed to register texture: {}", identifierRef, e); SaturnClient.LOGGER.error("Failed to register texture: {}", identifierRef, e);
@@ -64,7 +63,6 @@ public class IdentifierUtils {
SaturnClient.LOGGER.info( SaturnClient.LOGGER.info(
"Registered {} textures in {}ms", "Registered {} textures in {}ms",
textures.size(), textures.size(),
(end - start) (end - start));
);
} }
} }
@@ -3,6 +3,7 @@ package org.saturnclient.impl.cosmetics;
import java.util.Arrays; import java.util.Arrays;
import org.saturnclient.client.player.SaturnPlayer; import org.saturnclient.client.player.SaturnPlayer;
import org.saturnclient.common.ref.asset.IdentifierRef;
import org.saturnclient.config.Config; import org.saturnclient.config.Config;
import org.saturnclient.cosmetics.Cloaks; import org.saturnclient.cosmetics.Cloaks;
import org.saturnclient.impl.cosmetics.utils.ShaderUtils; import org.saturnclient.impl.cosmetics.utils.ShaderUtils;
@@ -23,7 +24,6 @@ import net.minecraft.component.type.EquippableComponent;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.equipment.EquipmentAsset; import net.minecraft.item.equipment.EquipmentAsset;
import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKey;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.RotationAxis; import net.minecraft.util.math.RotationAxis;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
@@ -283,7 +283,7 @@ public class CloakFeatureRenderer extends FeatureRenderer<PlayerEntityRenderStat
return; return;
} }
Identifier customCape = (Identifier) (Object) Cloaks.getCurrentCloakTexture(player.cloak); IdentifierRef customCape = Cloaks.getCurrentCloakTexture(player.cloak);
if (customCape == null if (customCape == null
|| this.hasCustomModelForLayer(playerEntityRenderState.equippedChestStack, LayerType.WINGS)) { || this.hasCustomModelForLayer(playerEntityRenderState.equippedChestStack, LayerType.WINGS)) {
return; return;
@@ -4,6 +4,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Map; import java.util.Map;
import org.saturnclient.common.ref.asset.IdentifierRef;
import org.saturnclient.impl.cosmetics.utils.ShaderUtils; import org.saturnclient.impl.cosmetics.utils.ShaderUtils;
import de.javagl.obj.*; import de.javagl.obj.*;
@@ -36,13 +37,13 @@ public class ObjRenderer {
Mtl mtl = mtlMap != null ? mtlMap.get(materialName) : null; Mtl mtl = mtlMap != null ? mtlMap.get(materialName) : null;
// Resolve texture identifier using same logic as ObjUnbakedModelModel // Resolve texture identifier using same logic as ObjUnbakedModelModel
Identifier texture = Identifier.of("minecraft:textures/misc/white.png"); IdentifierRef texture = IdentifierRef.ofVanilla("textures/misc/white.png");
if (mtl != null) { if (mtl != null) {
String mapKd = mtl.getMapKd(); String mapKd = mtl.getMapKd();
if (mapKd != null) { if (mapKd != null) {
if (!mapKd.startsWith("#")) { if (!mapKd.startsWith("#")) {
texture = Identifier.of(mapKd); texture = IdentifierRef.of(mapKd);
} }
} }
} }
@@ -42,11 +42,13 @@ public class IdentifierUtils {
} }
NativeImageBackedTexture texture = new NativeImageBackedTexture(() -> identifier.toString(), nativeImage); SaturnClient.client.execute(() -> {
NativeImageBackedTexture texture = new NativeImageBackedTexture(
() -> identifier.toString(),
nativeImage);
SaturnClient.client.execute(() -> SaturnClient.client.getTextureManager().registerTexture(identifier, texture);
SaturnClient.client.getTextureManager().registerTexture(identifier, texture) });
);
} catch (Exception e) { } catch (Exception e) {
SaturnClient.LOGGER.error("Failed to register texture: {}", identifierRef, e); SaturnClient.LOGGER.error("Failed to register texture: {}", identifierRef, e);
@@ -64,7 +66,6 @@ public class IdentifierUtils {
SaturnClient.LOGGER.info( SaturnClient.LOGGER.info(
"Registered {} textures in {}ms", "Registered {} textures in {}ms",
textures.size(), textures.size(),
(end - start) (end - start));
);
} }
} }
@@ -1,5 +1,8 @@
package org.saturnclient.impl.cosmetics.utils; package org.saturnclient.impl.cosmetics.utils;
import org.saturnclient.common.ref.asset.IdentifierRef;
import org.saturnclient.cosmetics.utils.GifUtils;
import com.mojang.blaze3d.pipeline.RenderPipeline; import com.mojang.blaze3d.pipeline.RenderPipeline;
import net.minecraft.client.gl.RenderPipelines; import net.minecraft.client.gl.RenderPipelines;
@@ -23,11 +26,14 @@ public class ShaderUtils {
.add(EndPortalBlockEntityRenderer.PORTAL_TEXTURE, false, false).build()) .add(EndPortalBlockEntityRenderer.PORTAL_TEXTURE, false, false).build())
.build(false)); .build(false));
public static RenderLayer getRenderLayer(Identifier texture) { public static RenderLayer getRenderLayer(IdentifierRef texture) {
if (texture.getPath().endsWith("end.png")) { String path = texture.toString();
if (path.endsWith(".gif")) {
return RenderLayer.getEntityAlpha((Identifier) (Object) GifUtils.get(texture));
} else if (path.endsWith("end.png")) {
return END_GATEWAY; return END_GATEWAY;
} else { } else {
return RenderLayer.getEntityAlpha(texture); return RenderLayer.getEntityAlpha((Identifier) (Object) texture);
} }
} }
} }
@@ -1,5 +1,4 @@
package org.saturnclient.impl.mixins; package org.saturnclient.impl.mixins;
import org.joml.Quaternionf;
import org.joml.Quaternionfc; import org.joml.Quaternionfc;
import org.saturnclient.common.ref.render.MatrixStackRef; import org.saturnclient.common.ref.render.MatrixStackRef;
import org.saturnclient.common.ref.render.QuaternionfRef; import org.saturnclient.common.ref.render.QuaternionfRef;