From f5a67b87276607fb2061d934e7aa1f4b7d680237 Mon Sep 17 00:00:00 2001 From: TheDeathlyCow <thedeathlycow@gmail.com> Date: Mon, 11 Dec 2023 23:28:35 -1000 Subject: [PATCH 1/8] fix farmers delight hot cocoa compat --- build.gradle | 3 ++ gradle.properties | 5 ++- .../frostiful/compat/FoodIntegration.java | 42 +++++++++++++++++++ .../compat/FrostifulIntegrations.java | 8 ---- .../frostiful/compat/SeasonsIntegration.java | 21 ++++++++++ .../present/HotCocoaItemMixin.java | 38 +++++++++++++++++ .../mixins/food/compat/WarmFoodMixin.java | 27 ++---------- .../AmbientTemperatureController.java | 3 +- src/main/resources/frostiful.mixins.json | 2 + 9 files changed, 115 insertions(+), 34 deletions(-) create mode 100644 src/main/java/com/github/thedeathlycow/frostiful/compat/FoodIntegration.java create mode 100644 src/main/java/com/github/thedeathlycow/frostiful/compat/SeasonsIntegration.java create mode 100644 src/main/java/com/github/thedeathlycow/frostiful/mixins/compat/farmersdelight/present/HotCocoaItemMixin.java diff --git a/build.gradle b/build.gradle index 0308cd9b..53894e0f 100644 --- a/build.gradle +++ b/build.gradle @@ -84,6 +84,9 @@ dependencies { // Fabric Seasons https://modrinth.com/mod/fabric-seasons modCompileOnly("maven.modrinth:fabric-seasons:${project.fabric_seasons_version}") { transitive = false } + // Farmer's Delight and add ons + modCompileOnly("maven.modrinth:farmers-delight-fabric:${project.farmers_delight_version}") { transitive = false } + modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-base:${project.cardinal_components_version}" modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${project.cardinal_components_version}" // Includes Cardinal Components API as a Jar-in-Jar dependency (optional but recommended) diff --git a/gradle.properties b/gradle.properties index 17fbb9d9..daf8aabf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -39,4 +39,7 @@ cardinal_components_version=5.2.1 trinkets_version=3.7.0 # Fabric Seasons -fabric_seasons_version=2.3+1.20 \ No newline at end of file +fabric_seasons_version=2.3+1.20 + +# Farmer's Delight and addons +farmers_delight_version=1.4.3 \ No newline at end of file diff --git a/src/main/java/com/github/thedeathlycow/frostiful/compat/FoodIntegration.java b/src/main/java/com/github/thedeathlycow/frostiful/compat/FoodIntegration.java new file mode 100644 index 00000000..82991d67 --- /dev/null +++ b/src/main/java/com/github/thedeathlycow/frostiful/compat/FoodIntegration.java @@ -0,0 +1,42 @@ +package com.github.thedeathlycow.frostiful.compat; + +import com.github.thedeathlycow.frostiful.Frostiful; +import com.github.thedeathlycow.frostiful.entity.effect.FStatusEffects; +import com.github.thedeathlycow.frostiful.tag.FItemTags; +import com.github.thedeathlycow.frostiful.util.TextStyles; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.effect.StatusEffectInstance; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.text.Text; + +import java.util.List; + +public class FoodIntegration { + + public static void onConsumeFood(Item item, ItemStack stack, LivingEntity user) { + if (isWarmingFood(item, stack)) { + applyWarmthFromFood(user); + } + } + + public static void appendWarmthTooltip(Item item, ItemStack stack, List<Text> tooltip) { + if (isWarmingFood(item, stack)) { + tooltip.add(Text.translatable("item.frostiful.warming.tooltip") + .setStyle(TextStyles.WARMING_TOOLTIP)); + } + } + + private static boolean isWarmingFood(Item item, ItemStack stack) { + return stack.isIn(FItemTags.WARM_FOODS); + } + + private static void applyWarmthFromFood(LivingEntity user) { + int duration = Frostiful.getConfig().freezingConfig.getWarmFoodWarmthTime(); + user.addStatusEffect(new StatusEffectInstance(FStatusEffects.WARMTH, duration)); + } + + private FoodIntegration() { + + } +} diff --git a/src/main/java/com/github/thedeathlycow/frostiful/compat/FrostifulIntegrations.java b/src/main/java/com/github/thedeathlycow/frostiful/compat/FrostifulIntegrations.java index 204f56be..8134a8bb 100644 --- a/src/main/java/com/github/thedeathlycow/frostiful/compat/FrostifulIntegrations.java +++ b/src/main/java/com/github/thedeathlycow/frostiful/compat/FrostifulIntegrations.java @@ -24,12 +24,4 @@ public static boolean isHeartsRenderOverridden() { public static boolean isModLoaded(String id) { return FabricLoader.getInstance().isModLoaded(id); } - - public static boolean isWinter(World world) { - if (isModLoaded(FABRIC_SEASONS_ID)) { - return Season.WINTER == FabricSeasons.getCurrentSeason(world); - } else { - return false; - } - } } diff --git a/src/main/java/com/github/thedeathlycow/frostiful/compat/SeasonsIntegration.java b/src/main/java/com/github/thedeathlycow/frostiful/compat/SeasonsIntegration.java new file mode 100644 index 00000000..cdc9aebc --- /dev/null +++ b/src/main/java/com/github/thedeathlycow/frostiful/compat/SeasonsIntegration.java @@ -0,0 +1,21 @@ +package com.github.thedeathlycow.frostiful.compat; + +import io.github.lucaargolo.seasons.FabricSeasons; +import io.github.lucaargolo.seasons.utils.Season; +import net.minecraft.world.World; + +public class SeasonsIntegration { + + public static boolean isWinter(World world) { + if (FrostifulIntegrations.isModLoaded(FrostifulIntegrations.FABRIC_SEASONS_ID)) { + return Season.WINTER == FabricSeasons.getCurrentSeason(world); + } else { + return false; + } + } + + private SeasonsIntegration() { + + } + +} diff --git a/src/main/java/com/github/thedeathlycow/frostiful/mixins/compat/farmersdelight/present/HotCocoaItemMixin.java b/src/main/java/com/github/thedeathlycow/frostiful/mixins/compat/farmersdelight/present/HotCocoaItemMixin.java new file mode 100644 index 00000000..7c0dddf9 --- /dev/null +++ b/src/main/java/com/github/thedeathlycow/frostiful/mixins/compat/farmersdelight/present/HotCocoaItemMixin.java @@ -0,0 +1,38 @@ +package com.github.thedeathlycow.frostiful.mixins.compat.farmersdelight.present; + +import com.github.thedeathlycow.frostiful.compat.FoodIntegration; +import com.nhoryzon.mc.farmersdelight.item.HotCocoaItem; +import com.nhoryzon.mc.farmersdelight.item.MilkBottleItem; +import net.minecraft.client.item.TooltipContext; +import net.minecraft.entity.LivingEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.text.Text; +import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; +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 java.util.List; + +@Mixin(HotCocoaItem.class) +public abstract class HotCocoaItemMixin extends MilkBottleItem { + + @Inject( + method = "affectConsumer", + at = @At("HEAD") + ) + private void onConsume(ItemStack stack, World world, LivingEntity user, CallbackInfo ci) { + FoodIntegration.onConsumeFood(this, stack, user); + } + + @Inject( + method = "appendTooltip", + at = @At("HEAD") + ) + private void appendWarmthToolTip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context, CallbackInfo ci) { + FoodIntegration.appendWarmthTooltip(this, stack, tooltip); + } + +} diff --git a/src/main/java/com/github/thedeathlycow/frostiful/mixins/food/compat/WarmFoodMixin.java b/src/main/java/com/github/thedeathlycow/frostiful/mixins/food/compat/WarmFoodMixin.java index 7eba5050..3cb23381 100644 --- a/src/main/java/com/github/thedeathlycow/frostiful/mixins/food/compat/WarmFoodMixin.java +++ b/src/main/java/com/github/thedeathlycow/frostiful/mixins/food/compat/WarmFoodMixin.java @@ -1,19 +1,14 @@ package com.github.thedeathlycow.frostiful.mixins.food.compat; -import com.github.thedeathlycow.frostiful.Frostiful; -import com.github.thedeathlycow.frostiful.entity.effect.FStatusEffects; -import com.github.thedeathlycow.frostiful.tag.FItemTags; -import com.github.thedeathlycow.frostiful.util.TextStyles; +import com.github.thedeathlycow.frostiful.compat.FoodIntegration; import net.minecraft.client.item.TooltipContext; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.text.Text; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -24,8 +19,6 @@ @Mixin(Item.class) public abstract class WarmFoodMixin { - @Shadow public abstract boolean isFood(); - @Inject( method = "finishUsing", at = @At("HEAD") @@ -36,10 +29,7 @@ private void addWarmthToWarmFoods( LivingEntity user, CallbackInfoReturnable<ItemStack> cir ) { - if (this.isWarmingFood(stack)) { - int duration = Frostiful.getConfig().freezingConfig.getWarmFoodWarmthTime(); - user.addStatusEffect(new StatusEffectInstance(FStatusEffects.WARMTH, duration)); - } + FoodIntegration.onConsumeFood((Item) (Object) this, stack, user); } @Inject( @@ -53,17 +43,6 @@ private void addToolTip( TooltipContext context, CallbackInfo ci ) { - if (this.isWarmingFood(stack)) { - tooltip.add(Text.translatable("item.frostiful.warming.tooltip") - .setStyle(TextStyles.WARMING_TOOLTIP)); - } - } - - private boolean isWarmingFood(ItemStack stack) { - return this.isFood() && stack.isIn(FItemTags.WARM_FOODS); + FoodIntegration.appendWarmthTooltip((Item) (Object) this, stack, tooltip); } - - - - } diff --git a/src/main/java/com/github/thedeathlycow/frostiful/survival/AmbientTemperatureController.java b/src/main/java/com/github/thedeathlycow/frostiful/survival/AmbientTemperatureController.java index 7fe07d2d..14ce4800 100644 --- a/src/main/java/com/github/thedeathlycow/frostiful/survival/AmbientTemperatureController.java +++ b/src/main/java/com/github/thedeathlycow/frostiful/survival/AmbientTemperatureController.java @@ -2,6 +2,7 @@ import com.github.thedeathlycow.frostiful.Frostiful; import com.github.thedeathlycow.frostiful.compat.FrostifulIntegrations; +import com.github.thedeathlycow.frostiful.compat.SeasonsIntegration; import com.github.thedeathlycow.frostiful.config.FrostifulConfig; import com.github.thedeathlycow.frostiful.tag.FBlockTags; import com.github.thedeathlycow.thermoo.api.temperature.EnvironmentController; @@ -82,7 +83,7 @@ private int getNaturalWorldTemperatureChange(World world, BlockPos pos) { BiomeCategory category = BiomeCategory.fromBiome(biome); int temp = category.getTemperatureChange(world); if (temp < 0) { - if (FrostifulIntegrations.isWinter(world)) { + if (SeasonsIntegration.isWinter(world)) { temp += Frostiful.getConfig().environmentConfig.getWinterTemperatureShift(); } return temp; diff --git a/src/main/resources/frostiful.mixins.json b/src/main/resources/frostiful.mixins.json index 7e43673d..fccfb2be 100644 --- a/src/main/resources/frostiful.mixins.json +++ b/src/main/resources/frostiful.mixins.json @@ -11,6 +11,8 @@ "block.PowderSnowWalkableMixin", "block.SnowPackingMixin", "block.WindBlowoutMixin", + "compat.farmersdelight.present.HotCocoaItemMixin", + "compat.farmersrespite.present.DrinkableItemMixin", "entity.DamageSourcesMixin", "entity.EntityInvoker", "entity.FallingBlockEntityAccessor", From 53382e94741bfe21e50fa415d1f7fe3647a5eab0 Mon Sep 17 00:00:00 2001 From: TheDeathlyCow <thedeathlycow@gmail.com> Date: Mon, 11 Dec 2023 23:38:42 -1000 Subject: [PATCH 2/8] add spectrum beverages to list of warm foods --- README.md | 1 + .../data/frostiful/tags/items/warm_foods.json | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/README.md b/README.md index 6221bce9..df3a3fc8 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Basically everything about this mod is documented extensively on the [wiki](http * [Farmer's Respite](https://www.curseforge.com/minecraft/mc-mods/farmers-respite): Teas and warm foods provide the Warmth effect * [Festive Delight](https://www.curseforge.com/minecraft/mc-mods/festive-delight): Christmas Tea provides the Warmth effect * [Frozen Up](https://www.curseforge.com/minecraft/mc-mods/frozen-up): Truffle Hot Chocolate provides the Warmth effect +* [Spectrum](https://modrinth.com/mod/spectrum): Hot Chocolate, Demon Tea, Restoration Tea, and Glistering Jelly Tea provide the Warmth effect * [Fabric Seasons](https://modrinth.com/mod/fabric-seasons): Winters in snowy and freezing biomes are *even colder* than normal # Additional Credits diff --git a/src/main/resources/data/frostiful/tags/items/warm_foods.json b/src/main/resources/data/frostiful/tags/items/warm_foods.json index 764ac9e2..6aeb28ab 100644 --- a/src/main/resources/data/frostiful/tags/items/warm_foods.json +++ b/src/main/resources/data/frostiful/tags/items/warm_foods.json @@ -92,6 +92,22 @@ { "id": "festive_delight:christmas_tea", "required": false + }, + { + "id": "spectrum:hot_chocolate", + "required": false + }, + { + "id": "spectrum:demon_tea", + "required": false + }, + { + "id": "spectrum:restoration_tea", + "required": false + }, + { + "id": "spectrum:glistering_jelly_tea", + "required": false } ] } \ No newline at end of file From 6662c0523d887dc695d9bcb5f5c8d83ff7b80c6b Mon Sep 17 00:00:00 2001 From: TheDeathlyCow <thedeathlycow@gmail.com> Date: Mon, 11 Dec 2023 23:41:20 -1000 Subject: [PATCH 3/8] remove purulent tea and rose hip tea from warm foods --- .../data/frostiful/tags/items/warm_foods.json | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/main/resources/data/frostiful/tags/items/warm_foods.json b/src/main/resources/data/frostiful/tags/items/warm_foods.json index 6aeb28ab..6e5184fb 100644 --- a/src/main/resources/data/frostiful/tags/items/warm_foods.json +++ b/src/main/resources/data/frostiful/tags/items/warm_foods.json @@ -21,18 +21,10 @@ "id": "farmersrespite:black_tea", "required": false }, - { - "id": "farmersrespite:rose_hip_tea", - "required": false - }, { "id": "farmersrespite:dandelion_tea", "required": false }, - { - "id": "farmersrespite:purulent_tea", - "required": false - }, { "id": "farmersrespite:coffee", "required": false @@ -69,14 +61,6 @@ "id": "farmersrespite:strong_black_tea", "required": false }, - { - "id": "farmersrespite:strong_purulent_tea", - "required": false - }, - { - "id": "farmersrespite:strong_rose_hip_tea", - "required": false - }, { "id": "farmersrespite:strong_coffee", "required": false From f2b3564131f304aa585904d4b516b475cbaba6c3 Mon Sep 17 00:00:00 2001 From: TheDeathlyCow <thedeathlycow@gmail.com> Date: Mon, 11 Dec 2023 23:42:20 -1000 Subject: [PATCH 4/8] remove farmers respitem from mixin list --- src/main/resources/frostiful.mixins.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/resources/frostiful.mixins.json b/src/main/resources/frostiful.mixins.json index fccfb2be..9b4e83ec 100644 --- a/src/main/resources/frostiful.mixins.json +++ b/src/main/resources/frostiful.mixins.json @@ -12,7 +12,6 @@ "block.SnowPackingMixin", "block.WindBlowoutMixin", "compat.farmersdelight.present.HotCocoaItemMixin", - "compat.farmersrespite.present.DrinkableItemMixin", "entity.DamageSourcesMixin", "entity.EntityInvoker", "entity.FallingBlockEntityAccessor", @@ -62,5 +61,5 @@ ], "injectors": { "defaultRequire": 1 - } + } } From e0d7f917e1967fe6c87f371875f2b3e242d8070f Mon Sep 17 00:00:00 2001 From: TheDeathlyCow <thedeathlycow@gmail.com> Date: Tue, 12 Dec 2023 00:03:14 -1000 Subject: [PATCH 5/8] tag driven biome categories --- .../config/group/EnvironmentConfigGroup.java | 6 ++++++ .../frostiful/survival/BiomeCategory.java | 15 +++++++++++---- .../thedeathlycow/frostiful/tag/FBiomeTags.java | 4 ++++ .../resources/assets/frostiful/lang/en_us.json | 1 + .../tags/worldgen/biome/cold_biomes.json | 11 +++++++++++ .../tags/worldgen/biome/cool_biomes.json | 7 +++++++ .../frostiful/tags/worldgen/biome/dry_biomes.json | 6 ++++++ .../worldgen/biome/freezing_blacklist_biomes.json | 7 +++++++ 8 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/data/frostiful/tags/worldgen/biome/cold_biomes.json create mode 100644 src/main/resources/data/frostiful/tags/worldgen/biome/cool_biomes.json create mode 100644 src/main/resources/data/frostiful/tags/worldgen/biome/dry_biomes.json create mode 100644 src/main/resources/data/frostiful/tags/worldgen/biome/freezing_blacklist_biomes.json diff --git a/src/main/java/com/github/thedeathlycow/frostiful/config/group/EnvironmentConfigGroup.java b/src/main/java/com/github/thedeathlycow/frostiful/config/group/EnvironmentConfigGroup.java index 15922f85..1a1a305e 100644 --- a/src/main/java/com/github/thedeathlycow/frostiful/config/group/EnvironmentConfigGroup.java +++ b/src/main/java/com/github/thedeathlycow/frostiful/config/group/EnvironmentConfigGroup.java @@ -9,6 +9,8 @@ public class EnvironmentConfigGroup implements ConfigData { boolean doDryBiomeNightFreezing = true; + boolean enableDynamicTemperature = true; + int nightTemperatureShift = -1; int coldBiomeTemperatureChange = -1; int freezingBiomeTemperatureChange = -3; @@ -33,6 +35,10 @@ public boolean doDryBiomeNightFreezing() { return doDryBiomeNightFreezing; } + public boolean isEnableDynamicTemperature() { + return enableDynamicTemperature; + } + public int getNightTemperatureShift() { return nightTemperatureShift; } diff --git a/src/main/java/com/github/thedeathlycow/frostiful/survival/BiomeCategory.java b/src/main/java/com/github/thedeathlycow/frostiful/survival/BiomeCategory.java index de66c406..3a9dd1cb 100644 --- a/src/main/java/com/github/thedeathlycow/frostiful/survival/BiomeCategory.java +++ b/src/main/java/com/github/thedeathlycow/frostiful/survival/BiomeCategory.java @@ -30,14 +30,21 @@ public enum BiomeCategory { public static BiomeCategory fromBiome(RegistryEntry<Biome> biomeEntry) { Biome biome = biomeEntry.value(); - float temperature = biome.getTemperature(); - if (biomeEntry.isIn(FBiomeTags.FREEZING_BIOMES)) { + EnvironmentConfigGroup config = Frostiful.getConfig().environmentConfig; + + // +inf means only tags will be considered + float temperature = config.isEnableDynamicTemperature() ? biome.getTemperature() : Float.POSITIVE_INFINITY; + + if (biomeEntry.isIn(FBiomeTags.FREEZING_BLACKLIST_BIOMES)) { + return NORMAL; + } else if (biomeEntry.isIn(FBiomeTags.FREEZING_BIOMES)) { return FREEZING; - } else if (temperature <= SNOW_TEMPERATURE) { + } else if (temperature <= SNOW_TEMPERATURE || biomeEntry.isIn(FBiomeTags.COLD_BIOMES)) { return COLD; } else if ( temperature <= TAIGA_TEMPERATURE - || (!biome.hasPrecipitation() && Frostiful.getConfig().environmentConfig.doDryBiomeNightFreezing()) + || (biomeEntry.isIn(FBiomeTags.DRY_BIOMES) && config.doDryBiomeNightFreezing()) + || biomeEntry.isIn(FBiomeTags.COOL_BIOMES) ) { return COLD_AT_NIGHT; } else { diff --git a/src/main/java/com/github/thedeathlycow/frostiful/tag/FBiomeTags.java b/src/main/java/com/github/thedeathlycow/frostiful/tag/FBiomeTags.java index ac395e2c..a555f40b 100644 --- a/src/main/java/com/github/thedeathlycow/frostiful/tag/FBiomeTags.java +++ b/src/main/java/com/github/thedeathlycow/frostiful/tag/FBiomeTags.java @@ -11,6 +11,10 @@ public class FBiomeTags { public static final TagKey<Biome> FREEZING_WIND_ALWAYS_SPAWNS = FBiomeTags.register("freezing_wind_always_spawns"); public static final TagKey<Biome> FREEZING_WIND_SPAWNS_IN_STORMS = FBiomeTags.register("freezing_wind_spawns_in_storms"); public static final TagKey<Biome> FREEZING_BIOMES = FBiomeTags.register("freezing_biomes"); + public static final TagKey<Biome> COLD_BIOMES = FBiomeTags.register("cold_biomes"); + public static final TagKey<Biome> COOL_BIOMES = FBiomeTags.register("cool_biomes"); + public static final TagKey<Biome> DRY_BIOMES = FBiomeTags.register("dry_biomes"); + public static final TagKey<Biome> FREEZING_BLACKLIST_BIOMES = FBiomeTags.register("freezing_blacklist_biomes"); public static TagKey<Biome> register(String id) { return TagKey.of(RegistryKeys.BIOME, new Identifier(Frostiful.MODID, id)); diff --git a/src/main/resources/assets/frostiful/lang/en_us.json b/src/main/resources/assets/frostiful/lang/en_us.json index ab00d1e1..c013e8e3 100644 --- a/src/main/resources/assets/frostiful/lang/en_us.json +++ b/src/main/resources/assets/frostiful/lang/en_us.json @@ -278,6 +278,7 @@ "text.autoconfig.frostiful.option.environmentConfig": "Environment Config", "text.autoconfig.frostiful.option.environmentConfig.doDryBiomeNightFreezing": "Do dry biome night freezing", + "text.autoconfig.frostiful.option.environmentConfig.enableDynamicTemperature": "Enable dynamic temperature", "text.autoconfig.frostiful.option.environmentConfig.coldBiomeTemperatureChange": "Cold biome base temperature change (per tick)", "text.autoconfig.frostiful.option.environmentConfig.freezingBiomeTemperatureChange": "Freezing biome base temperature change (per tick)", "text.autoconfig.frostiful.option.environmentConfig.nightTemperatureShift": "Night time temperature shift", diff --git a/src/main/resources/data/frostiful/tags/worldgen/biome/cold_biomes.json b/src/main/resources/data/frostiful/tags/worldgen/biome/cold_biomes.json new file mode 100644 index 00000000..af079716 --- /dev/null +++ b/src/main/resources/data/frostiful/tags/worldgen/biome/cold_biomes.json @@ -0,0 +1,11 @@ +{ + "replace": false, + "values": [ + "#c:aquatic_icy", + "#c:snowy", + "#c:snowy_plains", + "minecraft:jagged_peaks", + "minecraft:grove", + "minecraft:snowy_slopes" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/frostiful/tags/worldgen/biome/cool_biomes.json b/src/main/resources/data/frostiful/tags/worldgen/biome/cool_biomes.json new file mode 100644 index 00000000..8f5bb545 --- /dev/null +++ b/src/main/resources/data/frostiful/tags/worldgen/biome/cool_biomes.json @@ -0,0 +1,7 @@ +{ + "replace": false, + "values": [ + "#c:taiga", + "#c:climate_cold" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/frostiful/tags/worldgen/biome/dry_biomes.json b/src/main/resources/data/frostiful/tags/worldgen/biome/dry_biomes.json new file mode 100644 index 00000000..9ec09d9c --- /dev/null +++ b/src/main/resources/data/frostiful/tags/worldgen/biome/dry_biomes.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "#c:climate_dry" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/frostiful/tags/worldgen/biome/freezing_blacklist_biomes.json b/src/main/resources/data/frostiful/tags/worldgen/biome/freezing_blacklist_biomes.json new file mode 100644 index 00000000..80686249 --- /dev/null +++ b/src/main/resources/data/frostiful/tags/worldgen/biome/freezing_blacklist_biomes.json @@ -0,0 +1,7 @@ +{ + "replace": false, + "values": [ + "#c:in_nether", + "#c:in_the_end" + ] +} \ No newline at end of file From 9484542266b0d3b19f3fd6a90ea9ff3b7599ac1f Mon Sep 17 00:00:00 2001 From: TheDeathlyCow <thedeathlycow@gmail.com> Date: Tue, 12 Dec 2023 02:16:34 -1000 Subject: [PATCH 6/8] improved seasons integration --- gradle.properties | 2 +- .../frostiful/compat/AdaptedSeason.java | 67 +++++++++++++++++++ .../compat/FrostifulIntegrations.java | 3 - .../frostiful/compat/SeasonsIntegration.java | 21 ------ .../config/group/EnvironmentConfigGroup.java | 5 ++ .../AmbientTemperatureController.java | 12 ++-- .../frostiful/survival/BiomeCategory.java | 31 ++++++--- .../assets/frostiful/lang/en_us.json | 3 +- .../tags/worldgen/biome/cold_biomes.json | 7 +- .../tags/worldgen/biome/cool_biomes.json | 3 +- 10 files changed, 104 insertions(+), 50 deletions(-) create mode 100644 src/main/java/com/github/thedeathlycow/frostiful/compat/AdaptedSeason.java delete mode 100644 src/main/java/com/github/thedeathlycow/frostiful/compat/SeasonsIntegration.java diff --git a/gradle.properties b/gradle.properties index daf8aabf..5f207fe6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ loader_version=0.14.21 # Mod Properties -mod_version = 1.0.0 +mod_version = 1.0.1 maven_group = com.github.thedeathlycow archives_base_name = frostiful diff --git a/src/main/java/com/github/thedeathlycow/frostiful/compat/AdaptedSeason.java b/src/main/java/com/github/thedeathlycow/frostiful/compat/AdaptedSeason.java new file mode 100644 index 00000000..0a283a42 --- /dev/null +++ b/src/main/java/com/github/thedeathlycow/frostiful/compat/AdaptedSeason.java @@ -0,0 +1,67 @@ +package com.github.thedeathlycow.frostiful.compat; + +import com.github.thedeathlycow.frostiful.survival.BiomeCategory; +import io.github.lucaargolo.seasons.FabricSeasons; +import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; + +/** + * Used as a mod-neutral adapter for different possible seasons from other mods. + */ +public enum AdaptedSeason { + + SPRING, + SUMMER, + AUTUMN, + WINTER, + WET_SEASON, + DRY_SEASON; + + + /** + * Gets the current season in the world. Returns null if no season mod is enabled. + * + * @param world The world to get the season for. + * @return Returns the current season. Returns null if no season mod is enabled. + */ + @Nullable + public static AdaptedSeason getCurrentSeason(World world) { + if (FrostifulIntegrations.isModLoaded(FrostifulIntegrations.FABRIC_SEASONS_ID)) { + return switch (FabricSeasons.getCurrentSeason(world)) { + case SUMMER -> AdaptedSeason.SUMMER; + case WINTER -> AdaptedSeason.WINTER; + case FALL -> AdaptedSeason.AUTUMN; + case SPRING -> AdaptedSeason.SPRING; + }; + } else { + return null; + } + } + + /** + * Adjusts biome categories for their season. + * + * @param season The current season + * @param normalCategory The normal category of the biome if no season mod was enabled. + * @return Returns the biome category, adjusted for the season. + */ + public static BiomeCategory getSeasonallyShiftedBiomeCategory( + @Nullable AdaptedSeason season, + BiomeCategory normalCategory + ) { + if (isSummer(season) && normalCategory == BiomeCategory.FREEZING) { + return BiomeCategory.COLD; + } + return normalCategory; + } + + /** + * Checks if the current season is one of the two possible summer seasons. + * + * @param season The current season + * @return Returns true if the season is {@link #SUMMER} or {@link #DRY_SEASON} + */ + public static boolean isSummer(@Nullable AdaptedSeason season) { + return season == SUMMER || season == DRY_SEASON; + } +} diff --git a/src/main/java/com/github/thedeathlycow/frostiful/compat/FrostifulIntegrations.java b/src/main/java/com/github/thedeathlycow/frostiful/compat/FrostifulIntegrations.java index 8134a8bb..30408631 100644 --- a/src/main/java/com/github/thedeathlycow/frostiful/compat/FrostifulIntegrations.java +++ b/src/main/java/com/github/thedeathlycow/frostiful/compat/FrostifulIntegrations.java @@ -1,9 +1,6 @@ package com.github.thedeathlycow.frostiful.compat; -import io.github.lucaargolo.seasons.FabricSeasons; -import io.github.lucaargolo.seasons.utils.Season; import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.world.World; public class FrostifulIntegrations { diff --git a/src/main/java/com/github/thedeathlycow/frostiful/compat/SeasonsIntegration.java b/src/main/java/com/github/thedeathlycow/frostiful/compat/SeasonsIntegration.java deleted file mode 100644 index cdc9aebc..00000000 --- a/src/main/java/com/github/thedeathlycow/frostiful/compat/SeasonsIntegration.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.github.thedeathlycow.frostiful.compat; - -import io.github.lucaargolo.seasons.FabricSeasons; -import io.github.lucaargolo.seasons.utils.Season; -import net.minecraft.world.World; - -public class SeasonsIntegration { - - public static boolean isWinter(World world) { - if (FrostifulIntegrations.isModLoaded(FrostifulIntegrations.FABRIC_SEASONS_ID)) { - return Season.WINTER == FabricSeasons.getCurrentSeason(world); - } else { - return false; - } - } - - private SeasonsIntegration() { - - } - -} diff --git a/src/main/java/com/github/thedeathlycow/frostiful/config/group/EnvironmentConfigGroup.java b/src/main/java/com/github/thedeathlycow/frostiful/config/group/EnvironmentConfigGroup.java index 1a1a305e..0e12c911 100644 --- a/src/main/java/com/github/thedeathlycow/frostiful/config/group/EnvironmentConfigGroup.java +++ b/src/main/java/com/github/thedeathlycow/frostiful/config/group/EnvironmentConfigGroup.java @@ -30,6 +30,7 @@ public class EnvironmentConfigGroup implements ConfigData { int ultrawarmWarmRate = 15; int winterTemperatureShift = -1; + boolean isNightColdInSummer = false; public boolean doDryBiomeNightFreezing() { return doDryBiomeNightFreezing; @@ -90,4 +91,8 @@ public int getUltrawarmWarmRate() { public int getWinterTemperatureShift() { return winterTemperatureShift; } + + public boolean isNightColdInSummer() { + return isNightColdInSummer; + } } diff --git a/src/main/java/com/github/thedeathlycow/frostiful/survival/AmbientTemperatureController.java b/src/main/java/com/github/thedeathlycow/frostiful/survival/AmbientTemperatureController.java index 14ce4800..22e843c5 100644 --- a/src/main/java/com/github/thedeathlycow/frostiful/survival/AmbientTemperatureController.java +++ b/src/main/java/com/github/thedeathlycow/frostiful/survival/AmbientTemperatureController.java @@ -1,8 +1,7 @@ package com.github.thedeathlycow.frostiful.survival; import com.github.thedeathlycow.frostiful.Frostiful; -import com.github.thedeathlycow.frostiful.compat.FrostifulIntegrations; -import com.github.thedeathlycow.frostiful.compat.SeasonsIntegration; +import com.github.thedeathlycow.frostiful.compat.AdaptedSeason; import com.github.thedeathlycow.frostiful.config.FrostifulConfig; import com.github.thedeathlycow.frostiful.tag.FBlockTags; import com.github.thedeathlycow.thermoo.api.temperature.EnvironmentController; @@ -15,6 +14,7 @@ import net.minecraft.world.LightType; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; +import org.jetbrains.annotations.Nullable; public class AmbientTemperatureController extends EnvironmentControllerDecorator { @@ -80,12 +80,10 @@ public boolean isAreaHeated(World world, BlockPos pos) { private int getNaturalWorldTemperatureChange(World world, BlockPos pos) { RegistryEntry<Biome> biome = world.getBiome(pos); - BiomeCategory category = BiomeCategory.fromBiome(biome); - int temp = category.getTemperatureChange(world); + @Nullable AdaptedSeason season = AdaptedSeason.getCurrentSeason(world); + BiomeCategory category = BiomeCategory.fromBiome(biome, season); + int temp = category.getTemperatureChange(world, season); if (temp < 0) { - if (SeasonsIntegration.isWinter(world)) { - temp += Frostiful.getConfig().environmentConfig.getWinterTemperatureShift(); - } return temp; } diff --git a/src/main/java/com/github/thedeathlycow/frostiful/survival/BiomeCategory.java b/src/main/java/com/github/thedeathlycow/frostiful/survival/BiomeCategory.java index 3a9dd1cb..71b4101f 100644 --- a/src/main/java/com/github/thedeathlycow/frostiful/survival/BiomeCategory.java +++ b/src/main/java/com/github/thedeathlycow/frostiful/survival/BiomeCategory.java @@ -1,11 +1,13 @@ package com.github.thedeathlycow.frostiful.survival; import com.github.thedeathlycow.frostiful.Frostiful; +import com.github.thedeathlycow.frostiful.compat.AdaptedSeason; import com.github.thedeathlycow.frostiful.config.group.EnvironmentConfigGroup; import com.github.thedeathlycow.frostiful.tag.FBiomeTags; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; +import org.jetbrains.annotations.Nullable; import java.util.function.ToIntFunction; @@ -17,7 +19,7 @@ public enum BiomeCategory { FREEZING(EnvironmentConfigGroup::getFreezingBiomeTemperatureChange, true); private static final float SNOW_TEMPERATURE = 0.15f; - private static final float TAIGA_TEMPERATURE = 0.25f; + private static final float TAIGA_TEMPERATURE = 0.3f; private final ToIntFunction<EnvironmentConfigGroup> temperatureChange; private final boolean coldAtNight; @@ -27,7 +29,7 @@ public enum BiomeCategory { this.coldAtNight = coldAtNight; } - public static BiomeCategory fromBiome(RegistryEntry<Biome> biomeEntry) { + public static BiomeCategory fromBiome(RegistryEntry<Biome> biomeEntry, @Nullable AdaptedSeason season) { Biome biome = biomeEntry.value(); EnvironmentConfigGroup config = Frostiful.getConfig().environmentConfig; @@ -35,29 +37,40 @@ public static BiomeCategory fromBiome(RegistryEntry<Biome> biomeEntry) { // +inf means only tags will be considered float temperature = config.isEnableDynamicTemperature() ? biome.getTemperature() : Float.POSITIVE_INFINITY; + BiomeCategory category; + if (biomeEntry.isIn(FBiomeTags.FREEZING_BLACKLIST_BIOMES)) { - return NORMAL; + category = NORMAL; } else if (biomeEntry.isIn(FBiomeTags.FREEZING_BIOMES)) { - return FREEZING; + category = FREEZING; } else if (temperature <= SNOW_TEMPERATURE || biomeEntry.isIn(FBiomeTags.COLD_BIOMES)) { - return COLD; + category = COLD; } else if ( temperature <= TAIGA_TEMPERATURE || (biomeEntry.isIn(FBiomeTags.DRY_BIOMES) && config.doDryBiomeNightFreezing()) || biomeEntry.isIn(FBiomeTags.COOL_BIOMES) ) { - return COLD_AT_NIGHT; + category = COLD_AT_NIGHT; } else { - return NORMAL; + category = NORMAL; } + + return AdaptedSeason.getSeasonallyShiftedBiomeCategory(season, category); } - public int getTemperatureChange(World world) { + public int getTemperatureChange(World world, @Nullable AdaptedSeason season) { EnvironmentConfigGroup config = Frostiful.getConfig().environmentConfig; int change = this.temperatureChange.applyAsInt(config); - if (coldAtNight && world.isNight()) { + + if (coldAtNight && world.isNight() && (!AdaptedSeason.isSummer(season) || config.isNightColdInSummer())) { change += config.getNightTemperatureShift(); } + + if (change < 0 && season == AdaptedSeason.WINTER) { + change += config.getWinterTemperatureShift(); + } + + return change; } } diff --git a/src/main/resources/assets/frostiful/lang/en_us.json b/src/main/resources/assets/frostiful/lang/en_us.json index c013e8e3..8edeffca 100644 --- a/src/main/resources/assets/frostiful/lang/en_us.json +++ b/src/main/resources/assets/frostiful/lang/en_us.json @@ -291,5 +291,6 @@ "text.autoconfig.frostiful.option.environmentConfig.warmthPerLightLevel": "Warmth per light level", "text.autoconfig.frostiful.option.environmentConfig.minLightForWarmth": "Minimum block light level for warmth", "text.autoconfig.frostiful.option.environmentConfig.ultrawarmWarmRate": "Ultrawarm dimension warm rate", - "text.autoconfig.frostiful.option.environmentConfig.winterTemperatureShift": "Winter temperature shift (requires Fabric Seasons)" + "text.autoconfig.frostiful.option.environmentConfig.winterTemperatureShift": "Winter temperature shift (requires Fabric Seasons)", + "text.autoconfig.frostiful.option.environmentConfig.isNightColdInSummer": "Is night cold in summer (requires Fabric Seasons)" } \ No newline at end of file diff --git a/src/main/resources/data/frostiful/tags/worldgen/biome/cold_biomes.json b/src/main/resources/data/frostiful/tags/worldgen/biome/cold_biomes.json index af079716..20b14abe 100644 --- a/src/main/resources/data/frostiful/tags/worldgen/biome/cold_biomes.json +++ b/src/main/resources/data/frostiful/tags/worldgen/biome/cold_biomes.json @@ -1,11 +1,6 @@ { "replace": false, "values": [ - "#c:aquatic_icy", - "#c:snowy", - "#c:snowy_plains", - "minecraft:jagged_peaks", - "minecraft:grove", - "minecraft:snowy_slopes" + ] } \ No newline at end of file diff --git a/src/main/resources/data/frostiful/tags/worldgen/biome/cool_biomes.json b/src/main/resources/data/frostiful/tags/worldgen/biome/cool_biomes.json index 8f5bb545..20b14abe 100644 --- a/src/main/resources/data/frostiful/tags/worldgen/biome/cool_biomes.json +++ b/src/main/resources/data/frostiful/tags/worldgen/biome/cool_biomes.json @@ -1,7 +1,6 @@ { "replace": false, "values": [ - "#c:taiga", - "#c:climate_cold" + ] } \ No newline at end of file From da3efa7bdd6277a4ba64583cbd381f038aee6d15 Mon Sep 17 00:00:00 2001 From: TheDeathlyCow <thedeathlycow@gmail.com> Date: Tue, 12 Dec 2023 02:28:28 -1000 Subject: [PATCH 7/8] update readme --- README.md | 2 +- .../frostiful/config/group/EnvironmentConfigGroup.java | 6 ------ .../thedeathlycow/frostiful/survival/BiomeCategory.java | 2 +- src/main/resources/assets/frostiful/lang/en_us.json | 1 - 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index df3a3fc8..791d58c4 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Basically everything about this mod is documented extensively on the [wiki](http * [Festive Delight](https://www.curseforge.com/minecraft/mc-mods/festive-delight): Christmas Tea provides the Warmth effect * [Frozen Up](https://www.curseforge.com/minecraft/mc-mods/frozen-up): Truffle Hot Chocolate provides the Warmth effect * [Spectrum](https://modrinth.com/mod/spectrum): Hot Chocolate, Demon Tea, Restoration Tea, and Glistering Jelly Tea provide the Warmth effect -* [Fabric Seasons](https://modrinth.com/mod/fabric-seasons): Winters in snowy and freezing biomes are *even colder* than normal +* [Fabric Seasons](https://modrinth.com/mod/fabric-seasons): Winters in snowy and freezing biomes are *even colder* than normal. Freezing biomes are slightly in Summer. # Additional Credits diff --git a/src/main/java/com/github/thedeathlycow/frostiful/config/group/EnvironmentConfigGroup.java b/src/main/java/com/github/thedeathlycow/frostiful/config/group/EnvironmentConfigGroup.java index 0e12c911..d5e06f65 100644 --- a/src/main/java/com/github/thedeathlycow/frostiful/config/group/EnvironmentConfigGroup.java +++ b/src/main/java/com/github/thedeathlycow/frostiful/config/group/EnvironmentConfigGroup.java @@ -9,8 +9,6 @@ public class EnvironmentConfigGroup implements ConfigData { boolean doDryBiomeNightFreezing = true; - boolean enableDynamicTemperature = true; - int nightTemperatureShift = -1; int coldBiomeTemperatureChange = -1; int freezingBiomeTemperatureChange = -3; @@ -36,10 +34,6 @@ public boolean doDryBiomeNightFreezing() { return doDryBiomeNightFreezing; } - public boolean isEnableDynamicTemperature() { - return enableDynamicTemperature; - } - public int getNightTemperatureShift() { return nightTemperatureShift; } diff --git a/src/main/java/com/github/thedeathlycow/frostiful/survival/BiomeCategory.java b/src/main/java/com/github/thedeathlycow/frostiful/survival/BiomeCategory.java index 71b4101f..26a24389 100644 --- a/src/main/java/com/github/thedeathlycow/frostiful/survival/BiomeCategory.java +++ b/src/main/java/com/github/thedeathlycow/frostiful/survival/BiomeCategory.java @@ -35,7 +35,7 @@ public static BiomeCategory fromBiome(RegistryEntry<Biome> biomeEntry, @Nullable EnvironmentConfigGroup config = Frostiful.getConfig().environmentConfig; // +inf means only tags will be considered - float temperature = config.isEnableDynamicTemperature() ? biome.getTemperature() : Float.POSITIVE_INFINITY; + float temperature = biome.getTemperature(); BiomeCategory category; diff --git a/src/main/resources/assets/frostiful/lang/en_us.json b/src/main/resources/assets/frostiful/lang/en_us.json index 8edeffca..2d6012a8 100644 --- a/src/main/resources/assets/frostiful/lang/en_us.json +++ b/src/main/resources/assets/frostiful/lang/en_us.json @@ -278,7 +278,6 @@ "text.autoconfig.frostiful.option.environmentConfig": "Environment Config", "text.autoconfig.frostiful.option.environmentConfig.doDryBiomeNightFreezing": "Do dry biome night freezing", - "text.autoconfig.frostiful.option.environmentConfig.enableDynamicTemperature": "Enable dynamic temperature", "text.autoconfig.frostiful.option.environmentConfig.coldBiomeTemperatureChange": "Cold biome base temperature change (per tick)", "text.autoconfig.frostiful.option.environmentConfig.freezingBiomeTemperatureChange": "Freezing biome base temperature change (per tick)", "text.autoconfig.frostiful.option.environmentConfig.nightTemperatureShift": "Night time temperature shift", From b1482682f3c912054bf75a1040d385daea69e4d9 Mon Sep 17 00:00:00 2001 From: TheDeathlyCow <thedeathlycow@gmail.com> Date: Tue, 12 Dec 2023 02:32:13 -1000 Subject: [PATCH 8/8] fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 791d58c4..aa565c38 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Basically everything about this mod is documented extensively on the [wiki](http * [Festive Delight](https://www.curseforge.com/minecraft/mc-mods/festive-delight): Christmas Tea provides the Warmth effect * [Frozen Up](https://www.curseforge.com/minecraft/mc-mods/frozen-up): Truffle Hot Chocolate provides the Warmth effect * [Spectrum](https://modrinth.com/mod/spectrum): Hot Chocolate, Demon Tea, Restoration Tea, and Glistering Jelly Tea provide the Warmth effect -* [Fabric Seasons](https://modrinth.com/mod/fabric-seasons): Winters in snowy and freezing biomes are *even colder* than normal. Freezing biomes are slightly in Summer. +* [Fabric Seasons](https://modrinth.com/mod/fabric-seasons): Winters in snowy and freezing biomes are *even colder* than normal. Freezing biomes are slightly warmer in Summer. # Additional Credits