From 302eaa123bbe575c18ad988b09505fda76c6fd11 Mon Sep 17 00:00:00 2001 From: AnOpenSauceDev <119765865+AnOpenSauceDev@users.noreply.github.com> Date: Mon, 27 May 2024 17:35:06 +1000 Subject: [PATCH] Fix stuff, properly fix #98 #97 --- build.gradle | 4 ++-- gradle.properties | 4 ++-- .../java/com/modrinth/methane/Methane.java | 2 +- .../com/modrinth/methane/MethaneSettings.java | 3 --- .../mixin/ChunkLightProviderMixin.java | 22 +++++++++++++++++++ .../methane/mixin/LightingProviderMixin.java | 6 ++++- .../methane/mixin/WorldRendererMixin.java | 13 +---------- src/main/resources/methane.mixins.json | 1 + 8 files changed, 34 insertions(+), 21 deletions(-) create mode 100644 src/main/java/com/modrinth/methane/mixin/ChunkLightProviderMixin.java diff --git a/build.gradle b/build.gradle index b6e45b8..e691cb8 100644 --- a/build.gradle +++ b/build.gradle @@ -30,8 +30,8 @@ repositories { dependencies { - modApi "com.terraformersmc:modmenu:9.0.0" - modApi( "me.shedaniel.cloth:cloth-config-fabric:13.0.121") + modApi "com.terraformersmc:modmenu:10.0.0-beta.1" + modApi( "me.shedaniel.cloth:cloth-config-fabric:14.0.126") // To change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" diff --git a/gradle.properties b/gradle.properties index c7f4359..c5e21e5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,11 +3,11 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://modmuss50.me/fabric.html minecraft_version=1.20.6 -yarn_mappings=1.20.6+build.1 +yarn_mappings=1.20.6+build.3 loader_version=0.15.11 # Fabric API -fabric_version=0.98.0+1.20.6 +fabric_version=0.99.0+1.20.6 # LibMCdev libmcdev_version=1.4.2 diff --git a/src/main/java/com/modrinth/methane/Methane.java b/src/main/java/com/modrinth/methane/Methane.java index 534e623..40c6679 100644 --- a/src/main/java/com/modrinth/methane/Methane.java +++ b/src/main/java/com/modrinth/methane/Methane.java @@ -33,7 +33,7 @@ public void onInitialize() { - if(Methane.settings.destructiveSettings.DestroySky || Methane.settings.destructiveSettings.DestroyWeather || Methane.settings.destructiveSettings.destructiveweatheroptimizations || Methane.settings.destructiveSettings.RenderLayerSkips){ + if(Methane.settings.destructiveSettings.DestroyWeather || Methane.settings.destructiveSettings.destructiveweatheroptimizations || Methane.settings.destructiveSettings.RenderLayerSkips){ Methane.MethaneLogger.warn("One or more destructive Methane renderer features are being used. You might experience unusual bugs with other mods."); } } diff --git a/src/main/java/com/modrinth/methane/MethaneSettings.java b/src/main/java/com/modrinth/methane/MethaneSettings.java index 4e25031..7341659 100644 --- a/src/main/java/com/modrinth/methane/MethaneSettings.java +++ b/src/main/java/com/modrinth/methane/MethaneSettings.java @@ -56,9 +56,6 @@ public static class DestructiveSettings{ @Comment("Whether or not we calculate rainfall in biomes (breaks a lot of rain effects, but has performance benefits)") public boolean destructiveweatheroptimizations = false; - @Comment("Deletes the sky (NOT the same as sky fog), and gives a small performance boost. Will also remove the sun + moon") - public boolean DestroySky; - @Comment("Forcefully deletes weather.") public boolean DestroyWeather; diff --git a/src/main/java/com/modrinth/methane/mixin/ChunkLightProviderMixin.java b/src/main/java/com/modrinth/methane/mixin/ChunkLightProviderMixin.java new file mode 100644 index 0000000..c600ebc --- /dev/null +++ b/src/main/java/com/modrinth/methane/mixin/ChunkLightProviderMixin.java @@ -0,0 +1,22 @@ +package com.modrinth.methane.mixin; + +import com.modrinth.methane.Methane; +import net.minecraft.world.chunk.light.ChunkLightProvider; +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.CallbackInfoReturnable; + +@Mixin(ChunkLightProvider.class) +public class ChunkLightProviderMixin { + + @Inject(method = "doLightUpdates", at = @At("HEAD"),cancellable = true) + public void hack(CallbackInfoReturnable cir){ + + if(!Methane.settings.useOldLightingEngine && Methane.ModActive){ + cir.cancel(); + } + + } + +} diff --git a/src/main/java/com/modrinth/methane/mixin/LightingProviderMixin.java b/src/main/java/com/modrinth/methane/mixin/LightingProviderMixin.java index 6364351..90111fa 100644 --- a/src/main/java/com/modrinth/methane/mixin/LightingProviderMixin.java +++ b/src/main/java/com/modrinth/methane/mixin/LightingProviderMixin.java @@ -2,6 +2,9 @@ import com.modrinth.methane.Methane; import net.minecraft.client.MinecraftClient; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardDisplaySlot; +import net.minecraft.scoreboard.ScoreboardEntry; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkSectionPos; import net.minecraft.world.HeightLimitView; @@ -42,12 +45,13 @@ boolean isNotInSinglePlayer(){ // we lose out on a lot of performance, but savin @Inject(method = "doLightUpdates",at =@At("HEAD"),cancellable = true) public void doLightUpdates(CallbackInfoReturnable cir) { if(Methane.ModActive && !Methane.settings.useOldLightingEngine) - cir.cancel(); + cir.setReturnValue(0); } @Inject(method = "getLight", at = @At("HEAD"),cancellable = true) public void forceLight(BlockPos pos, int ambientDarkness, CallbackInfoReturnable cir){ if(Methane.ModActive) { + cir.setReturnValue(15); cir.cancel(); } } diff --git a/src/main/java/com/modrinth/methane/mixin/WorldRendererMixin.java b/src/main/java/com/modrinth/methane/mixin/WorldRendererMixin.java index 8bb929c..276ef1e 100644 --- a/src/main/java/com/modrinth/methane/mixin/WorldRendererMixin.java +++ b/src/main/java/com/modrinth/methane/mixin/WorldRendererMixin.java @@ -1,10 +1,7 @@ package com.modrinth.methane.mixin; import com.modrinth.methane.Methane; -import com.modrinth.methane.MethaneSettings; -import net.minecraft.block.BlockRenderType; import net.minecraft.client.render.*; -import net.minecraft.client.util.math.MatrixStack; import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -14,15 +11,6 @@ @Mixin(value = WorldRenderer.class,priority = 1000) public class WorldRendererMixin { - /* - @Inject(method = "renderSky(Lnet/minecraft/client/util/math/MatrixStack;Lorg/joml/Matrix4f;FLnet/minecraft/client/render/Camera;ZLjava/lang/Runnable;)V", at = @At("HEAD"),cancellable = true) - public void deletesky(MatrixStack matrices, Matrix4f projectionMatrix, float tickDelta, Camera camera, boolean thickFog, Runnable fogCallback, CallbackInfo ci){ - if(Methane.settings.destructiveSettings.DestroySky) - ci.cancel(); - } - - */ - @Inject(method = "renderWeather", at = @At("HEAD"),cancellable = true) public void delWeather(LightmapTextureManager manager, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci){ if(Methane.settings.destructiveSettings.DestroyWeather) @@ -37,6 +25,7 @@ public void debugDeleteLayers(RenderLayer renderLayer, double x, double y, doubl Methane.MethaneDebugger.LogWarning("skipped renderlayer + " + renderLayer); ci.cancel(); } + } diff --git a/src/main/resources/methane.mixins.json b/src/main/resources/methane.mixins.json index 4bc1b5d..d380824 100644 --- a/src/main/resources/methane.mixins.json +++ b/src/main/resources/methane.mixins.json @@ -5,6 +5,7 @@ "compatibilityLevel": "JAVA_17", "mixins": [ "BackgroundRendererMixin", + "ChunkLightProviderMixin", "GameRendererMixin", "LightingProviderMixin", "LightmapTextureManagerMixin",