diff --git a/build.gradle.kts b/build.gradle.kts index c3d2bfe7..d5632f68 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,10 +3,10 @@ plugins { id("fabric-loom") version ("1.8.9") apply (false) } -val MINECRAFT_VERSION by extra { "1.21.1" } -val NEOFORGE_VERSION by extra { "21.1.79" } +val MINECRAFT_VERSION by extra { "1.21.3" } +val NEOFORGE_VERSION by extra { "21.3.0-beta" } val FABRIC_LOADER_VERSION by extra { "0.16.9" } -val FABRIC_API_VERSION by extra { "0.108.0+1.21.1" } +val FABRIC_API_VERSION by extra { "0.108.0+1.21.3" } // This value can be set to null to disable Parchment. val PARCHMENT_VERSION by extra { null } @@ -15,7 +15,7 @@ val PARCHMENT_VERSION by extra { null } val MAVEN_GROUP by extra { "me.flashyreese.mods" } val ARCHIVE_NAME by extra { "sodium-extra" } val MOD_VERSION by extra { "0.6.0" } -val SODIUM_VERSION by extra { "mc1.21.1-0.6.0" } +val SODIUM_VERSION by extra { "mc1.21.3-0.6.0" } allprojects { apply(plugin = "java") diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/client/SodiumExtraClientMod.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/client/SodiumExtraClientMod.java index 5358c957..c69ab0e0 100644 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/client/SodiumExtraClientMod.java +++ b/common/src/main/java/me/flashyreese/mods/sodiumextra/client/SodiumExtraClientMod.java @@ -51,10 +51,8 @@ public static CaffeineConfig mixinConfig() { .addMixinOption("optimizations", true) .addMixinOption("optimizations.beacon_beam_rendering", true) .addMixinOption("optimizations.draw_helpers", false) - .addMixinOption("optimizations.fast_weather", false) .addMixinOption("particle", true) .addMixinOption("prevent_shaders", true) - .addMixinOption("profiler", true) .addMixinOption("reduce_resolution_on_mac", true) .addMixinOption("render", true) .addMixinOption("render.block", true) diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog/MixinFogRenderer.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog/MixinFogRenderer.java index df70b50b..f4467b19 100644 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog/MixinFogRenderer.java +++ b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog/MixinFogRenderer.java @@ -1,28 +1,29 @@ package me.flashyreese.mods.sodiumextra.mixin.fog; -import com.mojang.blaze3d.systems.RenderSystem; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; import net.minecraft.client.Camera; +import net.minecraft.client.renderer.FogParameters; import net.minecraft.client.renderer.FogRenderer; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.material.FogType; import org.jetbrains.annotations.Nullable; +import org.joml.Vector4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(FogRenderer.class) public abstract class MixinFogRenderer { @Shadow @Nullable - protected static FogRenderer.MobEffectFogFunction getPriorityFogFunction(Entity entity, float f) { + private static FogRenderer.MobEffectFogFunction getPriorityFogFunction(Entity entity, float f) { return null; } - @Inject(method = "setupFog", at = @At(value = "TAIL")) - private static void applyFog(Camera camera, FogRenderer.FogMode fogType, float viewDistance, boolean thickFog, float tickDelta, CallbackInfo ci) { + @Inject(method = "setupFog", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/FogParameters;(FFLcom/mojang/blaze3d/shaders/FogShape;FFFF)V", shift = At.Shift.AFTER), cancellable = true) + private static void applyFog(Camera camera, FogRenderer.FogMode fogMode, Vector4f vector4f, float f, boolean thickFog, float tickDelta, CallbackInfoReturnable cir) { Entity entity = camera.getEntity(); SodiumExtraClientMod.options().renderSettings.dimensionFogDistanceMap.putIfAbsent(entity.level().dimensionType().effectsLocation(), 0); int fogDistance = SodiumExtraClientMod.options().renderSettings.multiDimensionFogControl ? SodiumExtraClientMod.options().renderSettings.dimensionFogDistanceMap.get(entity.level().dimensionType().effectsLocation()) : SodiumExtraClientMod.options().renderSettings.fogDistance; @@ -30,15 +31,14 @@ private static void applyFog(Camera camera, FogRenderer.FogMode fogType, float v if (fogDistance == 0 || mobEffectFogFunction != null) { return; } - if (camera.getFluidInCamera() == FogType.NONE && (thickFog || fogType == FogRenderer.FogMode.FOG_TERRAIN)) { + if (camera.getFluidInCamera() == FogType.NONE && (thickFog || fogMode == FogRenderer.FogMode.FOG_TERRAIN)) { float fogStart = (float) SodiumExtraClientMod.options().renderSettings.fogStart / 100; if (fogDistance == 33) { - RenderSystem.setShaderFogColor(1f, 1f, 1f, 0f); - //RenderSystem.setShaderFogStart(Short.MAX_VALUE - 1 * fogStart); - //RenderSystem.setShaderFogEnd(Short.MAX_VALUE); + cir.setReturnValue(FogParameters.NO_FOG); } else { - RenderSystem.setShaderFogStart(fogDistance * 16 * fogStart); - RenderSystem.setShaderFogEnd((fogDistance + 1) * 16); + FogParameters ci = cir.getReturnValue(); + FogParameters newFogParameters = new FogParameters(fogDistance * 16 * fogStart, (fogDistance + 1) * 16, ci.shape(), ci.red(), ci.green(), ci.blue(), ci.alpha()); + cir.setReturnValue(newFogParameters); } } } diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog_falloff/MixinFogRenderer.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog_falloff/MixinFogRenderer.java index 2a7d20e1..58ac9dfc 100644 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog_falloff/MixinFogRenderer.java +++ b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/fog_falloff/MixinFogRenderer.java @@ -8,9 +8,8 @@ @Mixin(FogRenderer.class) public class MixinFogRenderer { - @ModifyArg(method = "setupFog", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShaderFogStart(F)V"), index = 0) - private static float modifySetShaderFogStart(float original) { - float fogStart = (float) SodiumExtraClientMod.options().renderSettings.fogStart / 100; - return original * fogStart; + @ModifyArg(method = "setupFog", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/FogParameters;(FFLcom/mojang/blaze3d/shaders/FogShape;FFFF)V"), index = 0) + private static float setupFog(float fogStart) { + return fogStart * ((float) SodiumExtraClientMod.options().renderSettings.fogStart / 100); } } diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/draw_helpers/MixinGuiGraphics.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/draw_helpers/MixinGuiGraphics.java index 66e7abf2..41ff6b0a 100644 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/draw_helpers/MixinGuiGraphics.java +++ b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/draw_helpers/MixinGuiGraphics.java @@ -22,6 +22,8 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import java.util.function.Function; + @Mixin(value = GuiGraphics.class, priority = 1500) public abstract class MixinGuiGraphics { @@ -33,10 +35,6 @@ public abstract class MixinGuiGraphics { @Final private MultiBufferSource.BufferSource bufferSource; - @Shadow - @Deprecated - protected abstract void flushIfUnmanaged(); - /** * @author FlashyReese * @reason Impl Sodium's vertex writer @@ -107,7 +105,6 @@ public void fill(RenderType type, int x1, int y1, int x2, int y2, int z, int col writer.push(stack, buffer, 4, ColorVertex.FORMAT); } - this.flushIfUnmanaged(); ci.cancel(); } @@ -116,68 +113,35 @@ public void fill(RenderType type, int x1, int y1, int x2, int y2, int z, int col * @author FlashyReese * @reason Impl Sodium's vertex writer */ - @Inject(method = "innerBlit(Lnet/minecraft/resources/ResourceLocation;IIIIIFFFF)V", at = @At(value = "HEAD"), cancellable = true) - public void drawTexturedQuad(ResourceLocation texture, int x1, int x2, int y1, int y2, int z, float u1, float u2, float v1, float v2, CallbackInfo ci) { - RenderSystem.setShaderTexture(0, texture); - RenderSystem.setShader(GameRenderer::getPositionTexShader); + @Inject(method = "innerBlit", at = @At(value = "HEAD"), cancellable = true) + public void innerBlit(Function function, ResourceLocation resourceLocation, int x1, int x2, int y1, int y2, float u1, float u2, float v1, float v2, int color, CallbackInfo ci) { + RenderType renderType = function.apply(resourceLocation); Matrix4f matrix4f = this.pose.last().pose(); - BufferBuilder bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); - VertexBufferWriter writer = VertexBufferWriter.of(bufferBuilder); + VertexConsumer vertexConsumer = this.bufferSource.getBuffer(renderType); + vertexConsumer.addVertex(matrix4f, (float)x1, (float)y1, 0.0F).setUv(u1, v1).setColor(color); + vertexConsumer.addVertex(matrix4f, (float)x1, (float)y2, 0.0F).setUv(u1, v2).setColor(color); + vertexConsumer.addVertex(matrix4f, (float)x2, (float)y2, 0.0F).setUv(u2, v2).setColor(color); + vertexConsumer.addVertex(matrix4f, (float)x2, (float)y1, 0.0F).setUv(u2, v1).setColor(color); + + VertexBufferWriter writer = VertexBufferWriter.of(vertexConsumer); try (MemoryStack stack = MemoryStack.stackPush()) { final long buffer = stack.nmalloc(4 * TextureVertex.STRIDE); long ptr = buffer; - TextureVertex.write(ptr, matrix4f, x1, y1, z, u1, v1); + TextureVertex.write(ptr, matrix4f, x1, y1, 0.0F, u1, v1); ptr += TextureVertex.STRIDE; - TextureVertex.write(ptr, matrix4f, x1, y2, z, u1, v2); + TextureVertex.write(ptr, matrix4f, x1, y2, 0.0F, u1, v2); ptr += TextureVertex.STRIDE; - TextureVertex.write(ptr, matrix4f, x2, y2, z, u2, v2); + TextureVertex.write(ptr, matrix4f, x2, y2, 0.0F, u2, v2); ptr += TextureVertex.STRIDE; - TextureVertex.write(ptr, matrix4f, x2, y1, z, u2, v1); + TextureVertex.write(ptr, matrix4f, x2, y1, 0.0F, u2, v1); ptr += TextureVertex.STRIDE; writer.push(stack, buffer, 4, TextureVertex.FORMAT); } - BufferUploader.drawWithShader(bufferBuilder.buildOrThrow()); - ci.cancel(); - } - - /** - * @author FlashyReese - * @reason Impl Sodium's vertex writer - */ - @Inject(method = "innerBlit(Lnet/minecraft/resources/ResourceLocation;IIIIIFFFFFFFF)V", at = @At(value = "HEAD"), cancellable = true) - public void drawTexturedQuad(ResourceLocation texture, int x1, int x2, int y1, int y2, int z, float u1, float u2, float v1, float v2, float red, float green, float blue, float alpha, CallbackInfo ci) { - RenderSystem.setShaderTexture(0, texture); - RenderSystem.setShader(GameRenderer::getPositionTexColorShader); - RenderSystem.enableBlend(); - Matrix4f matrix4f = this.pose.last().pose(); - BufferBuilder bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); - VertexBufferWriter writer = VertexBufferWriter.of(bufferBuilder); - int color = ColorABGR.pack(red, green, blue, alpha); - try (MemoryStack stack = MemoryStack.stackPush()) { - final long buffer = stack.nmalloc(4 * TextureColorVertex.STRIDE); - long ptr = buffer; - - TextureColorVertex.write(ptr, matrix4f, x1, y1, z, color, u1, v1); - ptr += TextureColorVertex.STRIDE; - - TextureColorVertex.write(ptr, matrix4f, x1, y2, z, color, u1, v2); - ptr += TextureColorVertex.STRIDE; - - TextureColorVertex.write(ptr, matrix4f, x2, y2, z, color, u2, v2); - ptr += TextureColorVertex.STRIDE; - - TextureColorVertex.write(ptr, matrix4f, x2, y1, z, color, u2, v1); - ptr += TextureColorVertex.STRIDE; - - writer.push(stack, buffer, 4, TextureColorVertex.FORMAT); - } - BufferUploader.drawWithShader(bufferBuilder.buildOrThrow()); - RenderSystem.disableBlend(); ci.cancel(); } } diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/fast_weather/MixinLevelRenderer.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/fast_weather/MixinLevelRenderer.java deleted file mode 100644 index f9fa1bf5..00000000 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/optimizations/fast_weather/MixinLevelRenderer.java +++ /dev/null @@ -1,225 +0,0 @@ -package me.flashyreese.mods.sodiumextra.mixin.optimizations.fast_weather; - -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.*; -import it.unimi.dsi.fastutil.longs.Long2ReferenceMap; -import it.unimi.dsi.fastutil.longs.Long2ReferenceOpenHashMap; -import me.flashyreese.mods.sodiumextra.client.render.vertex.formats.WeatherVertex; -import me.flashyreese.mods.sodiumextra.common.util.Utils; -import net.caffeinemc.mods.sodium.api.util.ColorABGR; -import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.client.renderer.LevelRenderer; -import net.minecraft.client.renderer.LightTexture; -import net.minecraft.core.BlockPos; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.Mth; -import net.minecraft.util.RandomSource; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.biome.Biome; -import net.minecraft.world.level.levelgen.Heightmap; -import org.lwjgl.system.MemoryStack; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(value = LevelRenderer.class, priority = 1500) -public class MixinLevelRenderer { - @Shadow - @Final - private static ResourceLocation RAIN_LOCATION; - @Shadow - @Final - private static ResourceLocation SNOW_LOCATION; - @Unique - private final Long2ReferenceMap biomeLong2ReferenceMap = new Long2ReferenceOpenHashMap<>(); - @Shadow - @Final - private Minecraft minecraft; - @Shadow - private int ticks; - @Shadow - @Final - private float[] rainSizeX; - @Shadow - @Final - private float[] rainSizeZ; - - - @Inject(method = "renderSnowAndRain", at = @At(value = "HEAD"), cancellable = true) - public void sodiumExtra$renderWeather(LightTexture lightTexture, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) { - assert this.minecraft.level != null; - float rainGradient = this.minecraft.level.getRainLevel(tickDelta); - if (rainGradient > 0.0F) { - lightTexture.turnOnLightLayer(); - Level world = this.minecraft.level; - int cameraPosX = Mth.floor(cameraX); - int cameraPosY = Mth.floor(cameraY); - int cameraPosZ = Mth.floor(cameraZ); - Tesselator tessellator = Tesselator.getInstance(); - BufferBuilder bufferBuilder = null; - RenderSystem.disableCull(); - RenderSystem.enableBlend(); - RenderSystem.enableDepthTest(); - int range = Minecraft.useFancyGraphics() ? 10 : 5; - - RenderSystem.depthMask(Minecraft.useShaderTransparency()); - int precipitationType = -1; - float time = (float) this.ticks + tickDelta; - RenderSystem.setShader(GameRenderer::getParticleShader); - BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(); - - for (int z = cameraPosZ - range; z <= cameraPosZ + range; ++z) { - for (int x = cameraPosX - range; x <= cameraPosX + range; ++x) { - int positionIndex = (z - cameraPosZ + 16) * 32 + x - cameraPosX + 16; - double offsetX = (double) this.rainSizeX[positionIndex] * 0.5; - double offsetZ = (double) this.rainSizeZ[positionIndex] * 0.5; - mutable.set(x, cameraY, z); - - long biomePacked = Utils.packPosition(x, z); - Biome biome = this.biomeLong2ReferenceMap.computeIfAbsent(biomePacked, key -> world.getBiome(mutable).value()); - if (biome.hasPrecipitation()) { - int topY = world.getHeight(Heightmap.Types.MOTION_BLOCKING, x, z); - int minY = cameraPosY - range; - int maxY = cameraPosY + range; - if (minY < topY) { - minY = topY; - } - - if (maxY < topY) { - maxY = topY; - } - - int adjustedTopY = Math.max(topY, cameraPosY); - - if (minY != maxY) { - RandomSource random = RandomSource.create((long) x * x * 3121 + x * 45238971L ^ (long) z * z * 418711 + z * 13761L); - mutable.set(x, minY, z); - Biome.Precipitation precipitation = biome.getPrecipitationAt(mutable); - if (precipitation == Biome.Precipitation.RAIN) { - if (precipitationType != 0) { - if (precipitationType >= 0) { - BufferUploader.drawWithShader(bufferBuilder.buildOrThrow()); - } - - precipitationType = 0; - RenderSystem.setShaderTexture(0, RAIN_LOCATION); - bufferBuilder = tessellator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE); - } - - int ticksModulus = this.ticks & 131071; - int randomOffset = x * x * 3121 + x * 45238971 + z * z * 418711 + z * 13761 & 0xFF; - float dropLength = 3.0F + random.nextFloat(); - float dropTimeOffset = -((float) (ticksModulus + randomOffset) + tickDelta) / 32.0F * dropLength; - float dropTextureOffset = dropTimeOffset % 32.0F; - - double relativeX = (double) x + 0.5 - cameraX; - double relativeZ = (double) z + 0.5 - cameraZ; - float distance = (float) Math.sqrt(relativeX * relativeX + relativeZ * relativeZ) / (float) range; - float alpha = ((1.0F - distance * distance) * 0.5F + 0.5F) * rainGradient; - mutable.set(x, adjustedTopY, z); - int color = ColorABGR.pack(1.0F, 1.0F, 1.0F, alpha); - int light = LevelRenderer.getLightColor(world, mutable); - - VertexBufferWriter writer = VertexBufferWriter.of(bufferBuilder); - write(writer, cameraX, cameraY, cameraZ, x, z, offsetX, offsetZ, minY, maxY, 0, dropTextureOffset, color, light); - } else if (precipitation == Biome.Precipitation.SNOW) { - if (precipitationType != 1) { - if (precipitationType >= 0) { - BufferUploader.drawWithShader(bufferBuilder.buildOrThrow()); - } - - precipitationType = 1; - RenderSystem.setShaderTexture(0, SNOW_LOCATION); - bufferBuilder = tessellator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE); - } - - float snowFallSpeed = -((float) (this.ticks & 511) + tickDelta) / 512.0F; - float snowTextureOffsetX = (float) (random.nextDouble() + (double) time * 0.01 * (double) ((float) random.nextGaussian())); - float snowTextureOffsetY = (float) (random.nextDouble() + (double) (time * (float) random.nextGaussian()) * 0.001); - - double relativeX = (double) x + 0.5 - cameraX; - double relativeZ = (double) z + 0.5 - cameraZ; - float distance = (float) Math.sqrt(relativeX * relativeX + relativeZ * relativeZ) / (float) range; - float alpha = ((1.0F - distance * distance) * 0.3F + 0.5F) * rainGradient; - - mutable.set(x, adjustedTopY, z); - int light = LevelRenderer.getLightColor(world, mutable); - int blockLight = light >> 16 & (LightTexture.FULL_BLOCK | 65295); - int skyLight = light & (LightTexture.FULL_BLOCK | 65295); - int adjustedBlockLight = (blockLight * 3 + LightTexture.FULL_BLOCK) / 4; - int adjustedSkyLight = (skyLight * 3 + LightTexture.FULL_BLOCK) / 4; - - VertexBufferWriter writer = VertexBufferWriter.of(bufferBuilder); - int color = ColorABGR.pack(1.0F, 1.0F, 1.0F, alpha); - int packedLight = Utils.packLight(adjustedSkyLight, adjustedBlockLight); - write(writer, cameraX, cameraY, cameraZ, x, z, offsetX, offsetZ, minY, maxY, snowTextureOffsetX, snowFallSpeed + snowTextureOffsetY, color, packedLight); - } - } - } - } - } - - if (precipitationType >= 0) { - BufferUploader.drawWithShader(bufferBuilder.buildOrThrow()); - } - - RenderSystem.enableCull(); - RenderSystem.disableBlend(); - lightTexture.turnOffLightLayer(); - } - ci.cancel(); - } - - @Inject(method = "allChanged", at = @At(value = "TAIL")) - private void postReload(CallbackInfo ci) { - this.biomeLong2ReferenceMap.clear(); - } - - @Unique - private void write(VertexBufferWriter writer, double cameraX, double cameraY, double cameraZ, int x, int z, double offsetX, double offsetZ, int minY, int maxY, float textureOffsetX, float textureOffsetY, int color, int light) { - try (MemoryStack stack = MemoryStack.stackPush()) { - long buffer = stack.nmalloc(4 * WeatherVertex.STRIDE); - long ptr = buffer; - - WeatherVertex.put(ptr, - (float) ((double) x - cameraX - offsetX + 0.5), (float) ((double) maxY - cameraY), (float) ((double) z - cameraZ - offsetZ + 0.5), - 0.0F + textureOffsetX, (float) minY * 0.25F + textureOffsetY, - color, - light - ); - ptr += WeatherVertex.STRIDE; - - WeatherVertex.put(ptr, - (float) ((double) x - cameraX + offsetX + 0.5), (float) ((double) maxY - cameraY), (float) ((double) z - cameraZ + offsetZ + 0.5), - 1.0F + textureOffsetX, (float) minY * 0.25F + textureOffsetY, - color, - light - ); - ptr += WeatherVertex.STRIDE; - - WeatherVertex.put(ptr, - (float) ((double) x - cameraX + offsetX + 0.5), (float) ((double) minY - cameraY), (float) ((double) z - cameraZ + offsetZ + 0.5), - 1.0F + textureOffsetX, (float) maxY * 0.25F + textureOffsetY, - color, - light - ); - ptr += WeatherVertex.STRIDE; - - WeatherVertex.put(ptr, - (float) ((double) x - cameraX - offsetX + 0.5), (float) ((double) minY - cameraY), (float) ((double) z - cameraZ - offsetZ + 0.5), - 0.0F + textureOffsetX, (float) maxY * 0.25F + textureOffsetY, - color, - light - ); - ptr += WeatherVertex.STRIDE; - - writer.push(stack, buffer, 4, WeatherVertex.FORMAT); - } - } -} diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinLevelRenderer.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinLevelRenderer.java index 544f31d9..96b17980 100644 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinLevelRenderer.java +++ b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/particle/MixinLevelRenderer.java @@ -2,26 +2,30 @@ import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; import net.minecraft.client.Camera; -import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.LightTexture; +import net.minecraft.client.renderer.WeatherEffectRenderer; +import net.minecraft.server.level.ParticleStatus; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(LevelRenderer.class) +@Mixin(WeatherEffectRenderer.class) public class MixinLevelRenderer { - @Inject(method = "tickRain", at = @At(value = "HEAD"), cancellable = true) - public void tickRainSplashing(Camera camera, CallbackInfo callbackInfo) { + @Inject(method = "tickRainParticles", at = @At(value = "HEAD"), cancellable = true) + public void tickRainSplashing(ClientLevel clientLevel, Camera camera, int i, ParticleStatus particleStatus, CallbackInfo ci) { if (!(SodiumExtraClientMod.options().particleSettings.particles && SodiumExtraClientMod.options().particleSettings.rainSplash)) { - callbackInfo.cancel(); + ci.cancel(); } } - @Inject(method = "renderSnowAndRain", at = @At(value = "HEAD"), cancellable = true) - private void renderWeather(LightTexture manager, float f, double d, double e, double g, CallbackInfo callbackInfo) { + @Inject(method = "render(Lnet/minecraft/world/level/Level;Lnet/minecraft/client/renderer/LightTexture;IFLnet/minecraft/world/phys/Vec3;)V", at = @At(value = "HEAD"), cancellable = true) + private void renderWeather(Level level, LightTexture lightTexture, int i, float f, Vec3 vec3, CallbackInfo ci) { if (!(SodiumExtraClientMod.options().detailSettings.rainSnow)) { - callbackInfo.cancel(); + ci.cancel(); } } } diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/prevent_shaders/MixinGameRenderer.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/prevent_shaders/MixinGameRenderer.java index 2c1040fe..e5cbdb8a 100644 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/prevent_shaders/MixinGameRenderer.java +++ b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/prevent_shaders/MixinGameRenderer.java @@ -18,7 +18,7 @@ private void preventShaders(CallbackInfo ci) { } } - @Inject(method = "loadEffect", at = @At("HEAD"), cancellable = true) + @Inject(method = "setPostEffect", at = @At("HEAD"), cancellable = true) private void dontLoadShader(ResourceLocation identifier, CallbackInfo ci) { if (SodiumExtraClientMod.options().extraSettings.preventShaders) { ci.cancel(); diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/profiler/MixinBlockEntityRenderDispatcher.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/profiler/MixinBlockEntityRenderDispatcher.java deleted file mode 100644 index 2833b785..00000000 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/profiler/MixinBlockEntityRenderDispatcher.java +++ /dev/null @@ -1,43 +0,0 @@ -package me.flashyreese.mods.sodiumextra.mixin.profiler; - -import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; -import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.WeakHashMap; - -@Mixin(BlockEntityRenderDispatcher.class) -public class MixinBlockEntityRenderDispatcher { - @Unique - private static final WeakHashMap, String> names = new WeakHashMap<>(); - - @Inject(at = @At("HEAD"), method = "setupAndRender") - private static void onRender(BlockEntityRenderer renderer, T blockEntity, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumers, CallbackInfo info) { - Level level = blockEntity.getLevel(); - if (level != null) { - String name = names.computeIfAbsent(renderer.getClass(), Class::getSimpleName); - if (!name.isEmpty()) { - level.getProfiler().push(name); - } - } - } - - @Inject(at = @At("TAIL"), method = "setupAndRender") - private static void afterRender(BlockEntityRenderer renderer, T blockEntity, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumers, CallbackInfo info) { - Level level = blockEntity.getLevel(); - if (level != null) { - String name = names.computeIfAbsent(renderer.getClass(), Class::getSimpleName); - if (!name.isEmpty()) { - level.getProfiler().pop(); - } - } - } -} \ No newline at end of file diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/profiler/MixinEntityRenderDispatcher.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/profiler/MixinEntityRenderDispatcher.java deleted file mode 100644 index 3ca010fb..00000000 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/profiler/MixinEntityRenderDispatcher.java +++ /dev/null @@ -1,45 +0,0 @@ -package me.flashyreese.mods.sodiumextra.mixin.profiler; - -import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.entity.EntityRenderDispatcher; -import net.minecraft.client.renderer.entity.EntityRenderer; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Level; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.WeakHashMap; - -@Mixin(EntityRenderDispatcher.class) -public abstract class MixinEntityRenderDispatcher { - private static final WeakHashMap, String> names = new WeakHashMap<>(); - - @Shadow - public abstract EntityRenderer getRenderer(T entity); - - @Inject(at = @At("HEAD"), method = "render") - private void onRender(E entity, double x, double y, double z, float yaw, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumers, int light, CallbackInfo ci) { - Level level = entity.level(); - if (level != null) { - String name = names.computeIfAbsent(this.getRenderer(entity).getClass(), Class::getSimpleName); - if (!name.isEmpty()) { - level.getProfiler().push(name); - } - } - } - - @Inject(at = @At("TAIL"), method = "render") - private void afterRender(E entity, double x, double y, double z, float yaw, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumers, int light, CallbackInfo ci) { - Level level = entity.level(); - if (level != null) { - String name = names.computeIfAbsent(this.getRenderer(entity).getClass(), Class::getSimpleName); - if (!name.isEmpty()) { - level.getProfiler().pop(); - } - } - } -} \ No newline at end of file diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/block/entity/MixinBeaconRenderer.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/block/entity/MixinBeaconRenderer.java index 8bdc114e..57eb1d9c 100644 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/block/entity/MixinBeaconRenderer.java +++ b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/block/entity/MixinBeaconRenderer.java @@ -33,7 +33,7 @@ public void render(BeaconBlockEntity beaconBlockEntity, float f, PoseStack poseS private void modifyMaxY(PoseStack matrices, MultiBufferSource vertexConsumers, float tickDelta, long worldTime, int yOffset, int maxY, int color, BeaconBlockEntity beaconBlockEntity, float f, PoseStack matrixStack, MultiBufferSource vertexConsumerProvider, int i, int j) { if (maxY == 1024 && SodiumExtraClientMod.options().renderSettings.limitBeaconBeamHeight) { int lastSegment = beaconBlockEntity.getBlockPos().getY() + yOffset; - maxY = Objects.requireNonNull(beaconBlockEntity.getLevel()).getMaxBuildHeight() - lastSegment; + maxY = Objects.requireNonNull(beaconBlockEntity.getLevel()).getMaxY() - lastSegment; } renderBeaconBeam(matrices, vertexConsumers, tickDelta, worldTime, yOffset, maxY, color); } diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinItemFrameEntityRenderer.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinItemFrameEntityRenderer.java index e0c7881e..e4f4694f 100644 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinItemFrameEntityRenderer.java +++ b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinItemFrameEntityRenderer.java @@ -4,6 +4,7 @@ import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.ItemFrameRenderer; +import net.minecraft.client.renderer.entity.state.ItemFrameRenderState; import net.minecraft.world.entity.decoration.ItemFrame; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -14,15 +15,15 @@ @Mixin(ItemFrameRenderer.class) public class MixinItemFrameEntityRenderer { - @Inject(method = "render(Lnet/minecraft/world/entity/decoration/ItemFrame;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderer;render(Lnet/minecraft/world/entity/Entity;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", shift = At.Shift.AFTER), cancellable = true) - public void render(ItemFrame itemFrame, float f, float g, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) { + @Inject(method = "render(Lnet/minecraft/client/renderer/entity/state/ItemFrameRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderer;render(Lnet/minecraft/client/renderer/entity/state/EntityRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", shift = At.Shift.AFTER), cancellable = true) + public void render(ItemFrameRenderState itemFrameRenderState, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) { if (!SodiumExtraClientMod.options().renderSettings.itemFrame) { ci.cancel(); } } - @Inject(method = "shouldShowName(Lnet/minecraft/world/entity/decoration/ItemFrame;)Z", at = @At(value = "HEAD"), cancellable = true) - private void hasLabel(T entity, CallbackInfoReturnable cir) { + @Inject(method = "shouldShowName(Lnet/minecraft/world/entity/decoration/ItemFrame;D)Z", at = @At(value = "HEAD"), cancellable = true) + private void hasLabel(T itemFrame, double d, CallbackInfoReturnable cir) { if (!SodiumExtraClientMod.options().renderSettings.itemFrameNameTag) { cir.setReturnValue(false); } diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinLivingEntityRenderer.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinLivingEntityRenderer.java index c32cdf6b..3e8dea65 100644 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinLivingEntityRenderer.java +++ b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinLivingEntityRenderer.java @@ -9,6 +9,8 @@ import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.LivingEntityRenderer; import net.minecraft.client.renderer.entity.RenderLayerParent; +import net.minecraft.client.renderer.entity.state.ArmorStandRenderState; +import net.minecraft.client.renderer.entity.state.LivingEntityRenderState; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.decoration.ArmorStand; import org.spongepowered.asm.mixin.Mixin; @@ -18,24 +20,25 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(LivingEntityRenderer.class) -abstract class MixinLivingEntityRenderer> extends EntityRenderer implements RenderLayerParent { +abstract class MixinLivingEntityRenderer> extends EntityRenderer implements RenderLayerParent { + protected MixinLivingEntityRenderer(EntityRendererProvider.Context ctx) { super(ctx); } - @Inject(method = "render(Lnet/minecraft/world/entity/LivingEntity;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At("HEAD"), cancellable = true) - private void onRender(T entity, float f, float g, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) { - if (entity instanceof ArmorStand && !SodiumExtraClientMod.options().renderSettings.armorStand) { + @Inject(method = "render(Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At("HEAD"), cancellable = true) + private void onRender(S livingEntityRenderState, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) { + if (livingEntityRenderState instanceof ArmorStandRenderState && !SodiumExtraClientMod.options().renderSettings.armorStand) { ci.cancel(); - if (this.shouldShowName(entity)) { - this.renderNameTag(entity, entity.getDisplayName(), poseStack, multiBufferSource, i, g); + if (livingEntityRenderState.nameTag != null) { + this.renderNameTag(livingEntityRenderState, livingEntityRenderState.nameTag, poseStack, multiBufferSource, i); } } } - @Inject(method = "shouldShowName(Lnet/minecraft/world/entity/LivingEntity;)Z", at = @At(value = "HEAD"), cancellable = true) - private void shouldShowName(T entity, CallbackInfoReturnable cir) { - if (entity instanceof AbstractClientPlayer && !SodiumExtraClientMod.options().renderSettings.playerNameTag) { + @Inject(method = "shouldShowName(Lnet/minecraft/world/entity/LivingEntity;D)Z", at = @At(value = "HEAD"), cancellable = true) + private void shouldShowName(T livingEntity, double d, CallbackInfoReturnable cir) { + if (livingEntity instanceof AbstractClientPlayer && !SodiumExtraClientMod.options().renderSettings.playerNameTag) { cir.setReturnValue(false); } } diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinPaintingEntityRenderer.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinPaintingEntityRenderer.java index b263b29c..d7c70f81 100644 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinPaintingEntityRenderer.java +++ b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/render/entity/MixinPaintingEntityRenderer.java @@ -4,6 +4,7 @@ import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.PaintingRenderer; +import net.minecraft.client.renderer.entity.state.PaintingRenderState; import net.minecraft.world.entity.decoration.Painting; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -12,8 +13,8 @@ @Mixin(PaintingRenderer.class) public class MixinPaintingEntityRenderer { - @Inject(at = @At("HEAD"), method = "render(Lnet/minecraft/world/entity/decoration/Painting;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", cancellable = true) - public void render(Painting painting, float f, float g, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) { + @Inject(at = @At("HEAD"), method = "render(Lnet/minecraft/client/renderer/entity/state/PaintingRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", cancellable = true) + public void render(PaintingRenderState paintingRenderState, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) { if (!SodiumExtraClientMod.options().renderSettings.lightUpdates) ci.cancel(); } diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky/MixinLevelRenderer.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky/MixinLevelRenderer.java deleted file mode 100644 index 519baa92..00000000 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky/MixinLevelRenderer.java +++ /dev/null @@ -1,39 +0,0 @@ -package me.flashyreese.mods.sodiumextra.mixin.sky; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexBuffer; -import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.renderer.LevelRenderer; -import net.minecraft.client.renderer.ShaderInstance; -import org.joml.Matrix4f; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(LevelRenderer.class) -public class MixinLevelRenderer { - @WrapOperation( - method = "renderSky", - at = @At( - value = "INVOKE", - target = "Lcom/mojang/blaze3d/vertex/VertexBuffer;drawWithShader(Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;Lnet/minecraft/client/renderer/ShaderInstance;)V", - ordinal = 0 - ) - ) - public void redirectSetSkyShader(VertexBuffer instance, Matrix4f viewMatrix, Matrix4f projectionMatrix, ShaderInstance program, Operation original) { - if (SodiumExtraClientMod.options().detailSettings.sky) { - original.call(instance, viewMatrix, projectionMatrix, program); - } - } - - @Inject(method = "renderEndSky", at = @At(value = "HEAD"), cancellable = true) - public void preRenderEndSky(PoseStack stack, CallbackInfo ci) { - if (!SodiumExtraClientMod.options().detailSettings.sky) { - ci.cancel(); - } - } -} diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky/MixinSkyRenderer.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky/MixinSkyRenderer.java new file mode 100644 index 00000000..ca9011aa --- /dev/null +++ b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sky/MixinSkyRenderer.java @@ -0,0 +1,52 @@ +package me.flashyreese.mods.sodiumextra.mixin.sky; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.Tesselator; +import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; +import net.minecraft.client.renderer.FogParameters; +import net.minecraft.client.renderer.SkyRenderer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(SkyRenderer.class) +public class MixinSkyRenderer { + @Inject( + method = "renderSkyDisc", + at = @At(value = "HEAD"), cancellable = true + ) + public void redirectRenderSkyDisc(float f, float g, float h, CallbackInfo ci) { + if (!SodiumExtraClientMod.options().detailSettings.sky) { + ci.cancel(); + } + } + + @Inject(method = "renderEndSky", at = @At(value = "HEAD"), cancellable = true) + public void preRenderEndSky(PoseStack stack, CallbackInfo ci) { + if (!SodiumExtraClientMod.options().detailSettings.sky) { + ci.cancel(); + } + } + + @Inject(method = "renderSun", at = @At(value = "HEAD"), cancellable = true) + private void renderSun(float f, Tesselator tesselator, PoseStack poseStack, CallbackInfo ci) { + if (!SodiumExtraClientMod.options().detailSettings.sun) { + ci.cancel(); + } + } + + @Inject(method = "renderMoon", at = @At(value = "HEAD"), cancellable = true) + private void renderMoon(int i, float f, Tesselator tesselator, PoseStack poseStack, CallbackInfo ci) { + if (!SodiumExtraClientMod.options().detailSettings.moon) { + ci.cancel(); + } + } + + @Inject(method = "renderStars", at = @At(value = "HEAD"), cancellable = true) + private void renderStars(FogParameters fogParameters, float f, PoseStack poseStack, CallbackInfo ci) { + if (!SodiumExtraClientMod.options().detailSettings.stars) { + ci.cancel(); + } + } +} diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/stars/MixinLevelRenderer.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/stars/MixinLevelRenderer.java deleted file mode 100644 index bd95b79c..00000000 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/stars/MixinLevelRenderer.java +++ /dev/null @@ -1,28 +0,0 @@ -package me.flashyreese.mods.sodiumextra.mixin.stars; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.client.renderer.LevelRenderer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(LevelRenderer.class) -public class MixinLevelRenderer { - @WrapOperation( - method = "renderSky", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/multiplayer/ClientLevel;getStarBrightness(F)F" - ) - ) - public float redirectGetStarBrightness(ClientLevel instance, float f, Operation original) { - if (SodiumExtraClientMod.options().detailSettings.stars) { - return original.call(instance, f); - } else { - return 0.0f; - } - } -} diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sun_moon/MixinLevelRenderer.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sun_moon/MixinLevelRenderer.java deleted file mode 100644 index d5e2891f..00000000 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/sun_moon/MixinLevelRenderer.java +++ /dev/null @@ -1,61 +0,0 @@ -package me.flashyreese.mods.sodiumextra.mixin.sun_moon; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; -import net.minecraft.client.renderer.DimensionSpecialEffects; -import net.minecraft.client.renderer.LevelRenderer; -import net.minecraft.resources.ResourceLocation; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(LevelRenderer.class) -public class MixinLevelRenderer { - - @Mutable - @Shadow - @Final - private static ResourceLocation SUN_LOCATION; - - @Mutable - @Shadow - @Final - private static ResourceLocation MOON_LOCATION; - - @WrapOperation( - method = "renderSky", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/renderer/DimensionSpecialEffects;getSunriseColor(FF)[F" - ) - ) - public float[] redirectGetFogColorOverride(DimensionSpecialEffects instance, float skyAngle, float tickDelta, Operation original) { - if (SodiumExtraClientMod.options().detailSettings.sun) { - return original.call(instance, skyAngle, tickDelta); - } else { - return null; - } - } - - @Inject( - method = "allChanged()V", - at = @At(value = "TAIL") - ) - private void postWorldRendererReload(CallbackInfo ci) { - if (SodiumExtraClientMod.options().detailSettings.sun) { - SUN_LOCATION = ResourceLocation.withDefaultNamespace("textures/environment/sun.png"); - } else { - SUN_LOCATION = ResourceLocation.fromNamespaceAndPath("sodium-extra", "textures/transparent.png"); - } - if (SodiumExtraClientMod.options().detailSettings.moon) { - MOON_LOCATION = ResourceLocation.withDefaultNamespace("textures/environment/moon_phases.png"); - } else { - MOON_LOCATION = ResourceLocation.fromNamespaceAndPath("sodium-extra", "textures/transparent.png"); - } - } -} diff --git a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinToastManager.java b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinToastManager.java index eb564092..6c49184b 100644 --- a/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinToastManager.java +++ b/common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/toasts/MixinToastManager.java @@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(ToastComponent.class) +@Mixin(ToastManager.class) public class MixinToastManager { @Inject(method = "addToast", at = @At("HEAD"), cancellable = true) public void goodByeToasts(Toast toast, CallbackInfo ci) { diff --git a/common/src/main/resources/sodium-extra.mixins.json b/common/src/main/resources/sodium-extra.mixins.json index 44dd1816..ebaf2d89 100644 --- a/common/src/main/resources/sodium-extra.mixins.json +++ b/common/src/main/resources/sodium-extra.mixins.json @@ -21,14 +21,10 @@ "optimizations.beacon_beam_rendering.MixinBeaconRenderer", "optimizations.beacon_beam_rendering.MixinVertexSerializerRegistryImpl", "optimizations.beacon_beam_rendering.LevelRendererAccessor", - "optimizations.draw_helpers.MixinGuiGraphics", - "optimizations.fast_weather.MixinLevelRenderer", "particle.MixinFireworkParticle", "particle.MixinParticleEngine", "particle.MixinLevelRenderer", "prevent_shaders.MixinGameRenderer", - "profiler.MixinBlockEntityRenderDispatcher", - "profiler.MixinEntityRenderDispatcher", "reduce_resolution_on_mac.MixinWindow", "render.block.entity.MixinBeaconRenderer", "render.block.entity.MixinEnchantingTableBlockEntityRenderer", @@ -36,16 +32,14 @@ "render.entity.MixinItemFrameEntityRenderer", "render.entity.MixinLivingEntityRenderer", "render.entity.MixinPaintingEntityRenderer", - "sky.MixinLevelRenderer", + "sky.MixinSkyRenderer", "sky_colors.MixinBiome", "sodium.accessibility.MixinSodiumGameOptionPages", "sodium.cloud.MixinCloudRenderer", "sodium.fog.MixinOcclusionCuller", "sodium.scrollable_page.MixinSodiumOptionsGUI", "sodium.vsync.MixinSodiumGameOptionsPages", - "stars.MixinLevelRenderer", "steady_debug_hud.MixinDebugScreenOverlay", - "sun_moon.MixinLevelRenderer", "toasts.MixinToastManager" ], "injectors": { diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 220b4b35..2e7d6aac 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -51,7 +51,7 @@ "depends": { "fabricloader": ">=0.16", "sodium": ">=0.6.0", - "minecraft": ">=1.21" + "minecraft": ">=1.21.2" }, "breaks": { "iris": "<1.7.0", diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index bf1335fb..5242632c 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -19,7 +19,7 @@ Features that shouldn't be in Sodium. [[dependencies.sodium_extra]] modId = "minecraft" type = "required" -versionRange = "[1.21,1.21.1)" +versionRange = "[1.21.1,)" ordering = "NONE" side = "CLIENT"