Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary fix for MC-168329 #1783

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/main/java/carpet/CarpetSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
38 changes: 38 additions & 0 deletions src/main/java/carpet/mixins/ServerLevel_noWeatherMixin.java
Original file line number Diff line number Diff line change
@@ -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<Level> resourceKey,
RegistryAccess registryAccess, Holder<DimensionType> holder, Supplier<ProfilerFiller> 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;
}
}
}
3 changes: 2 additions & 1 deletion src/main/resources/carpet.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@
"ChestBlock_customStickyMixin",
"HoneyBlock_customStickyMixin",
"PistonStructureResolver_customStickyMixin",
"SlimeBlock_customStickyMixin"
"SlimeBlock_customStickyMixin",
"ServerLevel_noWeatherMixin"
],
"client": [
"ClientLevel_tickSpeedMixin",
Expand Down