diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e4bd99..40b3fd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.1.4] + +### Added +* Added new config setting `replaceColdBiomesOnly`, default true + * When true, only cold biomes near spawn will be replaced (as before), when false _all_ biomes will be replaced + * Other changes: `replaceColdBiomeId` is now `replaceBiomeId`, and `replaceColdBiomesNearSpawn` is now `replaceBiomesNearSpawn` + ## [1.1.3] ### Added diff --git a/gradle.properties b/gradle.properties index c4f24c3..0ac019c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ minecraft_version=1.19.2 forge_version=1.19.2-43.2.4 # Mod Properties -mod_version=1.1.3 +mod_version=1.1.4 maven_group=dev.ftb.mods archives_base_name=ftb-team-dimensions mod_id=ftbteamdimensions diff --git a/src/main/java/dev/ftb/mods/ftbteamdimensions/FTBDimensionsConfig.java b/src/main/java/dev/ftb/mods/ftbteamdimensions/FTBDimensionsConfig.java index 33acd16..9bedec1 100644 --- a/src/main/java/dev/ftb/mods/ftbteamdimensions/FTBDimensionsConfig.java +++ b/src/main/java/dev/ftb/mods/ftbteamdimensions/FTBDimensionsConfig.java @@ -39,10 +39,11 @@ public static class CategoryCommonGeneral { public final ForgeConfigSpec.EnumValue chunkGenerator; public final ForgeConfigSpec.BooleanValue teamSpecificNetherEntryPoint; public final ForgeConfigSpec.BooleanValue placeEntitiesInStartStructure; - public final ForgeConfigSpec.IntValue replaceColdBiomesNearSpawn; + public final ForgeConfigSpec.BooleanValue replaceColdBiomesOnly; + public final ForgeConfigSpec.IntValue replaceBiomesNearSpawn; public final ForgeConfigSpec.EnumValue lobbyGameMode; public final ForgeConfigSpec.BooleanValue allowLobbyDamages; - public final ForgeConfigSpec.ConfigValue replaceColdBiomeId; + public final ForgeConfigSpec.ConfigValue replaceBiomeId; public CategoryCommonGeneral() { COMMON_BUILDER.push("general"); @@ -107,13 +108,17 @@ public CategoryCommonGeneral() { .comment("If true, then any entities saved in the starting structure NBT will be included when the structure is generated") .define("placeEntitiesInStartStructure", true); - this.replaceColdBiomesNearSpawn = COMMON_BUILDER - .comment("If > 0, any chunk closer than this distance from spawn, with a cold biome (i.e. water can freeze) in its X/Z midpoint, will have its biome replaced with the biome defined in 'replaceColdBiomeId'. Set to 0 to disable all replacement.") - .defineInRange("replaceColdBiomesNearSpawn", 64, 0, Integer.MAX_VALUE); + this.replaceBiomesNearSpawn = COMMON_BUILDER + .comment("If > 0, any chunk closer than this distance from spawn will have its biome replaced with the biome defined in 'replaceBiomeId'. Set to 0 to disable all replacement.") + .defineInRange("replaceColdBiomesNearSpawn", 0, 0, Integer.MAX_VALUE); - this.replaceColdBiomeId = COMMON_BUILDER - .comment("Id of the biome which will be used to replace cold biomes near spawn (see 'replaceColdBiomesNearSpawn')") - .define("replaceColdBiomeId", "minecraft:plains"); + this.replaceColdBiomesOnly = COMMON_BUILDER + .comment("If true (and 'replaceBiomesNearSpawn' > 0), only cold biomes near spawn (i.e. water can freeze) will be replaced with the biome defined in 'replaceBiomeId'.") + .define("replaceColdBiomesOnly", true); + + this.replaceBiomeId = COMMON_BUILDER + .comment("Id of the biome which will be used to replace biomes near spawn (see 'replaceBiomesNearSpawn')") + .define("replaceBiomeId", "minecraft:plains"); COMMON_BUILDER.pop(); } diff --git a/src/main/java/dev/ftb/mods/ftbteamdimensions/FTBTeamDimensions.java b/src/main/java/dev/ftb/mods/ftbteamdimensions/FTBTeamDimensions.java index 601b276..eae0a21 100644 --- a/src/main/java/dev/ftb/mods/ftbteamdimensions/FTBTeamDimensions.java +++ b/src/main/java/dev/ftb/mods/ftbteamdimensions/FTBTeamDimensions.java @@ -137,26 +137,31 @@ private void onLevelLoad(LevelEvent.Load event) { } private void onChunkLoad(ChunkEvent.Load event) { - if (event.getLevel() instanceof ServerLevel level && DimensionUtils.isTeamDimension(level) && FTBDimensionsConfig.COMMON_GENERAL.replaceColdBiomesNearSpawn.get() > 0) { + FTBDimensionsConfig.CategoryCommonGeneral general = FTBDimensionsConfig.COMMON_GENERAL; + if (event.getLevel() instanceof ServerLevel level && DimensionUtils.isTeamDimension(level) && general.replaceBiomesNearSpawn.get() > 0) { BlockPos spawnPos = DimensionStorage.get(level.getServer()).getDimensionSpawnLocation(level.dimension().location()); if (spawnPos != null) { ChunkPos chunkPos = event.getChunk().getPos(); BlockPos pos1 = chunkPos.getMiddleBlockPosition(spawnPos.getY()); - int threshold = (int) Math.pow(FTBDimensionsConfig.COMMON_GENERAL.replaceColdBiomesNearSpawn.get(), 2); - if (pos1.distSqr(spawnPos) < threshold && level.getBiome(pos1).value().coldEnoughToSnow(pos1)) { - ResourceKey biomeKey = ResourceKey.create(Registry.BIOME_REGISTRY, - new ResourceLocation(FTBDimensionsConfig.COMMON_GENERAL.replaceColdBiomeId.get())); - Holder replacement = level.registryAccess().registry(Registry.BIOME_REGISTRY).orElseThrow().getHolderOrThrow(biomeKey); - BlockPos from = new BlockPos(chunkPos.getMinBlockX(), level.getMinBuildHeight(), chunkPos.getMinBlockZ()); - BlockPos to = new BlockPos(chunkPos.getMaxBlockX(), level.getMaxBuildHeight(), chunkPos.getMaxBlockZ()); - level.getServer().executeIfPossible(() -> - BiomeReplacementUtils.replaceBiome(level, event.getChunk(), from , to, replacement) - ); + int threshold = (int) Math.pow(general.replaceBiomesNearSpawn.get(), 2); + if (pos1.distSqr(spawnPos) < threshold && (!general.replaceColdBiomesOnly.get() || level.getBiome(pos1).value().coldEnoughToSnow(pos1))) { + doReplacement(event, level, chunkPos); } } } } + private static void doReplacement(ChunkEvent.Load event, ServerLevel level, ChunkPos chunkPos) { + ResourceKey biomeKey = ResourceKey.create(Registry.BIOME_REGISTRY, + new ResourceLocation(FTBDimensionsConfig.COMMON_GENERAL.replaceBiomeId.get())); + Holder replacement = level.registryAccess().registry(Registry.BIOME_REGISTRY).orElseThrow().getHolderOrThrow(biomeKey); + BlockPos from = new BlockPos(chunkPos.getMinBlockX(), level.getMinBuildHeight(), chunkPos.getMinBlockZ()); + BlockPos to = new BlockPos(chunkPos.getMaxBlockX(), level.getMaxBuildHeight(), chunkPos.getMaxBlockZ()); + level.getServer().executeIfPossible(() -> + BiomeReplacementUtils.replaceBiome(level, event.getChunk(), from , to, replacement) + ); + } + private void onSleepFinished(final SleepFinishedTimeEvent event) { if (event.getLevel() instanceof ServerLevel level && level.dimension().location().getNamespace().equals(MOD_ID)) { // player has slept in a dynamic dimension