Skip to content

Commit

Permalink
feat: Add a config option for showing the sleep vignette
Browse files Browse the repository at this point in the history
Thank you to [EnragedPotato](https://github.com/EnragedPotato) for the suggestion in #68.
  • Loading branch information
Steveplays28 committed Aug 23, 2024
1 parent 24fb35a commit adcabf2
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Integer> original) {
if (StevesRealisticSleep.config.showSleepVignette) {
return original.call(instance);
}

return -1;
}
}
Original file line number Diff line number Diff line change
@@ -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?",
Expand Down
Original file line number Diff line number Diff line change
@@ -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?",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
],
"injectors": {
"defaultRequire": 1
}
},
"client": [
"client.gui.InGameHudMixin"
]
}

0 comments on commit adcabf2

Please sign in to comment.