diff --git a/common/src/api/java/net/caffeinemc/mods/sodium/api/texture/SpriteUtil.java b/common/src/api/java/net/caffeinemc/mods/sodium/api/texture/SpriteUtil.java new file mode 100644 index 0000000000..f21eb45e10 --- /dev/null +++ b/common/src/api/java/net/caffeinemc/mods/sodium/api/texture/SpriteUtil.java @@ -0,0 +1,27 @@ +package net.caffeinemc.mods.sodium.api.texture; + +import net.caffeinemc.mods.sodium.api.internal.DependencyInjection; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +@ApiStatus.Experimental +@ApiStatus.AvailableSince("0.6.0") +public interface SpriteUtil { + SpriteUtil INSTANCE = DependencyInjection.load(SpriteUtil.class, + "net.caffeinemc.mods.sodium.client.render.texture.SpriteUtilImpl"); + + /** + * Marks a provided sprite as active + * @param sprite The sprite you want to mark as active + */ + void markSpriteActive(@NotNull TextureAtlasSprite sprite); + + /** + * Checks if the provided sprite has an animation + * + * @param sprite The sprite you want to check + * @return true if the provided sprite has an animation, false if it doesn't + */ + boolean hasAnimation(@NotNull TextureAtlasSprite sprite); +} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/RenderSectionManager.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/RenderSectionManager.java index 21aae7a7e1..b05d80e6ca 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/RenderSectionManager.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/RenderSectionManager.java @@ -8,6 +8,7 @@ import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; import it.unimi.dsi.fastutil.objects.ReferenceSet; import it.unimi.dsi.fastutil.objects.ReferenceSets; +import net.caffeinemc.mods.sodium.api.texture.SpriteUtil; import net.caffeinemc.mods.sodium.client.SodiumClientMod; import net.caffeinemc.mods.sodium.client.gl.device.CommandList; import net.caffeinemc.mods.sodium.client.gl.device.RenderDevice; @@ -37,7 +38,6 @@ import net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.trigger.CameraMovement; import net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.trigger.SortTriggering; import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkMeshFormats; -import net.caffeinemc.mods.sodium.client.render.texture.SpriteUtil; import net.caffeinemc.mods.sodium.client.render.util.RenderAsserts; import net.caffeinemc.mods.sodium.client.render.viewport.CameraTransform; import net.caffeinemc.mods.sodium.client.render.viewport.Viewport; @@ -274,7 +274,7 @@ public void tickVisibleRenders() { } for (TextureAtlasSprite sprite : sprites) { - SpriteUtil.markSpriteActive(sprite); + SpriteUtil.INSTANCE.markSpriteActive(sprite); } } } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/data/BuiltSectionInfo.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/data/BuiltSectionInfo.java index 25bf883a4d..a747eb042f 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/data/BuiltSectionInfo.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/data/BuiltSectionInfo.java @@ -1,10 +1,10 @@ package net.caffeinemc.mods.sodium.client.render.chunk.data; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; +import net.caffeinemc.mods.sodium.api.texture.SpriteUtil; import net.caffeinemc.mods.sodium.client.render.chunk.RenderSectionFlags; import net.caffeinemc.mods.sodium.client.render.chunk.occlusion.VisibilityEncoding; import net.caffeinemc.mods.sodium.client.render.chunk.terrain.TerrainRenderPass; -import net.caffeinemc.mods.sodium.client.render.texture.SpriteUtil; import net.minecraft.client.renderer.chunk.VisibilitySet; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.core.Direction; @@ -79,7 +79,7 @@ public void setOcclusionData(VisibilitySet data) { * @param sprite The sprite */ public void addSprite(TextureAtlasSprite sprite) { - if (SpriteUtil.hasAnimation(sprite)) { + if (SpriteUtil.INSTANCE.hasAnimation(sprite)) { this.animatedSprites.add(sprite); } } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/ItemRenderContext.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/ItemRenderContext.java index 62dfae8cad..f28c9c7216 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/ItemRenderContext.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/ItemRenderContext.java @@ -19,11 +19,11 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.MatrixUtil; +import net.caffeinemc.mods.sodium.api.texture.SpriteUtil; import net.caffeinemc.mods.sodium.client.render.frapi.helper.ColorHelper; import net.caffeinemc.mods.sodium.client.render.frapi.mesh.EncodingFormat; import net.caffeinemc.mods.sodium.client.render.frapi.mesh.MutableQuadViewImpl; import net.caffeinemc.mods.sodium.client.render.texture.SpriteFinderCache; -import net.caffeinemc.mods.sodium.client.render.texture.SpriteUtil; import net.caffeinemc.mods.sodium.mixin.features.render.frapi.ItemRendererAccessor; import net.fabricmc.fabric.api.renderer.v1.material.BlendMode; import net.fabricmc.fabric.api.renderer.v1.material.RenderMaterial; @@ -35,6 +35,7 @@ import net.minecraft.client.color.item.ItemColors; import net.minecraft.client.renderer.*; import net.minecraft.client.renderer.entity.ItemRenderer; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.Direction; import net.minecraft.util.RandomSource; @@ -223,7 +224,10 @@ private void shadeQuad(MutableQuadViewImpl quad, boolean emissive) { private void bufferQuad(MutableQuadViewImpl quad, VertexConsumer vertexConsumer) { QuadEncoder.writeQuadVertices(quad, vertexConsumer, overlay, matPosition, trustedNormals, matNormal); - SpriteUtil.markSpriteActive(quad.sprite(SpriteFinderCache.forBlockAtlas())); + TextureAtlasSprite sprite = quad.sprite(SpriteFinderCache.forBlockAtlas()); + if (sprite != null) { + SpriteUtil.INSTANCE.markSpriteActive(sprite); + } } /** diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/NonTerrainBlockRenderContext.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/NonTerrainBlockRenderContext.java index 130d240b2e..1ef82b6069 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/NonTerrainBlockRenderContext.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/NonTerrainBlockRenderContext.java @@ -18,13 +18,13 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; +import net.caffeinemc.mods.sodium.api.texture.SpriteUtil; import net.caffeinemc.mods.sodium.client.model.light.LightMode; import net.caffeinemc.mods.sodium.client.model.light.LightPipelineProvider; import net.caffeinemc.mods.sodium.client.model.light.data.SingleBlockLightDataCache; import net.caffeinemc.mods.sodium.client.render.frapi.helper.ColorHelper; import net.caffeinemc.mods.sodium.client.render.frapi.mesh.MutableQuadViewImpl; import net.caffeinemc.mods.sodium.client.render.texture.SpriteFinderCache; -import net.caffeinemc.mods.sodium.client.render.texture.SpriteUtil; import net.caffeinemc.mods.sodium.client.services.SodiumModelData; import net.fabricmc.fabric.api.renderer.v1.material.RenderMaterial; import net.fabricmc.fabric.api.renderer.v1.material.ShadeMode; @@ -32,6 +32,7 @@ import net.fabricmc.fabric.api.util.TriState; import net.minecraft.client.color.block.BlockColors; import net.minecraft.client.renderer.ItemBlockRenderTypes; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; import net.minecraft.util.RandomSource; @@ -127,6 +128,9 @@ protected void shadeQuad(MutableQuadViewImpl quad, LightMode lightMode, boolean private void bufferQuad(MutableQuadViewImpl quad) { QuadEncoder.writeQuadVertices(quad, vertexConsumer, overlay, matPosition, trustedNormals, matNormal); - SpriteUtil.markSpriteActive(quad.sprite(SpriteFinderCache.forBlockAtlas())); + TextureAtlasSprite sprite = quad.sprite(SpriteFinderCache.forBlockAtlas()); + if (sprite != null) { + SpriteUtil.INSTANCE.markSpriteActive(sprite); + } } } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/texture/SpriteUtil.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/texture/SpriteUtil.java deleted file mode 100644 index 084acc18b5..0000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/texture/SpriteUtil.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.texture; - -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import org.jetbrains.annotations.Nullable; - -public class SpriteUtil { - public static void markSpriteActive(@Nullable TextureAtlasSprite sprite) { - if (sprite == null) { - // Can happen in some cases, for example if a mod passes a BakedQuad with a null sprite - // to a VertexConsumer that does not have a texture element. - return; - } - - ((SpriteContentsExtension) sprite.contents()).sodium$setActive(true); - } - - public static boolean hasAnimation(TextureAtlasSprite sprite) { - return ((SpriteContentsExtension) sprite.contents()).sodium$hasAnimation(); - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/texture/SpriteUtilImpl.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/texture/SpriteUtilImpl.java new file mode 100644 index 0000000000..28739686d1 --- /dev/null +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/texture/SpriteUtilImpl.java @@ -0,0 +1,21 @@ +package net.caffeinemc.mods.sodium.client.render.texture; + +import net.caffeinemc.mods.sodium.api.texture.SpriteUtil; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import org.jetbrains.annotations.NotNull; + +import java.util.Objects; + +public class SpriteUtilImpl implements SpriteUtil { + @Override + public void markSpriteActive(@NotNull TextureAtlasSprite sprite) { + Objects.requireNonNull(sprite); + + ((SpriteContentsExtension) sprite.contents()).sodium$setActive(true); + } + + @Override + public boolean hasAnimation(@NotNull TextureAtlasSprite sprite) { + return ((SpriteContentsExtension) sprite.contents()).sodium$hasAnimation(); + } +} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/immediate/buffer_builder/intrinsics/BufferBuilderMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/immediate/buffer_builder/intrinsics/BufferBuilderMixin.java index a72f45f5bc..b2ab2179aa 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/immediate/buffer_builder/intrinsics/BufferBuilderMixin.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/immediate/buffer_builder/intrinsics/BufferBuilderMixin.java @@ -3,12 +3,13 @@ import com.mojang.blaze3d.vertex.BufferBuilder; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; +import net.caffeinemc.mods.sodium.api.texture.SpriteUtil; import net.caffeinemc.mods.sodium.client.model.quad.ModelQuadView; import net.caffeinemc.mods.sodium.client.render.immediate.model.BakedModelEncoder; -import net.caffeinemc.mods.sodium.client.render.texture.SpriteUtil; import net.caffeinemc.mods.sodium.api.util.ColorABGR; import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -25,7 +26,12 @@ public void putBulkData(PoseStack.Pose matrices, BakedQuad bakedQuad, float r, f if (!this.fastFormat) { VertexConsumer.super.putBulkData(matrices, bakedQuad, r, g, b, a, light, overlay); - SpriteUtil.markSpriteActive(bakedQuad.getSprite()); + TextureAtlasSprite sprite = bakedQuad.getSprite(); + // This can be null + //noinspection ConstantValue + if (sprite != null) { + SpriteUtil.INSTANCE.markSpriteActive(sprite); + } return; } @@ -41,7 +47,10 @@ public void putBulkData(PoseStack.Pose matrices, BakedQuad bakedQuad, float r, f int color = ColorABGR.pack(r, g, b, a); BakedModelEncoder.writeQuadVertices(writer, matrices, quad, color, light, overlay, false); - SpriteUtil.markSpriteActive(quad.getSprite()); + TextureAtlasSprite sprite = quad.getSprite(); + if (sprite != null) { + SpriteUtil.INSTANCE.markSpriteActive(sprite); + } } @Override @@ -49,7 +58,12 @@ public void putBulkData(PoseStack.Pose matrices, BakedQuad bakedQuad, float[] br if (!this.fastFormat) { VertexConsumer.super.putBulkData(matrices, bakedQuad, brightnessTable, r, g, b, a, light, overlay, colorize); - SpriteUtil.markSpriteActive(bakedQuad.getSprite()); + TextureAtlasSprite sprite = bakedQuad.getSprite(); + // This can be null + //noinspection ConstantValue + if (sprite != null) { + SpriteUtil.INSTANCE.markSpriteActive(sprite); + } return; } @@ -64,6 +78,9 @@ public void putBulkData(PoseStack.Pose matrices, BakedQuad bakedQuad, float[] br BakedModelEncoder.writeQuadVertices(writer, matrices, quad, r, g, b, a, brightnessTable, colorize, light, overlay); - SpriteUtil.markSpriteActive(quad.getSprite()); + TextureAtlasSprite sprite = quad.getSprite(); + if (sprite != null) { + SpriteUtil.INSTANCE.markSpriteActive(sprite); + } } } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/model/item/ItemRendererMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/model/item/ItemRendererMixin.java index a3b15c4252..0ccc0deeb1 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/model/item/ItemRendererMixin.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/model/item/ItemRendererMixin.java @@ -1,8 +1,9 @@ package net.caffeinemc.mods.sodium.mixin.features.render.model.item; +import net.caffeinemc.mods.sodium.api.texture.SpriteUtil; import net.caffeinemc.mods.sodium.client.model.quad.BakedQuadView; import net.caffeinemc.mods.sodium.client.render.immediate.model.BakedModelEncoder; -import net.caffeinemc.mods.sodium.client.render.texture.SpriteUtil; +import net.caffeinemc.mods.sodium.client.render.texture.SpriteFinderCache; import net.caffeinemc.mods.sodium.client.render.vertex.VertexConsumerUtils; import net.caffeinemc.mods.sodium.client.model.color.interop.ItemColorsExtension; import net.caffeinemc.mods.sodium.client.util.DirectionUtil; @@ -12,6 +13,7 @@ import net.minecraft.client.color.item.ItemColors; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.entity.ItemRenderer; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.Direction; import net.minecraft.util.RandomSource; @@ -94,7 +96,10 @@ private void renderBakedItemQuads(PoseStack.Pose matrices, VertexBufferWriter wr BakedModelEncoder.writeQuadVertices(writer, matrices, quad, color, light, overlay, BakedModelEncoder.shouldMultiplyAlpha()); - SpriteUtil.markSpriteActive(quad.getSprite()); + TextureAtlasSprite sprite = quad.getSprite(); + if (sprite != null) { + SpriteUtil.INSTANCE.markSpriteActive(sprite); + } } } } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/GuiGraphicsMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/GuiGraphicsMixin.java index 49d71efb44..fed72a54e8 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/GuiGraphicsMixin.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/GuiGraphicsMixin.java @@ -1,6 +1,6 @@ package net.caffeinemc.mods.sodium.mixin.features.textures.animations.tracking; -import net.caffeinemc.mods.sodium.client.render.texture.SpriteUtil; +import net.caffeinemc.mods.sodium.api.texture.SpriteUtil; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import org.spongepowered.asm.mixin.Mixin; @@ -16,7 +16,7 @@ private void preDrawSprite(int x, int y, int z, TextureAtlasSprite sprite, CallbackInfo ci) { - SpriteUtil.markSpriteActive(sprite); + SpriteUtil.INSTANCE.markSpriteActive(sprite); } @Inject(method = "blit(IIIIILnet/minecraft/client/renderer/texture/TextureAtlasSprite;FFFF)V", at = @At("HEAD")) @@ -26,6 +26,6 @@ private void preDrawSprite(int x, int y, int z, float red, float green, float blue, float alpha, CallbackInfo ci) { - SpriteUtil.markSpriteActive(sprite); + SpriteUtil.INSTANCE.markSpriteActive(sprite); } } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/ModelBlockRendererMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/ModelBlockRendererMixin.java index 020ee3cb27..cb666fa6aa 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/ModelBlockRendererMixin.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/ModelBlockRendererMixin.java @@ -2,9 +2,10 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import net.caffeinemc.mods.sodium.client.render.texture.SpriteUtil; +import net.caffeinemc.mods.sodium.api.texture.SpriteUtil; import net.minecraft.client.renderer.block.ModelBlockRenderer; import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.state.BlockState; @@ -22,6 +23,11 @@ public class ModelBlockRendererMixin { */ @Inject(method = "putQuadData", at = @At("HEAD")) private void preRenderQuad(BlockAndTintGetter level, BlockState state, BlockPos pos, VertexConsumer vertexConsumer, PoseStack.Pose matrices, BakedQuad quad, float brightness0, float brightness1, float brightness2, float brightness3, int light0, int light1, int light2, int light3, int overlay, CallbackInfo ci) { - SpriteUtil.markSpriteActive(quad.getSprite()); + TextureAtlasSprite sprite = quad.getSprite(); + // This can be null + //noinspection ConstantValue + if (sprite != null) { + SpriteUtil.INSTANCE.markSpriteActive(sprite); + } } } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/TextureAtlasMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/TextureAtlasMixin.java index d60038f2c4..f23ca8fe4f 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/TextureAtlasMixin.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/TextureAtlasMixin.java @@ -1,6 +1,6 @@ package net.caffeinemc.mods.sodium.mixin.features.textures.animations.tracking; -import net.caffeinemc.mods.sodium.client.render.texture.SpriteUtil; +import net.caffeinemc.mods.sodium.api.texture.SpriteUtil; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import org.spongepowered.asm.mixin.Mixin; @@ -15,7 +15,7 @@ private void preReturnSprite(CallbackInfoReturnable cir) { TextureAtlasSprite sprite = cir.getReturnValue(); if (sprite != null) { - SpriteUtil.markSpriteActive(sprite); + SpriteUtil.INSTANCE.markSpriteActive(sprite); } } } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/TextureSheetParticleMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/TextureSheetParticleMixin.java index 6773925be4..a4f162ab15 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/TextureSheetParticleMixin.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/textures/animations/tracking/TextureSheetParticleMixin.java @@ -1,7 +1,7 @@ package net.caffeinemc.mods.sodium.mixin.features.textures.animations.tracking; import com.mojang.blaze3d.vertex.VertexConsumer; -import net.caffeinemc.mods.sodium.client.render.texture.SpriteUtil; +import net.caffeinemc.mods.sodium.api.texture.SpriteUtil; import net.minecraft.client.Camera; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.particle.SingleQuadParticle; @@ -28,13 +28,13 @@ protected TextureSheetParticleMixin(ClientLevel level, double x, double y, doubl @Inject(method = "setSprite(Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;)V", at = @At("RETURN")) private void afterSetSprite(TextureAtlasSprite sprite, CallbackInfo ci) { - this.shouldTickSprite = sprite != null && SpriteUtil.hasAnimation(sprite); + this.shouldTickSprite = sprite != null && SpriteUtil.INSTANCE.hasAnimation(sprite); } @Override public void render(VertexConsumer vertexConsumer, Camera camera, float tickDelta) { if (this.shouldTickSprite) { - SpriteUtil.markSpriteActive(this.sprite); + SpriteUtil.INSTANCE.markSpriteActive(this.sprite); } super.render(vertexConsumer, camera, tickDelta); diff --git a/fabric/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/model/block/ModelBlockRendererMixin.java b/fabric/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/model/block/ModelBlockRendererMixin.java index 6fbc0d2ecf..34c53b60c0 100644 --- a/fabric/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/model/block/ModelBlockRendererMixin.java +++ b/fabric/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/model/block/ModelBlockRendererMixin.java @@ -2,15 +2,16 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; +import net.caffeinemc.mods.sodium.api.texture.SpriteUtil; import net.caffeinemc.mods.sodium.api.util.ColorABGR; import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; import net.caffeinemc.mods.sodium.client.model.quad.BakedQuadView; import net.caffeinemc.mods.sodium.client.render.immediate.model.BakedModelEncoder; -import net.caffeinemc.mods.sodium.client.render.texture.SpriteUtil; import net.caffeinemc.mods.sodium.client.render.vertex.VertexConsumerUtils; import net.caffeinemc.mods.sodium.client.util.DirectionUtil; import net.minecraft.client.renderer.block.ModelBlockRenderer; import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.Direction; import net.minecraft.util.Mth; @@ -46,7 +47,10 @@ private static void renderQuads(PoseStack.Pose matrices, VertexBufferWriter writ BakedModelEncoder.writeQuadVertices(writer, matrices, quad, color, light, overlay, false); - SpriteUtil.markSpriteActive(quad.getSprite()); + TextureAtlasSprite sprite = quad.getSprite(); + if (sprite != null) { + SpriteUtil.INSTANCE.markSpriteActive(sprite); + } } } diff --git a/neoforge/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/model/block/ModelBlockRendererMixin.java b/neoforge/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/model/block/ModelBlockRendererMixin.java index c87264a58e..f07b8e3967 100644 --- a/neoforge/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/model/block/ModelBlockRendererMixin.java +++ b/neoforge/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/model/block/ModelBlockRendererMixin.java @@ -2,16 +2,17 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; +import net.caffeinemc.mods.sodium.api.texture.SpriteUtil; import net.caffeinemc.mods.sodium.api.util.ColorABGR; import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; import net.caffeinemc.mods.sodium.client.model.quad.BakedQuadView; import net.caffeinemc.mods.sodium.client.render.immediate.model.BakedModelEncoder; -import net.caffeinemc.mods.sodium.client.render.texture.SpriteUtil; import net.caffeinemc.mods.sodium.client.render.vertex.VertexConsumerUtils; import net.caffeinemc.mods.sodium.client.util.DirectionUtil; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.ModelBlockRenderer; import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.Direction; import net.minecraft.util.Mth; @@ -48,7 +49,10 @@ private static void renderQuads(PoseStack.Pose matrices, VertexBufferWriter writ BakedModelEncoder.writeQuadVertices(writer, matrices, quad, color, light, overlay, false); - SpriteUtil.markSpriteActive(quad.getSprite()); + TextureAtlasSprite sprite = quad.getSprite(); + if (sprite != null) { + SpriteUtil.INSTANCE.markSpriteActive(sprite); + } } }