Skip to content

Commit

Permalink
Fix snowy biome colours + warning screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
IMB11 committed Aug 31, 2024
1 parent 42ce8ae commit 3c7c5b7
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// 1.21.1 2024-08-30T19:57:10.8858252 Fog/Custom Fog Definition:fog
// 1.21.1 2024-08-31T10:48:07.9332249 Fog/Custom Fog Definition:fog
ed7a26be0cdc64db4e2714898fec43817761c00b assets\minecraft\fog_definitions\biome\crimson_forest.json
61268868389f80ddd2fc175dab578a5a6d3775dd assets\c\fog_definitions\tag\biome\is_aquatic_icy.json
bdf7dff67ada32610d3c8970f29d8c74d654ca55 assets\c\fog_definitions\tag\biome\is_beach.json
efa18c3764d4d5d57a4ca2f3dabd69d188148a19 assets\minecraft\fog_definitions\biome\soul_sand_valley.json
ff9939863833df7f1cc8b94bec65cb20c1272cce assets\c\fog_definitions\tag\biome\is_snowy.json
081f23017dccbbbbf86d0fed5183724dd3b2fae7 assets\minecraft\fog_definitions\biome\basalt_deltas.json
0aadd5cec8445c0814015d19f23cfb515e4fff62 assets\c\fog_definitions\tag\biome\is_badlands.json
d18991fdc8b5c612a3ae1b45144585860b1bf064 assets\minecraft\fog_definitions\biome\nether_wastes.json
6ab53206f31ea26518ebf301389f655c2846e67e assets\c\fog_definitions\tag\biome\is_desert.json
d18991fdc8b5c612a3ae1b45144585860b1bf064 assets\minecraft\fog_definitions\biome\nether_wastes.json
024071636ecdb7f6288625a11a90b2d75d65c917 assets\minecraft\fog_definitions\biome\sparse_jungle.json
61268868389f80ddd2fc175dab578a5a6d3775dd assets\c\fog_definitions\tag\biome\is_aquatic_icy.json
bdf7dff67ada32610d3c8970f29d8c74d654ca55 assets\c\fog_definitions\tag\biome\is_beach.json
efa18c3764d4d5d57a4ca2f3dabd69d188148a19 assets\minecraft\fog_definitions\biome\soul_sand_valley.json
4a095b16c1146432aee0cd907ceb87d33c031738 assets\c\fog_definitions\tag\biome\is_end.json
5e48288dad15e0c0bfd3db7ada891bc50cdbc5a2 assets\c\fog_definitions\tag\biome\is_jungle.json
450e4e8e01a0af4128b371ad342d4a0d7bd9e560 assets\c\fog_definitions\tag\biome\is_swamp.json
e21ca1bacda76f8e67c3a79262c54bb45b0f70ce assets\minecraft\fog_definitions\biome\warped_forest.json
66dbd1cc3283d1f6a3f9f8c789e67baabc193059 assets\c\fog_definitions\tag\biome\is_snowy.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"colors": {
"day": "#F4F9EF",
"night": "#F4F9EF"
"day": "#DFEBF4",
"night": "#687782"
},
"end_multiplier": 1.0,
"start_multiplier": 1.0
Expand Down
52 changes: 52 additions & 0 deletions src/main/java/dev/imb11/fog/client/util/UpdateWarningHelper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package dev.imb11.fog.client.util;

import dev.imb11.fog.client.FogClient;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConfirmScreen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;

import java.nio.file.Files;

public class UpdateWarningHelper {
// TODO: Bump this every time you modify something within the datagen classes.
public static int getDatagenVersion() {
return 1;
}

public static void checkVersion() {
var datagenVersionPath = FogClient.getConfigFolder().resolve("datagen.version");

boolean shouldWarn = true;
// Check if datagenVersionPath content is < datagenVersion
if (datagenVersionPath.toFile().exists()) {
try {
var version = Integer.parseInt(Files.readString(datagenVersionPath));
if (version >= getDatagenVersion()) {
shouldWarn = false;
}
} catch (Exception e) {
// Ignore
}
}

if (shouldWarn) {
MinecraftClient client = MinecraftClient.getInstance();

client.setScreen(new ConfirmScreen(
confirmed -> {
try {
Files.writeString(datagenVersionPath, Integer.toString(getDatagenVersion()));
} catch (Exception ignored) {}
client.setScreen(new TitleScreen());
},
Text.translatable("fog.datagen_warning.title"),
Text.translatable("fog.datagen_warning.message"),
ScreenTexts.OK,
ScreenTexts.OK
));
FogClient.LOGGER.info("Datagen warning displayed - you may need to delete the `.minecraft/config/fog/fog_definitions` folder.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void acceptBiomeTags(@NotNull BiConsumer<TagKey<Biome>, CustomFogDefiniti
.colors("#D1C8AB", "#827D6A").build());

provider.accept(ConventionalBiomeTags.IS_SNOWY, CustomFogDefinition.Builder.create()
.colors("#F4F9EF", "#F4F9EF").build());
.colors("#DFEBF4", "#687782").build());

provider.accept(ConventionalBiomeTags.IS_AQUATIC_ICY, CustomFogDefinition.Builder.create()
.colors("#BDDBE1", "#526C72").build());
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/dev/imb11/fog/mixin/client/ui/TitleScreenMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package dev.imb11.fog.mixin.client.ui;

import dev.imb11.fog.client.util.UpdateWarningHelper;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.TitleScreen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(TitleScreen.class)
public class TitleScreenMixin {
@Shadow
private boolean doBackgroundFade;

@Unique
private static boolean hasShown = false;

@Inject(at = @At("HEAD"), method = "render")
public void showAfterLoaded(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (this.doBackgroundFade && !hasShown) {
UpdateWarningHelper.checkVersion();
hasShown = true;
}
}
}
2 changes: 2 additions & 0 deletions src/main/resources/assets/fog/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"fog.datagen_warning.title": "§6§l§nWarning!§r",
"fog.datagen_warning.message": "Fog has been updated, changing the default biome fog colors.\nPlease back up your changes to the `.minecraft/config/fog/fog_definitions` folder before deleting it to apply the new changes.\nThis will not be shown again. (Note: Pressing 'OK' will not delete the folder for you.)",
"fog.config.category.fog_calculations": "Fog Calculations",
"fog.config.option.fog_calculations.warning": "§6§l§nWarning!§r It is not recommended to touch these constants unless you understand what they do, and how they are used.\nConsider leaving them as-is for the best experience.",
"fog.config.option.initial_fog_start": "Initial Fog Start",
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/fog.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"mixins": [],
"client": [
"client.rendering.BackgroundRendererMixin",
"client.rendering.WorldRendererMixin"
"client.rendering.WorldRendererMixin",
"client.ui.TitleScreenMixin"
]
}

0 comments on commit 3c7c5b7

Please sign in to comment.