Merge pull request #53 from saturnclientmc/refactor-gif
Refactored gif system
This commit is contained in:
+1
-1
Submodule common updated: ca42b00067...2b6194223a
+2
-2
@@ -3,6 +3,7 @@ package org.saturnclient.impl.cosmetics;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.saturnclient.client.player.SaturnPlayer;
|
||||
import org.saturnclient.common.ref.asset.IdentifierRef;
|
||||
import org.saturnclient.config.Config;
|
||||
import org.saturnclient.cosmetics.Cloaks;
|
||||
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.equipment.EquipmentAsset;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
@@ -283,7 +283,7 @@ public class CloakFeatureRenderer extends FeatureRenderer<PlayerEntityRenderStat
|
||||
return;
|
||||
}
|
||||
|
||||
Identifier customCape = (Identifier) (Object) Cloaks.getCurrentCloakTexture(player.cloak);
|
||||
IdentifierRef customCape = Cloaks.getCurrentCloakTexture(player.cloak);
|
||||
if (customCape == null
|
||||
|| this.hasCustomModelForLayer(playerEntityRenderState.equippedChestStack, LayerType.WINGS)) {
|
||||
return;
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import org.saturnclient.common.ref.asset.IdentifierRef;
|
||||
import org.saturnclient.impl.cosmetics.utils.ShaderUtils;
|
||||
|
||||
import de.javagl.obj.*;
|
||||
@@ -36,13 +37,13 @@ public class ObjRenderer {
|
||||
Mtl mtl = mtlMap != null ? mtlMap.get(materialName) : null;
|
||||
|
||||
// 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) {
|
||||
String mapKd = mtl.getMapKd();
|
||||
if (mapKd != null) {
|
||||
if (!mapKd.startsWith("#")) {
|
||||
texture = Identifier.of(mapKd);
|
||||
texture = IdentifierRef.of(mapKd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-9
@@ -42,11 +42,10 @@ public class IdentifierUtils {
|
||||
|
||||
}
|
||||
|
||||
NativeImageBackedTexture texture = new NativeImageBackedTexture(nativeImage);
|
||||
|
||||
SaturnClient.client.execute(() ->
|
||||
SaturnClient.client.getTextureManager().registerTexture(identifier, texture)
|
||||
);
|
||||
SaturnClient.client.execute(() -> {
|
||||
NativeImageBackedTexture texture = new NativeImageBackedTexture(nativeImage);
|
||||
SaturnClient.client.getTextureManager().registerTexture(identifier, texture);
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
SaturnClient.LOGGER.error("Failed to register texture: {}", identifierRef, e);
|
||||
@@ -62,9 +61,8 @@ public class IdentifierUtils {
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
SaturnClient.LOGGER.info(
|
||||
"Registered {} textures in {}ms",
|
||||
textures.size(),
|
||||
(end - start)
|
||||
);
|
||||
"Registered {} textures in {}ms",
|
||||
textures.size(),
|
||||
(end - start));
|
||||
}
|
||||
}
|
||||
+10
-4
@@ -1,5 +1,8 @@
|
||||
package org.saturnclient.impl.cosmetics.utils;
|
||||
|
||||
import org.saturnclient.common.ref.asset.IdentifierRef;
|
||||
import org.saturnclient.cosmetics.utils.GifUtils;
|
||||
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.RenderPhase;
|
||||
import net.minecraft.client.render.VertexFormat.DrawMode;
|
||||
@@ -10,7 +13,7 @@ import net.minecraft.util.Identifier;
|
||||
|
||||
public class ShaderUtils {
|
||||
public static final RenderLayer END_GATEWAY = RenderLayer.of(
|
||||
"end_gateway_no_cull",
|
||||
"end_gateway",
|
||||
VertexFormats.POSITION,
|
||||
DrawMode.QUADS,
|
||||
1536,
|
||||
@@ -25,11 +28,14 @@ public class ShaderUtils {
|
||||
.cull(RenderPhase.DISABLE_CULLING)
|
||||
.build(false));
|
||||
|
||||
public static RenderLayer getRenderLayer(Identifier texture) {
|
||||
if (texture.getPath().endsWith("end.png")) {
|
||||
public static RenderLayer getRenderLayer(IdentifierRef texture) {
|
||||
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;
|
||||
} else {
|
||||
return RenderLayer.getEntityAlpha(texture);
|
||||
return RenderLayer.getEntityAlpha((Identifier) (Object) texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,6 +3,7 @@ package org.saturnclient.impl.cosmetics;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.saturnclient.client.player.SaturnPlayer;
|
||||
import org.saturnclient.common.ref.asset.IdentifierRef;
|
||||
import org.saturnclient.config.Config;
|
||||
import org.saturnclient.cosmetics.Cloaks;
|
||||
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.equipment.EquipmentAsset;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
@@ -283,7 +283,7 @@ public class CloakFeatureRenderer extends FeatureRenderer<PlayerEntityRenderStat
|
||||
return;
|
||||
}
|
||||
|
||||
Identifier customCape = (Identifier) (Object) Cloaks.getCurrentCloakTexture(player.cloak);
|
||||
IdentifierRef customCape = Cloaks.getCurrentCloakTexture(player.cloak);
|
||||
if (customCape == null
|
||||
|| this.hasCustomModelForLayer(playerEntityRenderState.equippedChestStack, LayerType.WINGS)) {
|
||||
return;
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import org.saturnclient.common.ref.asset.IdentifierRef;
|
||||
import org.saturnclient.impl.cosmetics.utils.ShaderUtils;
|
||||
|
||||
import de.javagl.obj.*;
|
||||
@@ -36,13 +37,13 @@ public class ObjRenderer {
|
||||
Mtl mtl = mtlMap != null ? mtlMap.get(materialName) : null;
|
||||
|
||||
// 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) {
|
||||
String mapKd = mtl.getMapKd();
|
||||
if (mapKd != null) {
|
||||
if (!mapKd.startsWith("#")) {
|
||||
texture = Identifier.of(mapKd);
|
||||
texture = IdentifierRef.of(mapKd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-9
@@ -42,11 +42,13 @@ public class IdentifierUtils {
|
||||
|
||||
}
|
||||
|
||||
NativeImageBackedTexture texture = new NativeImageBackedTexture(() -> identifier.toString(), nativeImage);
|
||||
|
||||
SaturnClient.client.execute(() ->
|
||||
SaturnClient.client.getTextureManager().registerTexture(identifier, texture)
|
||||
);
|
||||
SaturnClient.client.execute(() -> {
|
||||
NativeImageBackedTexture texture = new NativeImageBackedTexture(
|
||||
() -> identifier.toString(),
|
||||
nativeImage);
|
||||
|
||||
SaturnClient.client.getTextureManager().registerTexture(identifier, texture);
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
SaturnClient.LOGGER.error("Failed to register texture: {}", identifierRef, e);
|
||||
@@ -62,9 +64,8 @@ public class IdentifierUtils {
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
SaturnClient.LOGGER.info(
|
||||
"Registered {} textures in {}ms",
|
||||
textures.size(),
|
||||
(end - start)
|
||||
);
|
||||
"Registered {} textures in {}ms",
|
||||
textures.size(),
|
||||
(end - start));
|
||||
}
|
||||
}
|
||||
+29
-4
@@ -1,14 +1,39 @@
|
||||
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 net.minecraft.client.gl.RenderPipelines;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.RenderPhase.Textures;
|
||||
import net.minecraft.client.render.block.entity.EndPortalBlockEntityRenderer;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class ShaderUtils {
|
||||
public static RenderLayer getRenderLayer(Identifier texture) {
|
||||
if (texture.getPath().endsWith("end.png")) {
|
||||
return RenderLayer.getEndGateway();
|
||||
public static final RenderPipeline END_GATEWAY_PIPELINE = RenderPipelines.register(
|
||||
RenderPipeline.builder(new RenderPipeline.Snippet[] { RenderPipelines.RENDERTYPE_END_PORTAL_SNIPPET })
|
||||
.withLocation("pipeline/end_gateway")
|
||||
.withShaderDefine("PORTAL_LAYERS", 16)
|
||||
.withCull(false)
|
||||
.build());
|
||||
|
||||
public static final RenderLayer END_GATEWAY = RenderLayer.of("end_gateway", 1536, false, false,
|
||||
END_GATEWAY_PIPELINE,
|
||||
RenderLayer.MultiPhaseParameters.builder()
|
||||
.texture(Textures.create().add(EndPortalBlockEntityRenderer.SKY_TEXTURE, false, false)
|
||||
.add(EndPortalBlockEntityRenderer.PORTAL_TEXTURE, false, false).build())
|
||||
.build(false));
|
||||
|
||||
public static RenderLayer getRenderLayer(IdentifierRef texture) {
|
||||
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;
|
||||
} else {
|
||||
return RenderLayer.getEntityAlpha(texture);
|
||||
return RenderLayer.getEntityAlpha((Identifier) (Object) texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
package org.saturnclient.impl.mixins;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Quaternionfc;
|
||||
import org.saturnclient.common.ref.render.MatrixStackRef;
|
||||
import org.saturnclient.common.ref.render.QuaternionfRef;
|
||||
|
||||
Reference in New Issue
Block a user