-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compatibility for Modern Beta on Fabric/Quilt.
- Modern Beta biomes can now be replaced (direct replacement only)
- Loading branch information
1 parent
75acaa5
commit bcfef15
Showing
14 changed files
with
404 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
common/src/main/java/com/terraformersmc/biolith/api/compat/BiolithCompats.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.terraformersmc.biolith.api.compat; | ||
|
||
import com.terraformersmc.biolith.impl.compat.BiolithCompat; | ||
|
||
/** | ||
* <p> | ||
* BiolithCompats can be used to check whether Biolith has enabled a compatibility mode. | ||
* </p> | ||
* <p> | ||
* For example: | ||
* </p> | ||
* <pre>{@code | ||
* if (BiolithCompats.isCompatEnabled(BiolithCompats.MODERN_BETA)) { | ||
* BiomePlacement.replaceOverworld(ModernBetaBiomeKeys.BETA_FOREST, FOREST_A, 0.4D); | ||
* BiomePlacement.replaceOverworld(ModernBetaBiomeKeys.BETA_FOREST, FOREST_B, 0.4D); | ||
* } | ||
* }</pre> | ||
*/ | ||
@SuppressWarnings("unused") | ||
public enum BiolithCompats { | ||
MODERN_BETA, | ||
TERRABLENDER, | ||
VANILLA; | ||
|
||
public static boolean isCompatEnabled(BiolithCompats compat) { | ||
return switch (compat) { | ||
case MODERN_BETA -> BiolithCompat.COMPAT_MODERN_BETA; | ||
case TERRABLENDER -> BiolithCompat.COMPAT_TERRABLENDER; | ||
case VANILLA -> true; | ||
}; | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
common/src/main/java/com/terraformersmc/biolith/api/compat/ModernBetaBiomeKeys.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.terraformersmc.biolith.api.compat; | ||
|
||
import net.minecraft.registry.RegistryKey; | ||
import net.minecraft.registry.RegistryKeys; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.world.biome.Biome; | ||
|
||
/** | ||
* <p> | ||
* Copies of the registry keys of Modern Beta's biomes. These keys can be used to | ||
* target Modern Beta biomes with Biolith's replacement noise, without depending on | ||
* Modern Beta when building. Modern Beta biomes can be replaced, but they cannot | ||
* be placed or targeted with sub-biome matchers. | ||
* </p> | ||
* <p> | ||
* For example, to replace 20% of "Beta Forest" with "Forest A" and 20% with "Forest B": | ||
* </p> | ||
* <pre>{@code | ||
* if (BiolithCompats.isCompatEnabled(BiolithCompats.MODERN_BETA)) { | ||
* BiomePlacement.replaceOverworld(ModernBetaBiomeKeys.BETA_FOREST, FOREST_A, 0.4D); | ||
* BiomePlacement.replaceOverworld(ModernBetaBiomeKeys.BETA_FOREST, FOREST_B, 0.4D); | ||
* } | ||
* }</pre> | ||
*/ | ||
@SuppressWarnings("unused") | ||
public class ModernBetaBiomeKeys { | ||
public static final RegistryKey<Biome> BETA_FOREST = keyOf("beta_forest"); | ||
public static final RegistryKey<Biome> BETA_SHRUBLAND = keyOf("beta_shrubland"); | ||
public static final RegistryKey<Biome> BETA_DESERT = keyOf("beta_desert"); | ||
public static final RegistryKey<Biome> BETA_SAVANNA = keyOf("beta_savanna"); | ||
public static final RegistryKey<Biome> BETA_PLAINS = keyOf("beta_plains"); | ||
public static final RegistryKey<Biome> BETA_SEASONAL_FOREST = keyOf("beta_seasonal_forest"); | ||
public static final RegistryKey<Biome> BETA_RAINFOREST = keyOf("beta_rainforest"); | ||
public static final RegistryKey<Biome> BETA_SWAMPLAND = keyOf("beta_swampland"); | ||
public static final RegistryKey<Biome> BETA_TAIGA = keyOf("beta_taiga"); | ||
public static final RegistryKey<Biome> BETA_TUNDRA = keyOf("beta_tundra"); | ||
public static final RegistryKey<Biome> BETA_ICE_DESERT = keyOf("beta_ice_desert"); | ||
|
||
public static final RegistryKey<Biome> BETA_OCEAN = keyOf("beta_ocean"); | ||
public static final RegistryKey<Biome> BETA_LUKEWARM_OCEAN = keyOf("beta_lukewarm_ocean"); | ||
public static final RegistryKey<Biome> BETA_WARM_OCEAN = keyOf("beta_warm_ocean"); | ||
public static final RegistryKey<Biome> BETA_COLD_OCEAN = keyOf("beta_cold_ocean"); | ||
public static final RegistryKey<Biome> BETA_FROZEN_OCEAN = keyOf("beta_frozen_ocean"); | ||
|
||
public static final RegistryKey<Biome> BETA_SKY = keyOf("beta_sky"); | ||
|
||
public static final RegistryKey<Biome> PE_FOREST = keyOf("pe_forest"); | ||
public static final RegistryKey<Biome> PE_SHRUBLAND = keyOf("pe_shrubland"); | ||
public static final RegistryKey<Biome> PE_DESERT = keyOf("pe_desert"); | ||
public static final RegistryKey<Biome> PE_SAVANNA = keyOf("pe_savanna"); | ||
public static final RegistryKey<Biome> PE_PLAINS = keyOf("pe_plains"); | ||
public static final RegistryKey<Biome> PE_SEASONAL_FOREST = keyOf("pe_seasonal_forest"); | ||
public static final RegistryKey<Biome> PE_RAINFOREST = keyOf("pe_rainforest"); | ||
public static final RegistryKey<Biome> PE_SWAMPLAND = keyOf("pe_swampland"); | ||
public static final RegistryKey<Biome> PE_TAIGA = keyOf("pe_taiga"); | ||
public static final RegistryKey<Biome> PE_TUNDRA = keyOf("pe_tundra"); | ||
public static final RegistryKey<Biome> PE_ICE_DESERT = keyOf("pe_ice_desert"); | ||
|
||
public static final RegistryKey<Biome> PE_OCEAN = keyOf("pe_ocean"); | ||
public static final RegistryKey<Biome> PE_LUKEWARM_OCEAN = keyOf("pe_lukewarm_ocean"); | ||
public static final RegistryKey<Biome> PE_WARM_OCEAN = keyOf("pe_warm_ocean"); | ||
public static final RegistryKey<Biome> PE_COLD_OCEAN = keyOf("pe_cold_ocean"); | ||
public static final RegistryKey<Biome> PE_FROZEN_OCEAN = keyOf("pe_frozen_ocean"); | ||
|
||
public static final RegistryKey<Biome> ALPHA = keyOf("alpha"); | ||
public static final RegistryKey<Biome> ALPHA_WINTER = keyOf("alpha_winter"); | ||
|
||
public static final RegistryKey<Biome> INFDEV_611 = keyOf("infdev_611"); | ||
public static final RegistryKey<Biome> INFDEV_420 = keyOf("infdev_420"); | ||
public static final RegistryKey<Biome> INFDEV_415 = keyOf("infdev_415"); | ||
public static final RegistryKey<Biome> INFDEV_227 = keyOf("infdev_227"); | ||
|
||
public static final RegistryKey<Biome> INDEV_NORMAL = keyOf("indev_normal"); | ||
public static final RegistryKey<Biome> INDEV_HELL = keyOf("indev_hell"); | ||
public static final RegistryKey<Biome> INDEV_PARADISE = keyOf("indev_paradise"); | ||
public static final RegistryKey<Biome> INDEV_WOODS = keyOf("indev_woods"); | ||
|
||
private static RegistryKey<Biome> keyOf(String name) { | ||
return RegistryKey.of(RegistryKeys.BIOME, Identifier.of("modern_beta", name)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
fabric/src/main/java/com/terraformersmc/biolith/impl/compat/ModernBetaCompatFabric.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.terraformersmc.biolith.impl.compat; | ||
|
||
import com.mojang.brigadier.context.CommandContext; | ||
import com.terraformersmc.biolith.impl.Biolith; | ||
import com.terraformersmc.biolith.impl.biome.BiolithFittestNodes; | ||
import com.terraformersmc.biolith.impl.biome.BiomeCoordinator; | ||
import com.terraformersmc.biolith.impl.biome.DimensionBiomePlacement; | ||
import com.terraformersmc.biolith.impl.commands.BiolithDescribeCommand; | ||
import mod.bespectacled.modernbeta.world.biome.ModernBetaBiomeSource; | ||
import net.minecraft.registry.entry.RegistryEntry; | ||
import net.minecraft.server.command.ServerCommandSource; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Formatting; | ||
import net.minecraft.world.biome.Biome; | ||
import net.minecraft.world.biome.source.BiomeSource; | ||
import net.minecraft.world.biome.source.util.MultiNoiseUtil; | ||
|
||
import static com.terraformersmc.biolith.impl.commands.BiolithDescribeCommand.textFromBiome; | ||
|
||
public class ModernBetaCompatFabric { | ||
public static int describe(CommandContext<ServerCommandSource> context, int biomeX, int biomeY, int biomeZ, ServerWorld world, BiomeSource biomeSource, MultiNoiseUtil.Entries<RegistryEntry<Biome>> biomeEntries, MultiNoiseUtil.MultiNoiseSampler noise) { | ||
if (!(biomeSource instanceof ModernBetaBiomeSource)) { | ||
return 0; | ||
} | ||
|
||
RegistryEntry<Biome> original = ((ModernBetaBiomeSource) biomeSource).getBiomeProvider().getBiome(biomeX, biomeY, biomeZ); | ||
BiolithFittestNodes<RegistryEntry<Biome>> fittestNodes = new BiolithFittestNodes<>(new MultiNoiseUtil.SearchTree.TreeLeafNode<>(DimensionBiomePlacement.OUT_OF_RANGE, original), 0, null, Integer.MAX_VALUE); | ||
|
||
double replacementNoise = BiomeCoordinator.OVERWORLD.getLocalNoise(biomeX, biomeY, biomeZ); | ||
int replacementScale = Biolith.getConfigManager().getGeneralConfig().getOverworldReplacementScale(); | ||
|
||
BiolithDescribeCommand.DescribeBiomeData describeBiomeData = BiomeCoordinator.OVERWORLD.getBiomeData(biomeX, biomeY, biomeZ, new MultiNoiseUtil.NoiseValuePoint(0,0,0,0,0,0), fittestNodes); | ||
|
||
String worldTranslationKey = world.getRegistryKey().getValue().toTranslationKey(); | ||
|
||
context.getSource().sendMessage(Text.literal("§nBiolith ") | ||
.append(Text.translatable(worldTranslationKey).formatted(Formatting.UNDERLINE)) | ||
.append(Text.literal("§n (")) | ||
.append(Text.translatable("biolith.command.describe.biome.scale").formatted(Formatting.UNDERLINE)) | ||
.append(Text.literal("§n: " + replacementScale + ") ")) | ||
.append(Text.translatable("biolith.command.describe.header").formatted(Formatting.UNDERLINE))); | ||
|
||
context.getSource().sendMessage(Text.literal(String.format("§6BR§r:%+05.3f", replacementNoise))); | ||
|
||
context.getSource().sendMessage(Text.translatable("biolith.command.describe.biome.modern_beta") | ||
.append(textFromBiome(original))); | ||
|
||
if (describeBiomeData.replacementBiome() != null) { | ||
context.getSource().sendMessage(Text.translatable("biolith.command.describe.biome.replacement") | ||
.append(textFromBiome(describeBiomeData.replacementBiome())) | ||
.append(Text.literal("\n ")) | ||
.append(describeBiomeData.lowerBiome() == null ? | ||
Text.translatable("biolith.command.describe.biome.none") : | ||
textFromBiome(describeBiomeData.lowerBiome())) | ||
.append(Text.literal(" < ")) | ||
.append(textFromBiome(describeBiomeData.replacementBiome())) | ||
.append(Text.literal(" < ")) | ||
.append(describeBiomeData.higherBiome() == null ? | ||
Text.translatable("biolith.command.describe.biome.none") : | ||
textFromBiome(describeBiomeData.higherBiome())) | ||
.append(Text.literal(String.format("\n %+05.3f < %+05.3f < %+05.3f ", | ||
describeBiomeData.replacementRange().x, | ||
replacementNoise, | ||
describeBiomeData.replacementRange().y)))); | ||
} | ||
|
||
return 1; | ||
} | ||
} |
Oops, something went wrong.