diff --git a/common/src/main/java/io/github/steveplays28/stevesrealisticsleep/config/StevesRealisticSleepConfig.java b/common/src/main/java/io/github/steveplays28/stevesrealisticsleep/config/StevesRealisticSleepConfig.java index 8298514..8b49b92 100644 --- a/common/src/main/java/io/github/steveplays28/stevesrealisticsleep/config/StevesRealisticSleepConfig.java +++ b/common/src/main/java/io/github/steveplays28/stevesrealisticsleep/config/StevesRealisticSleepConfig.java @@ -7,6 +7,9 @@ @Config(name = StevesRealisticSleep.MOD_NAMESPACE) public class StevesRealisticSleepConfig implements ConfigData { + @ConfigEntry.Gui.Tooltip + public boolean showSleepVignette = true; + @ConfigEntry.Gui.Tooltip public boolean sendDawnMessage = true; @ConfigEntry.Gui.Tooltip diff --git a/common/src/main/java/io/github/steveplays28/stevesrealisticsleep/mixin/client/gui/InGameHudMixin.java b/common/src/main/java/io/github/steveplays28/stevesrealisticsleep/mixin/client/gui/InGameHudMixin.java new file mode 100644 index 0000000..77dc33f --- /dev/null +++ b/common/src/main/java/io/github/steveplays28/stevesrealisticsleep/mixin/client/gui/InGameHudMixin.java @@ -0,0 +1,25 @@ +package io.github.steveplays28.stevesrealisticsleep.mixin.client.gui; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import io.github.steveplays28.stevesrealisticsleep.StevesRealisticSleep; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.client.network.ClientPlayerEntity; +import org.jetbrains.annotations.NotNull; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Environment(EnvType.CLIENT) +@Mixin(InGameHud.class) +public class InGameHudMixin { + @WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getSleepTimer()I")) + private int stevesrealisticsleep$cancelSleepVignetteIfDisabled(ClientPlayerEntity instance, @NotNull Operation original) { + if (StevesRealisticSleep.config.showSleepVignette) { + return original.call(instance); + } + + return -1; + } +} diff --git a/common/src/main/resources/assets/steves_realistic_sleep/lang/en_us.json b/common/src/main/resources/assets/steves_realistic_sleep/lang/en_us.json index c4f00cc..b43f6f8 100644 --- a/common/src/main/resources/assets/steves_realistic_sleep/lang/en_us.json +++ b/common/src/main/resources/assets/steves_realistic_sleep/lang/en_us.json @@ -1,5 +1,7 @@ { "text.autoconfig.steves_realistic_sleep.title": "Realistic Sleep Config", + "text.autoconfig.steves_realistic_sleep.option.showSleepVignette": "Show sleep vignette?", + "text.autoconfig.steves_realistic_sleep.option.showSleepVignette.@Tooltip": "Show the sleep vignette (dark overlay) while sleeping.", "text.autoconfig.steves_realistic_sleep.option.sendDawnMessage": "Send dawn message?", "text.autoconfig.steves_realistic_sleep.option.sendDawnMessage.@Tooltip": "Send a message to all players on the actionbar at dawn.", "text.autoconfig.steves_realistic_sleep.option.sendDuskMessage": "Send dusk message?", diff --git a/common/src/main/resources/data/steves_realistic_sleep/lang/en_us.json b/common/src/main/resources/data/steves_realistic_sleep/lang/en_us.json index c4f00cc..b43f6f8 100644 --- a/common/src/main/resources/data/steves_realistic_sleep/lang/en_us.json +++ b/common/src/main/resources/data/steves_realistic_sleep/lang/en_us.json @@ -1,5 +1,7 @@ { "text.autoconfig.steves_realistic_sleep.title": "Realistic Sleep Config", + "text.autoconfig.steves_realistic_sleep.option.showSleepVignette": "Show sleep vignette?", + "text.autoconfig.steves_realistic_sleep.option.showSleepVignette.@Tooltip": "Show the sleep vignette (dark overlay) while sleeping.", "text.autoconfig.steves_realistic_sleep.option.sendDawnMessage": "Send dawn message?", "text.autoconfig.steves_realistic_sleep.option.sendDawnMessage.@Tooltip": "Send a message to all players on the actionbar at dawn.", "text.autoconfig.steves_realistic_sleep.option.sendDuskMessage": "Send dusk message?", diff --git a/common/src/main/resources/steves_realistic_sleep-common.mixins.json b/common/src/main/resources/steves_realistic_sleep-common.mixins.json index 7478758..8e49762 100644 --- a/common/src/main/resources/steves_realistic_sleep-common.mixins.json +++ b/common/src/main/resources/steves_realistic_sleep-common.mixins.json @@ -13,5 +13,8 @@ ], "injectors": { "defaultRequire": 1 - } + }, + "client": [ + "client.gui.InGameHudMixin" + ] }