diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index 8bd8e2ac8f..c8f4bfc93a 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -1127,4 +1127,11 @@ public enum FungusGrowthMode { category = {SURVIVAL, FEATURE} ) public static FungusGrowthMode thickFungusGrowth = FungusGrowthMode.FALSE; + + @Rule( + desc = "Reset a dimension's weather in every tick if it has no sky light", + extra = {"This is intended to fix MC-168329"}, + category = BUGFIX + ) + public static boolean noWeatherInSkylightlessDimension = false; } diff --git a/src/main/java/carpet/mixins/ServerLevel_noWeatherMixin.java b/src/main/java/carpet/mixins/ServerLevel_noWeatherMixin.java new file mode 100644 index 0000000000..7e480c10a8 --- /dev/null +++ b/src/main/java/carpet/mixins/ServerLevel_noWeatherMixin.java @@ -0,0 +1,38 @@ +package carpet.mixins; + +import java.util.function.Supplier; + +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; + +import carpet.CarpetSettings; +import net.minecraft.core.Holder; +import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.ResourceKey; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.world.level.storage.WritableLevelData; + +@Mixin(ServerLevel.class) +public abstract class ServerLevel_noWeatherMixin extends Level { + + protected ServerLevel_noWeatherMixin(WritableLevelData writableLevelData, ResourceKey resourceKey, + RegistryAccess registryAccess, Holder holder, Supplier supplier, boolean bl, + boolean bl2, long l, int i) { + super(writableLevelData, resourceKey, registryAccess, holder, supplier, bl, bl2, l, i); + } + + @Inject(method = "advanceWeatherCycle", at = @At("HEAD")) + private void resetWeather(CallbackInfo ci) { + if (CarpetSettings.noWeatherInSkylightlessDimension && !super.dimensionType().hasSkyLight()) { + super.oRainLevel = super.rainLevel; + super.oThunderLevel = super.thunderLevel; + super.rainLevel = 0; + super.thunderLevel = 0; + } + } +} diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index 2594ed2111..dc5f2d5a74 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -184,7 +184,8 @@ "ChestBlock_customStickyMixin", "HoneyBlock_customStickyMixin", "PistonStructureResolver_customStickyMixin", - "SlimeBlock_customStickyMixin" + "SlimeBlock_customStickyMixin", + "ServerLevel_noWeatherMixin" ], "client": [ "ClientLevel_tickSpeedMixin",