Skip to content

Commit

Permalink
feat: Add a config option for ice formation in water during winter
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveplays28 committed Jun 15, 2024
1 parent 90c3109 commit e228a82
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import dev.isxander.yacl3.config.v2.api.ConfigClassHandler;
import dev.isxander.yacl3.config.v2.api.SerialEntry;
import dev.isxander.yacl3.config.v2.api.autogen.AutoGen;
import dev.isxander.yacl3.config.v2.api.autogen.Boolean;
import dev.isxander.yacl3.config.v2.api.autogen.FloatField;
import dev.isxander.yacl3.config.v2.api.autogen.FloatSlider;
import dev.isxander.yacl3.config.v2.api.serializer.GsonConfigSerializerBuilder;
Expand Down Expand Up @@ -31,4 +32,8 @@ public class SimpleSeasonsConfig {
@SerialEntry(comment = "The length multiplier of seasons. Increasing this value will result in longer seasons and decreasing this value will result in shorter seasons.")
@FloatField(min = 0.0001f, format = "%.4f")
public float seasonLengthMultiplier = 1f;
@AutoGen(category = SERVER_CATEGORY)
@SerialEntry(comment = "Determines if ice should form in water (with the exception of water in oceans and water in biomes with a wet/dry season) during winter.")
@Boolean(colored = true)
public boolean iceFormationInWaterDuringWinter = true;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.steveplays28.simpleseasons.mixin.world.biome;

import io.github.steveplays28.simpleseasons.api.SimpleSeasonsApi;
import io.github.steveplays28.simpleseasons.config.SimpleSeasonsConfig;
import io.github.steveplays28.simpleseasons.state.world.SeasonTracker;
import net.fabricmc.fabric.api.tag.convention.v1.ConventionalBiomeTags;
import net.minecraft.block.Blocks;
Expand Down Expand Up @@ -28,7 +29,7 @@ public abstract class BiomeMixin {
return;
}

if ( !this.hasPrecipitation() || SimpleSeasonsApi.biomeHasWetAndDrySeasons(
if (!this.hasPrecipitation() || SimpleSeasonsApi.biomeHasWetAndDrySeasons(
world.getBiome(blockPos)) || !Blocks.SNOW.getDefaultState().canPlaceAt(world, blockPos)) {
cir.setReturnValue(false);
return;
Expand All @@ -39,12 +40,14 @@ public abstract class BiomeMixin {

@Inject(method = "canSetIce(Lnet/minecraft/world/WorldView;Lnet/minecraft/util/math/BlockPos;Z)Z", at = @At(value = "HEAD"), cancellable = true)
private void simple_seasons$canSetIceAllowSettingIceInWinter(@NotNull WorldView worldView, @NotNull BlockPos blockPos, boolean doWaterCheck, @NotNull CallbackInfoReturnable<Boolean> cir) {
if (!(worldView instanceof @NotNull World world) || !SimpleSeasonsApi.worldHasSeasons(world)) {
if (!(worldView instanceof @NotNull World world) || !SimpleSeasonsApi.worldHasSeasons(
world) || !SimpleSeasonsConfig.HANDLER.instance().iceFormationInWaterDuringWinter) {
return;
}

var biome = world.getBiome(blockPos);
if (biome.isIn(ConventionalBiomeTags.OCEAN) || SimpleSeasonsApi.biomeHasWetAndDrySeasons(world.getBiome(blockPos)) || world.getLightLevel(
if (biome.isIn(ConventionalBiomeTags.OCEAN) || SimpleSeasonsApi.biomeHasWetAndDrySeasons(
world.getBiome(blockPos)) || world.getLightLevel(
LightType.BLOCK, blockPos) >= 10 || doWaterCheck && !world.getFluidState(blockPos).isOf(Fluids.WATER)) {
cir.setReturnValue(false);
return;
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/assets/simple_seasons/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"yacl3.config.simple-seasons:config.seasonProgressUpdateRate": "Season Progress Update Rate",
"yacl3.config.simple-seasons:config.seasonProgressUpdateRate.desc": "The rate at which the season progress updates. Every time the season progress updates in a world, a packet is sent to all clients in that world containing the new season progress. Subsequently, all clients in that world will reload the world's color and schedule a rebuild for all chunks.\nIncreasing this value will result in packets being sent more often to all clients in a world and thus season colors will update more often on all clients in that world. Decreasing this value will result in packets being sent less often to all clients in a world and thus season colors will update less often on all clients in that world. This config option can be performance intensive if set too high.",
"yacl3.config.simple-seasons:config.seasonLengthMultiplier": "Season Length Multiplier",
"yacl3.config.simple-seasons:config.seasonLengthMultiplier.desc": "The length multiplier of seasons. Increasing this value will result in longer seasons and decreasing this value will result in shorter seasons."
"yacl3.config.simple-seasons:config.seasonLengthMultiplier.desc": "The length multiplier of seasons. Increasing this value will result in longer seasons and decreasing this value will result in shorter seasons.",
"yacl3.config.simple-seasons:config.iceFormationInWaterDuringWinter": "Ice Formation In Water During Winter",
"yacl3.config.simple-seasons:config.iceFormationInWaterDuringWinter.desc": "Determines if ice should form in water (with the exception of water in oceans and water in biomes with a wet/dry season) during winter."
}

0 comments on commit e228a82

Please sign in to comment.