### Region Weight Example Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/region-class.md Demonstrates how to get and print the weight of a region. ```java Region region = /* ... */; System.out.println("Region weight: " + region.getWeight()); ``` -------------------------------- ### Custom Region Example: Simple Overlay Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/SUMMARY.txt A complete working example demonstrating a simple overlay region. This showcases how to add custom regions that modify existing terrain features. ```java // Example for custom-region.md - Simple overlay regions // Assumes necessary imports and TerraBlender initialization // Define a custom region Region customRegion = new Region("my_overlay_region", 100, 100, 100, 100, 100, 100); // Add a vanilla biome as an overlay customRegion.addBiome(new BiomeKey("minecraft", "plains")); // Register the custom region Regions.register(customRegion); ``` -------------------------------- ### Custom Region Example: Modified Vanilla Biomes Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/SUMMARY.txt A complete working example demonstrating modified vanilla biomes. This shows how to alter the parameters or characteristics of existing biomes. ```java // Example for custom-region.md - Modified vanilla biomes // Assumes necessary imports and TerraBlender initialization // Modify the temperature of plains biome ModifiedVanillaOverworldBuilder.replaceParameter(new BiomeKey("minecraft", "plains"), Parameter.Temperature, 0.8f); // Add a custom biome as a replacement for snowy plains under certain conditions ModifiedVanillaOverworldBuilder.replaceBiome(new BiomeKey("minecraft", "snowy_plains"), new BiomeKey("terrablender", "custom_frozen_plains")); ``` -------------------------------- ### Custom Region Examples Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/SUMMARY.txt Contains 6 complete working examples demonstrating how to create custom regions, modify vanilla biomes, and implement various biome generation patterns in TerraBlender. ```APIDOC ## Custom Region Examples ### Description A collection of practical examples showcasing advanced TerraBlender features and best practices for custom biome and region generation. ### Example Scenarios - **Simple overlay regions**: Demonstrates applying simple overlays to existing regions. - **Modified vanilla biomes**: Shows how to alter vanilla biomes. - **Multi-biome regions**: Illustrates creating regions composed of multiple biomes. - **Nether regions**: Provides examples for Nether dimension generation. - **End biome registration**: Covers custom biome registration for the End dimension. ### Best Practices - **Patterns**: Demonstrates recommended patterns for structuring custom generation logic. - **Initialization**: Examples include proper initialization sequences. ``` -------------------------------- ### Custom Region Subclass Example Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/region-class.md Example of how to extend the Region class and call the super constructor. ```java public class MyForestRegion extends Region { public MyForestRegion(Identifier name, int weight) { super(name, RegionType.OVERWORLD, weight); } } ``` -------------------------------- ### Custom Region Example: Multi-Biome Region Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/SUMMARY.txt A complete working example demonstrating a multi-biome region. This illustrates how to define a single region that can contain multiple distinct biomes. ```java // Example for custom-region.md - Multi-biome regions // Assumes necessary imports and TerraBlender initialization // Define a region that can contain multiple biomes Region multiBiomeRegion = new Region("my_multi_biome_region", 200, 200, 200, 200, 200, 200); // Add several biomes to this region with different weights multiBiomeRegion.addBiome(new BiomeKey("minecraft", "forest"), 5); // Weight 5 multiBiomeRegion.addBiome(new BiomeKey("minecraft", "mountains"), 3); // Weight 3 multiBiomeRegion.addBiome(new BiomeKey("minecraft", "taiga"), 2); // Weight 2 // Register the multi-biome region Regions.register(multiBiomeRegion); ``` -------------------------------- ### Custom Region Example: Best Practices and Patterns Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/SUMMARY.txt Illustrates best practices and common patterns for creating custom regions in TerraBlender. This example focuses on modularity and clarity in configuration. ```java // Example for custom-region.md - Best practices and patterns // Assumes necessary imports and TerraBlender initialization // Centralized biome definitions final BiomeKey PLAINS = new BiomeKey("minecraft", "plains"); final BiomeKey FOREST = new BiomeKey("minecraft", "forest"); final BiomeKey CUSTOM_FOREST = new BiomeKey("terrablender", "my_custom_forest"); // Define a region with clear parameter constraints Region temperateForestRegion = new Region("temperate_forest_region", 150, 150, 150, 150, 150, 150) .addBiome(FOREST, 8) .addBiome(CUSTOM_FOREST, 2) .addParameterCondition(Parameter.Temperature, 0.4f, 0.7f) .addParameterCondition(Parameter.Humidity, 0.3f, 0.6f); Regions.register(temperateForestRegion); ``` -------------------------------- ### Custom Biome Registration Example Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/region-class.md Example of overriding the addBiomes method to register a custom biome using a helper method. ```java @Override public void addBiomes(Registry registry, Consumer>> mapper) { // Add a custom biome using the helper method addBiome(mapper, Temperature.HOT, Humidity.HUMID, Continentalness.INLAND, Erosion.EROSION_2, Weirdness.VALLEY, Depth.SURFACE, 0.0F, MY_CUSTOM_BIOME); } ``` -------------------------------- ### Example Usage of Wrapper.wrap() Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/types.md Demonstrates how to use the static `wrap` method to create a WeightedEntry.Wrapper for a ResourceKey with a weight of 10. ```java WeightedEntry.Wrapper> entry = WeightedEntry.wrap(MY_BIOME, 10); ``` -------------------------------- ### Example Usage of Wrapper.codec() Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/types.md Illustrates creating a Codec for a Wrapper containing ResourceKey objects, utilizing the provided ResourceKey codec. ```java Codec>> biomeCodec = Wrapper.codec(ResourceKey.codec(Registries.BIOME)); ``` -------------------------------- ### Example RuleBuilder Implementation Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/surface-rule-manager.md An example implementation of `RuleBuilder` that creates rules based on a specific biome. This demonstrates how to use `SurfaceRules.ifTrue` and `SurfaceRules.state` with biome lookups. ```java RuleBuilder myRules = biomes -> SurfaceRules.ifTrue( SurfaceRules.isBiome(biomes.getOrThrow(MY_BIOME)), SurfaceRules.state(MY_SURFACE_BLOCK.defaultBlockState()) ); ``` -------------------------------- ### Custom Region Example: Nether Region Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/SUMMARY.txt A complete working example demonstrating a Nether-specific region. This shows how to define custom generation within the Nether dimension. ```java // Example for custom-region.md - Nether regions // Assumes necessary imports and TerraBlender initialization // Define a custom region for the Nether Region netherRegion = new Region("my_nether_region", 150, 150, 150, 150, 150, 150); // Add a custom Nether biome netherRegion.addBiome(new BiomeKey("terrablender", "custom_nether_wasteland")); // Register the Nether region (assuming a mechanism to associate with Nether dimension) // This might involve specific registration methods or configuration not shown here. // For simplicity, we'll use the general register method. Regions.register(netherRegion); ``` -------------------------------- ### Region Identifier Example Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/region-class.md Demonstrates how to get and print the name of a region. ```java Region region = new MyRegion(Identifier.fromNamespaceAndPath("mymod", "my_region"), RegionType.OVERWORLD, 10); Identifier id = region.getName(); System.out.println("Region name: " + id); ``` -------------------------------- ### Custom Region Example: End Biome Registration Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/SUMMARY.txt A complete working example demonstrating End biome registration. This focuses on setting up custom biomes within the End dimension. ```java // Example for custom-region.md - End biome registration // Assumes necessary imports and TerraBlender initialization // Register custom biomes for the End dimension using EndBiomeRegistry EndBiomeRegistry.registerHighlands(new BiomeKey("terrablender", "custom_end_highlands"), 10); EndBiomeRegistry.registerMidlands(new BiomeKey("terrablender", "custom_end_midlands"), 5); EndBiomeRegistry.registerEdges(new BiomeKey("terrablender", "custom_end_edges"), 5); EndBiomeRegistry.registerIslands(new BiomeKey("terrablender", "custom_end_islands"), 1); // Optionally, you can also register vanilla End biomes if needed for specific configurations. ``` -------------------------------- ### Example TerrablenderOverworldBiomeBuilder Usage Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/terrablender-overworld-biome-builder.md Demonstrates how to create custom biome arrays and use them to instantiate a TerrablenderOverworldBiomeBuilder. This example shows the assignment of specific biomes to different humidity and temperature combinations within the middle biomes array. ```Java // Create custom biome arrays ResourceKey[][] customMiddleBiomes = new ResourceKey[5][5]; customMiddleBiomes[0][0] = MY_ARID_ICY_BIOME; // [ARID, ICY] customMiddleBiomes[0][4] = MY_ARID_HOT_BIOME; // [ARID, HOT] customMiddleBiomes[4][4] = MY_HUMID_HOT_BIOME; // [HUMID, HOT] TerrablenderOverworldBiomeBuilder builder = new TerrablenderOverworldBiomeBuilder( oceanBiomes, customMiddleBiomes, customMiddleBiomesVariant, plateauBiomes, plateauBiomesVariant, shatteredBiomes, beachBiomes, peakBiomes, peakBiomesVariant, slopeBiomes, slopeBiomesVariant ); ``` -------------------------------- ### Instantiate VanillaParameterOverlayBuilder Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/vanilla-parameter-overlay-builder.md Creates an instance of the VanillaParameterOverlayBuilder. This is the starting point for defining custom biome parameter mappings. ```java VanillaParameterOverlayBuilder builder = new VanillaParameterOverlayBuilder(); ``` -------------------------------- ### Complete Region Example with Modified Overworld Biomes Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/modified-vanilla-overworld-builder.md A full example of a custom Region class that utilizes ModifiedVanillaOverworldBuilder to replace global biomes, adjust specific climate parameter points, and remove unwanted parameter points. ```java public class MyModifiedOverworldRegion extends Region { public MyModifiedOverworldRegion(Identifier name, int weight) { super(name, RegionType.OVERWORLD, weight); } @Override public void addBiomes(Registry registry, Consumer>> mapper) { addModifiedVanillaOverworldBiomes(mapper, builder -> { // Replace specific biomes globally builder.replaceBiome(Biomes.DESERT, MY_HOT_DESERT); builder.replaceBiome(Biomes.PLAINS, MY_GRASSLAND); builder.replaceBiome(Biomes.FOREST, MY_FOREST); builder.replaceBiome(Biomes.TAIGA, MY_BOREAL_FOREST); // Adjust a specific climate condition Climate.ParameterPoint coldDryPoint = Climate.parameters( Temperature.ICY.parameter(), Humidity.DRY.parameter(), Continentalness.INLAND.parameter(), Erosion.EROSION_2.parameter(), Depth.SURFACE.parameter(), Weirdness.VALLEY.parameter(), 0.0F ); builder.replaceBiome(coldDryPoint, MY_ARCTIC_WASTELAND); // Remove an unwanted parameter point builder.removeParameter(/* some point */); }); } } ``` -------------------------------- ### Loading TerraBlender Configuration from JSON Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/SUMMARY.txt Provides an example of loading TerraBlender configuration from a JSON file. This is an alternative method for configuring TerraBlender. ```json { "general": { "region_size": 10 }, "end": { "chorus_plant_spawn_chance": 0.1 } } ``` -------------------------------- ### Forge/NeoForge Configuration (TOML) Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/configuration.md Example TOML configuration file for Forge and NeoForge. Use this to set region sizes and biome weights. ```toml [general] # Region size controls overworld_region_size = 3 nether_region_size = 2 # Weight controls for vanilla biome frequency vanilla_overworld_region_weight = 10 vanilla_nether_region_weight = 10 [end] # End biome patch sizes highlands_biome_size = 4 midlands_biome_size = 4 edge_biome_size = 3 island_biome_size = 2 # Vanilla biome weights in the End vanilla_end_highlands_weight = 10 vanilla_end_midlands_weight = 10 vanilla_end_barrens_weight = 10 vanilla_small_end_islands_weight = 10 ``` -------------------------------- ### Register Custom Regions in Java Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/examples-custom-region.md Demonstrates the complete mod setup for registering custom Overworld, Nether, and End regions using the Regions API. Ensure all necessary biome setup classes are imported. ```java package mymod.terrablender; import net.minecraft.resources.Identifier; import terrablender.api.Regions; public class TerraBlenderSetup { public static void registerRegions() { // Register Overworld regions Regions.register( Identifier.fromNamespaceAndPath("mymod", "forest_region"), new CustomForestRegion( Identifier.fromNamespaceAndPath("mymod", "forest_region"), 10 ) ); Regions.register( Identifier.fromNamespaceAndPath("mymod", "varied_terrain_region"), new VariedTerrainRegion( Identifier.fromNamespaceAndPath("mymod", "varied_terrain_region"), 10 ) ); // Register Nether regions Regions.register( Identifier.fromNamespaceAndPath("mymod", "nether_region"), new CustomNetherRegion( Identifier.fromNamespaceAndPath("mymod", "nether_region"), 10 ) ); // Register End biomes EndBiomeSetup.registerEndBiomes(); } } ``` -------------------------------- ### Initialize ParameterPointListBuilder Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/parameter-utils.md Creates a new builder instance. This is the starting point for constructing parameter point lists. ```java public ParameterPointListBuilder() ``` -------------------------------- ### Example Usage of ModifiedVanillaOverworldBuilder Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/modified-vanilla-overworld-builder.md Demonstrates how to instantiate the builder, replace specific biomes, and retrieve the final list of mappings. Use this to quickly test biome replacements. ```java ModifiedVanillaOverworldBuilder builder = new ModifiedVanillaOverworldBuilder(); builder.replaceBiome(Biomes.DESERT, MY_DESERT); builder.replaceBiome(Biomes.OCEAN, MY_OCEAN); List>> mappings = builder.build(); // Use the mappings in a Region mappings.forEach(mapper); ``` -------------------------------- ### Biome Replacement Priority Example Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/modified-vanilla-overworld-builder.md Demonstrates the priority order for biome replacements. Point-specific replacements take precedence over global replacements. ```java builder.replaceBiome(Biomes.DESERT, MY_BIOME_1); // Global replacement builder.replaceBiome(specificPoint, MY_BIOME_2); // Point-specific (takes precedence) // The specificPoint will use MY_BIOME_2, all other desert points use MY_BIOME_1 ``` -------------------------------- ### Loading TerraBlender Configuration from TOML Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/SUMMARY.txt Provides an example of loading TerraBlender configuration from a TOML file. This is the recommended method for configuring TerraBlender in a mod. ```toml [general] region_size = 10 [end] chorus_plant_spawn_chance = 0.1 ``` -------------------------------- ### Fabric Configuration (JSON) Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/configuration.md Example JSON configuration file for Fabric. This format is used to define region sizes and biome weights. ```json { "general": { "overworld_region_size": 3, "nether_region_size": 2, "vanilla_overworld_region_weight": 10, "vanilla_nether_region_weight": 10 }, "end": { "highlands_biome_size": 4, "midlands_biome_size": 4, "edge_biome_size": 3, "island_biome_size": 2, "vanilla_end_highlands_weight": 10, "vanilla_end_midlands_weight": 10, "vanilla_end_barrens_weight": 10, "vanilla_small_end_islands_weight": 10 } } ``` -------------------------------- ### Create a New ModifiedVanillaOverworldBuilder Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/modified-vanilla-overworld-builder.md Instantiates a new builder. Call build() without any modifications to get the default vanilla biome configuration. ```java public ModifiedVanillaOverworldBuilder() ``` ```java ModifiedVanillaOverworldBuilder builder = new ModifiedVanillaOverworldBuilder(); ``` -------------------------------- ### Region Type Check Example Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/region-class.md Shows how to check if a region is of type OVERWORLD. ```java Region region = /* ... */; if (region.getType() == RegionType.OVERWORLD) { System.out.println("This is an overworld region"); } ``` -------------------------------- ### Registering Biomes with Weights Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/end-biome-registry.md Example of registering biomes with specific integer weights to influence their selection frequency. Higher weights mean higher probability. ```java registerHighlandsBiome(BIOME_A, 10); registerHighlandsBiome(BIOME_B, 5); registerHighlandsBiome(BIOME_C, 5); ``` -------------------------------- ### Static Initialization of Rule Maps Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/surface-rule-manager.md Initializes maps for all `RuleCategory` and `RuleStage` combinations. This setup is required before adding or injecting custom surface rules. ```java for (RuleCategory category : RuleCategory.values()) { surfaceRuleBuilders.put(category, Maps.newHashMap()); Map>> ruleStages = Maps.newHashMap(); for (RuleStage stage : RuleStage.values()) ruleStages.put(stage, Lists.newArrayList()); defaultSurfaceRuleInjections.put(category, ruleStages); } ``` -------------------------------- ### Overlaying Custom Biomes with VanillaParameterOverlayBuilder Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/vanilla-parameter-overlay-builder.md Example of how to extend the Region class to add custom biomes using the VanillaParameterOverlayBuilder. This pattern is useful for defining specific climate conditions that should map to custom biomes instead of vanilla ones. ```java public class MyOverlayRegion extends Region { public MyOverlayRegion(Identifier name, int weight) { super(name, RegionType.OVERWORLD, weight); } @Override public void addBiomes(Registry registry, Consumer>> mapper) { VanillaParameterOverlayBuilder builder = new VanillaParameterOverlayBuilder(); // Add a custom cold/humid biome new ParameterPointListBuilder() .temperature(Temperature.ICY, Temperature.COOL) .humidity(Humidity.HUMID) .continentalness(Continentalness.INLAND) .erosion(Erosion.EROSION_3) .depth(Depth.SURFACE) .weirdness(Weirdness.VALLEY) .build() .forEach(point -> builder.add(point, MY_BOREAL_FOREST)); // Add a custom hot/arid biome new ParameterPointListBuilder() .temperature(Temperature.HOT) .humidity(Humidity.ARID) .continentalness(Continentalness.FAR_INLAND) .erosion(Erosion.EROSION_5) .depth(Depth.SURFACE) .weirdness(Weirdness.VALLEY) .build() .forEach(point -> builder.add(point, MY_BADLANDS)); // Build and add to mapper builder.build().forEach(mapper); } } ``` -------------------------------- ### TerraBlender Configuration Example: Global Access Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/SUMMARY.txt Illustrates the common pattern of accessing TerraBlender configuration globally using the CONFIG object. This provides a convenient way to retrieve settings throughout the mod. ```java // Example for configuration.md - Global CONFIG access pattern // Assumes TerraBlenderConfig is loaded and accessible via a static field named CONFIG // Accessing a general setting int regionSize = TerraBlender.CONFIG.general.region_size; // Accessing an End dimension setting float chorusChance = TerraBlender.CONFIG.end.chorus_plant_spawn_chance; System.out.println("Region Size: " + regionSize); System.out.println("Chorus Plant Spawn Chance: " + chorusChance); ``` -------------------------------- ### Custom Region Implementation Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/types.md Example of extending the Region class to define a custom region. Requires specifying a name, region type, and weight. ```java public class MyRegion extends Region { public MyRegion(Identifier name, int weight) { super(name, RegionType.OVERWORLD, weight); } } ``` -------------------------------- ### Add Multiple Custom Biome Mappings and Build Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/vanilla-parameter-overlay-builder.md Adds multiple custom biome mappings for a jungle biome based on specific climate parameters and then builds the final overlay mapping list. This demonstrates a more complex biome distribution setup. ```java VanillaParameterOverlayBuilder builder = new VanillaParameterOverlayBuilder(); // Add multiple custom biome mappings new ParameterPointListBuilder() .temperature(Temperature.HOT) .humidity(Humidity.HUMID) .continentalness(Continentalness.INLAND) .erosion(Erosion.EROSION_2) .depth(Depth.SURFACE) .weirdness(Weirdness.VALLEY) .build() .forEach(point -> builder.add(point, MY_JUNGLE)); List>> mappings = builder.build(); mappings.forEach(mapper); ``` -------------------------------- ### Register Custom Biome Region Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/parameter-utils.md Example of registering a custom biome region, demonstrating both simple single biome addition and complex multiple parameter combinations using a builder. ```java public class MyCustomRegion extends Region { public MyCustomRegion(Identifier name, int weight) { super(name, RegionType.OVERWORLD, weight); } @Override public void addBiomes(Registry registry, Consumer>> mapper) { // Simple: Single biome with specific parameters addBiome(mapper, Temperature.HOT, Humidity.HUMID, Continentalness.INLAND, Erosion.EROSION_2, Weirdness.VALLEY, Depth.SURFACE, 0.0F, MY_JUNGLE); // Complex: Multiple parameter combinations using builder new ParameterPointListBuilder() .temperature(Temperature.COOL, Temperature.COLD) .humidity(Humidity.WET, Humidity.HUMID) .continentalness(Continentalness.COAST) .erosion(Erosion.EROSION_4, Erosion.EROSION_5) .depth(Depth.SURFACE) .weirdness(Weirdness.VALLEY, Weirdness.LOW_SLICE_NORMAL_DESCENDING) .build() .forEach(point -> addBiome(mapper, point, MY_RAINFOREST)); } } ``` -------------------------------- ### Create VanillaParameterOverlayBuilder Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/vanilla-parameter-overlay-builder.md Initializes a new VanillaParameterOverlayBuilder. This builder is used to define custom biome overlays that will be added to the game's biome generation. ```java public VanillaParameterOverlayBuilder() ``` -------------------------------- ### Get Region Count Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/regions-api.md Gets the total number of registered regions for a specified region type, including both vanilla and modded regions. This method is useful for understanding the scope of available regions. ```java public static int getCount(RegionType type) ``` ```java int overworldCount = Regions.getCount(RegionType.OVERWORLD); int netherCount = Regions.getCount(RegionType.NETHER); System.out.println("Overworld regions: " + overworldCount); System.out.println("Nether regions: " + netherCount); ``` -------------------------------- ### Building a Parameter Point List in TerraBlender Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/SUMMARY.txt Shows how to use the ParameterPointListBuilder to fluently construct a list of climate parameter points, which are used to define biome generation conditions. ```java ParameterPointListBuilder.newBuilder() .addPoint(ParameterPoint.of(0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f)) .build(); ``` -------------------------------- ### VanillaParameterOverlayBuilder.build() Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/vanilla-parameter-overlay-builder.md Builds the final list of overlay mappings. This method constructs the complete overlay mapping list, including handling for adjacent and standalone parameter points to ensure vanilla biomes fill any gaps. ```APIDOC ## build() ### Description Builds the final list of overlay mappings. Constructs the complete overlay mapping list. The builder performs the following steps: 1. **Adjacency Detection:** Identifies parameter points that are adjacent to each other (differ in exactly one dimension) 2. **Inverse Mapping:** For adjacent points, creates inverse parameter ranges that defer to vanilla biomes 3. **Standalone Handling:** For non-adjacent points, creates inverse ranges to defer to vanilla 4. **Result:** Returns both the original mappings and inverse mappings to ensure vanilla biomes fill gaps The `DEFERRED_PLACEHOLDER` biome key is used to indicate areas where vanilla biomes should generate. ### Method ```java public List>> build() ``` ### Return Type `List>>` - Immutable list of all mappings ### Example ```java VanillaParameterOverlayBuilder builder = new VanillaParameterOverlayBuilder(); // Add multiple custom biome mappings new ParameterPointListBuilder() .temperature(Temperature.HOT) .humidity(Humidity.HUMID) .continentalness(Continentalness.INLAND) .erosion(Erosion.EROSION_2) .depth(Depth.SURFACE) .weirdness(Weirdness.VALLEY) .build() .forEach(point -> builder.add(point, MY_JUNGLE)); List>> mappings = builder.build(); mappings.forEach(mapper); ``` ``` -------------------------------- ### Temperature.parameter() Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/parameter-utils.md Gets the raw Climate.Parameter object associated with a specific temperature preset. ```APIDOC ## Method: parameter() ### Description Gets the raw `Climate.Parameter` for this temperature value. ### Return Type `Climate.Parameter` - The underlying parameter object ``` -------------------------------- ### Accessing TerraBlenderConfig Properties Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/configuration.md Example of how to access loaded configuration values from the TerraBlenderConfig instance. ```java TerraBlenderConfig config = TerraBlender.CONFIG; int overworldSize = config.overworldRegionSize; int netherWeight = config.vanillaNetherRegionWeight; ``` -------------------------------- ### Get Island Biomes Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/end-biome-registry.md Retrieves an immutable copy of all registered island biomes with their weights. ```java public static List>> getIslandBiomes() ``` -------------------------------- ### getType() Method Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/region-class.md Gets the type of this region. Returns the region type specified during construction. ```java public RegionType getType() ``` -------------------------------- ### Get Edge Biomes Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/end-biome-registry.md Retrieves an immutable copy of all registered edge biomes with their weights. ```java public static List>> getEdgeBiomes() ``` -------------------------------- ### Get Midlands Biomes Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/end-biome-registry.md Retrieves an immutable copy of all registered midlands biomes with their weights. ```java public static List>> getMidlandsBiomes() ``` -------------------------------- ### getName() Method Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/region-class.md Gets the unique identifier for this region. Returns the identifier assigned during construction. ```java public Identifier getName() ``` -------------------------------- ### getWeight() Method Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/region-class.md Gets the weight of this region. Returns the relative weight used to determine biome generation frequency. ```java public int getWeight() ``` -------------------------------- ### Convenience Factory Method for Wrapper Creation Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/types.md A static utility method to simplify the creation of Wrapper instances. It automatically converts an integer weight into a Weight object. ```java public static Wrapper wrap(T object, int weight) ``` -------------------------------- ### getNamespacedRules Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/surface-rule-manager.md Gets the namespaced rules for a given dimension category, with support for fallback to a specified rule source if no namespace matches. ```APIDOC ## getNamespacedRules() ### Description Gets the namespaced rules for a given category with fallback support. ### Method `public static SurfaceRules.RuleSource getNamespacedRules(RuleCategory category, SurfaceRules.RuleSource fallback)` ### Parameters #### Path Parameters - **category** (RuleCategory) - Yes - Dimension category - **fallback** (SurfaceRules.RuleSource) - Yes - Fallback rule to use if namespace not found ### Response #### Success Response (SurfaceRules.RuleSource) The namespaced rule source with fallback. ### Example ```java SurfaceRules.RuleSource rules = SurfaceRuleManager.getNamespacedRules( RuleCategory.OVERWORLD, SurfaceRules.state(Blocks.STONE.defaultBlockState()) ); ``` ``` -------------------------------- ### get(RegionType type) Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/regions-api.md Retrieves an immutable list of all registered regions for a specified type. The list preserves registration order. ```APIDOC ## get(RegionType type) ### Description Retrieves all regions of a specified type. Returns an immutable copy of all registered regions for the given type. The list preserves registration order (or the order defined by indices). Modifications to the returned list do not affect the registry. ### Method `public static List get(RegionType type)` ### Parameters #### Path Parameters - **type** (`RegionType`) - Yes - Type of regions to retrieve (OVERWORLD or NETHER) ### Return Type `List` - Immutable list of all regions for the specified type ### Example ```java List overworldRegions = Regions.get(RegionType.OVERWORLD); for (Region region : overworldRegions) { System.out.println("Region: " + region.getName() + ", Weight: " + region.getWeight()); } ``` ``` -------------------------------- ### VanillaParameterOverlayBuilder Class Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/SUMMARY.txt Details the VanillaParameterOverlayBuilder class, used for adding overlays to vanilla biomes based on parameter detection and adjacency. Includes methods for adding overlays and building the final configuration, preserving vanilla biome characteristics. ```APIDOC ## VanillaParameterOverlayBuilder Class ### Description Enables the creation of overlay layers on vanilla biomes by detecting parameter conditions and adjacency. This system helps in preserving vanilla biome characteristics while introducing custom modifications. ### Methods - **add**: Adds an overlay configuration. - **build**: Finalizes and applies the overlay configurations. ### Features - **Adjacency detection**: Identifies biome adjacencies for overlay placement. - **Inverse mapping**: Manages mapping between parameters and biomes. - **Vanilla biome preservation**: Ensures vanilla biomes are maintained where intended. ``` -------------------------------- ### TerraBlenderConfig Constructor Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/configuration.md Initializes a new TerraBlenderConfig object by specifying the path to the configuration file. ```APIDOC ## TerraBlenderConfig Constructor ### Description Initializes a new TerraBlenderConfig object. ### Method Signature ```java public TerraBlenderConfig(Path path) ``` ### Parameters #### Path Parameters - **path** (Path) - Required - Path to the configuration file ``` -------------------------------- ### VanillaParameterOverlayBuilder Constructor Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/vanilla-parameter-overlay-builder.md Creates a new instance of VanillaParameterOverlayBuilder. This builder is used to define custom biome parameter mappings that will be overlaid onto the existing vanilla biome generation. ```APIDOC ## VanillaParameterOverlayBuilder() ### Description Creates a new builder with an empty mapping set. Added mappings will be layered on top of vanilla biome generation. ### Constructor ```java public VanillaParameterOverlayBuilder() ``` ### Example ```java VanillaParameterOverlayBuilder builder = new VanillaParameterOverlayBuilder(); ``` ``` -------------------------------- ### Get Biome Holder with HolderGetter Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/types.md Retrieves a biome holder using its resource key. Ensure the key is valid and exists in the registry. ```java Holder getOrThrow(ResourceKey key) ``` ```java RuleBuilder myRules = biomes -> { Holder myBiome = biomes.getOrThrow(MY_BIOME_KEY); // Use myBiome to build rules }; ``` -------------------------------- ### build() Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/parameter-utils.md Builds a complete list of parameter points by creating the Cartesian product of all specified parameters. If any parameter type is not specified, it defaults to FULL_RANGE. Returns an immutable copy of the list. ```APIDOC ## Method: build() ### Description Builds a complete list of parameter points. Creates the Cartesian product of all specified parameters. If any parameter type is not specified, fills with FULL_RANGE. Returns an immutable copy. ### Signature ```java public List build() ``` ### Return Type `List` - Immutable list of all parameter points ### Example ```java List points = new ParameterPointListBuilder() .temperature(Temperature.HOT) .humidity(Humidity.HUMID) .continentalness(Continentalness.INLAND) .erosion(Erosion.EROSION_2) .depth(Depth.SURFACE) .weirdness(Weirdness.VALLEY) .build(); for (Climate.ParameterPoint point : points) { addBiome(mapper, point, MY_JUNGLE_BIOME); } ``` ``` -------------------------------- ### Wrapper Constructor Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/types.md Initializes a new instance of the Wrapper record, taking the data to be wrapped and its associated weight as parameters. ```java public Wrapper(T data, Weight weight) ``` -------------------------------- ### Get Underlying Climate Parameter Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/parameter-utils.md Retrieves the Climate.Parameter object associated with a Humidity enum value. This is useful for direct manipulation or inspection of the parameter. ```java public Climate.Parameter parameter() ``` -------------------------------- ### TerraBlenderConfig Constructor Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/configuration.md Initializes the TerraBlenderConfig with a path to the configuration file. ```java public TerraBlenderConfig(Path path) ``` -------------------------------- ### Get Default Surface Rules Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/surface-rule-manager.md Retrieves the built-in default surface rules for a specified dimension category. These rules are established during manager initialization. ```Java public static SurfaceRules.RuleSource getDefaultSurfaceRules(RuleCategory category) ``` -------------------------------- ### Constructor for ParameterPoint Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/types.md Use this constructor to create a new ParameterPoint with specific climate parameters and an offset. ```java public ParameterPoint(Climate.Parameter temperature, Climate.Parameter humidity, Climate.Parameter continentalness, Climate.Parameter erosion, Climate.Parameter depth, Climate.Parameter weirdness, long offset) ``` -------------------------------- ### Get Highlands Biomes Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/end-biome-registry.md Retrieves an immutable copy of all registered highlands biomes, including their weights. List order follows registration order. ```java public static List>> getHighlandsBiomes() ``` ```java List>> highlands = EndBiomeRegistry.getHighlandsBiomes(); for (WeightedEntry.Wrapper> entry : highlands) { ResourceKey biome = entry.data(); int weight = entry.weight().asInt(); System.out.println("Biome: " + biome + ", Weight: " + weight); } ``` -------------------------------- ### ParameterPointListBuilder Constructor Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/parameter-utils.md Initializes a new instance of the ParameterPointListBuilder class with empty parameter lists. ```APIDOC ## Constructor ParameterPointListBuilder ### Description Creates a new parameter point list builder with empty parameter lists. ### Method ```java public ParameterPointListBuilder() ``` ``` -------------------------------- ### Get Region Index Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/regions-api.md Retrieves the zero-based index of a region by its type and identifier. The index is cached for performance. Throws a RuntimeException if the region is not registered. ```java public static int getIndex(RegionType type, Identifier location) ``` ```java Identifier regionId = Identifier.fromNamespaceAndPath("mymod", "my_region"); int index = Regions.getIndex(RegionType.OVERWORLD, regionId); System.out.println("Region index: " + index); ``` -------------------------------- ### TerraBlenderConfig load() Method Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/configuration.md Loads and parses the configuration file, populating the public fields. This method is automatically called during initialization. ```java public void load() ``` -------------------------------- ### Accessing WeightedEntry.Wrapper Values Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/end-biome-registry.md Demonstrates how to retrieve the biome resource key and its integer weight from a WeightedEntry.Wrapper instance. ```java WeightedEntry.Wrapper> entry = /* from registry */; // Get the biome ResourceKey biome = entry.data(); // Get the weight as integer int weight = entry.weight().asInt(); ``` -------------------------------- ### getCount Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/regions-api.md Gets the total count of regions for a specified type. Returns the number of registered regions for the given type. Includes both vanilla and modded regions. ```APIDOC ## getCount(RegionType type) ### Description Gets the total count of regions for a specified type. Returns the number of registered regions for the given type. Includes both vanilla and modded regions. ### Method `getCount` ### Parameters #### Path Parameters - **type** (`RegionType`) - Yes - Type of regions to count ### Return Type `int` - Number of registered regions for the type ### Example ```java int overworldCount = Regions.getCount(RegionType.OVERWORLD); int netherCount = Regions.getCount(RegionType.NETHER); System.out.println("Overworld regions: " + overworldCount); System.out.println("Nether regions: " + netherCount); ``` ``` -------------------------------- ### Registering a Custom Region in TerraBlender Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/SUMMARY.txt Demonstrates the basic pattern for registering a custom region using the Regions static registry. Ensure TerraBlender is initialized before calling this. ```java Regions.register(new Region("my_custom_region", 100, 100, 100, 100, 100, 100)); ``` -------------------------------- ### Climate.ParameterPoint Constructor Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/types.md Constructs a new ParameterPoint with specified climate parameters and an offset. ```APIDOC ## Climate.ParameterPoint Constructor ### Description Constructs a new ParameterPoint with specified climate parameters and an offset. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **temperature** (`Climate.Parameter`) - Required - Temperature parameter range - **humidity** (`Climate.Parameter`) - Required - Humidity parameter range - **continentalness** (`Climate.Parameter`) - Required - Continentalness parameter range - **erosion** (`Climate.Parameter`) - Required - Erosion parameter range - **depth** (`Climate.Parameter`) - Required - Depth parameter range - **weirdness** (`Climate.Parameter`) - Required - Weirdness parameter range - **offset** (`long`) - Required - Offset value (quantized) ``` -------------------------------- ### Create Custom Forest Region with Overlay Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/examples-custom-region.md Defines a custom region for forests using VanillaParameterOverlayBuilder to add custom biomes based on climate parameters. Requires biome definitions in MyBiomes and registration. ```java package mymod.terrablender; import com.mojang.datafixers.util.Pair; import net.minecraft.core.Registry; import net.minecraft.resources.Identifier; import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Climate; import terrablender.api.Region; import terrablender.api.RegionType; import terrablender.api.VanillaParameterOverlayBuilder; import terrablender.api.ParameterUtils.*; import java.util.function.Consumer; public class CustomForestRegion extends Region { public CustomForestRegion(Identifier name, int weight) { super(name, RegionType.OVERWORLD, weight); } @Override public void addBiomes(Registry registry, Consumer>> mapper) { VanillaParameterOverlayBuilder builder = new VanillaParameterOverlayBuilder(); // Create parameter points for a tropical forest new ParameterPointListBuilder() .temperature(Temperature.HOT) .humidity(Humidity.HUMID) .continentalness(Continentalness.INLAND) .erosion(Erosion.EROSION_2, Erosion.EROSION_3) .depth(Depth.SURFACE) .weirdness(Weirdness.VALLEY) .build() .forEach(point -> builder.add(point, MyBiomes.TROPICAL_JUNGLE)); // Create parameter points for a temperate forest new ParameterPointListBuilder() .temperature(Temperature.NEUTRAL, Temperature.COOL) .humidity(Humidity.WET, Humidity.HUMID) .continentalness(Continentalness.INLAND, Continentalness.MID_INLAND) .erosion(Erosion.EROSION_3, Erosion.EROSION_4) .depth(Depth.SURFACE) .weirdness(Weirdness.VALLEY, Weirdness.LOW_SLICE_NORMAL_DESCENDING) .build() .forEach(point -> builder.add(point, MyBiomes.TEMPERATE_FOREST)); // Build and add all mappings builder.build().forEach(mapper); } } ``` ```java Identifier regionId = Identifier.fromNamespaceAndPath("mymod", "forest_region"); Region forestRegion = new CustomForestRegion(regionId, 10); Regions.register(forestRegion); ``` -------------------------------- ### Terrablender Overworld Biome Builder Initialization Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/terrablender-overworld-biome-builder.md This Java code demonstrates the initialization of all biome arrays required by the TerrablenderOverworldBiomeBuilder and provides a loop structure for populating them with custom biomes. ```java public class MyOverworldBiomeBuilder { public static TerrablenderOverworldBiomeBuilder create() { // Initialize 5x5 biome arrays ResourceKey[][] oceans = new ResourceKey[2][5]; ResourceKey[][] middleBiomes = new ResourceKey[5][5]; ResourceKey[][] middleVariants = new ResourceKey[5][5]; ResourceKey[][] plateaus = new ResourceKey[5][5]; ResourceKey[][] plateauVariants = new ResourceKey[5][5]; ResourceKey[][] shattered = new ResourceKey[5][5]; ResourceKey[][] beaches = new ResourceKey[5][5]; ResourceKey[][] peaks = new ResourceKey[5][5]; ResourceKey[][] peakVariants = new ResourceKey[5][5]; ResourceKey[][] slopes = new ResourceKey[5][5]; ResourceKey[][] slopeVariants = new ResourceKey[5][5]; // Fill arrays with custom biomes for (int humid = 0; humid < 5; humid++) { for (int temp = 0; temp < 5; temp++) { // Assign custom biomes or vanilla fallbacks middleBiomes[humid][temp] = getCustomMiddleBiome(humid, temp); middleVariants[humid][temp] = getCustomMiddleVariant(humid, temp); // ... similarly for other arrays } } // Create and return builder return new TerrablenderOverworldBiomeBuilder( oceans, middleBiomes, middleVariants, plateaus, plateauVariants, shattered, beaches, peaks, peakVariants, slopes, slopeVariants ); } } ``` -------------------------------- ### TerraBlenderConfig Class Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/SUMMARY.txt Reference for the TerraBlenderConfig class, which holds all configuration options for TerraBlender. Includes general settings, End dimension settings, and examples for TOML and JSON configuration formats. ```APIDOC ## TerraBlenderConfig Class ### Description Represents the main configuration for TerraBlender, encompassing all customizable settings for biome generation, region sizes, weights, and dimension-specific options. ### Configuration Options - **General Settings**: Includes parameters like region sizes and weight distributions. - **End Dimension Settings**: Specific configurations for the End dimension. - **Ranges**: All configuration options are documented with their valid ranges. ### Examples - **TOML Example**: Demonstrates configuration using TOML format. - **JSON Example**: Demonstrates configuration using JSON format. ### Access Pattern - **Global CONFIG access**: Describes the pattern for accessing the global configuration instance. ``` -------------------------------- ### Weight Calculation Example Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/configuration.md Illustrates how biome weights are calculated to determine frequency. The total weight is the sum of all biome weights, and individual biome frequency is its weight divided by the total. ```plaintext Total weight = vanilla (10) + mod1 (5) + mod2 (5) = 20 Vanilla frequency: 10/20 = 50% Mod1 frequency: 5/20 = 25% Mod2 frequency: 5/20 = 25% ``` -------------------------------- ### TerraBlenderConfig.load() Method Source: https://github.com/glitchfiend/terrablender/blob/26.2/_autodocs/configuration.md Loads and parses the configuration file, populating the public fields with validated values. This method is automatically called during TerraBlender initialization. ```APIDOC ## load() Method ### Description Loads and parses the configuration file. Automatically called by TerraBlender during initialization. Reads all configuration keys and populates the public fields with validated values. ### Method Signature ```java public void load() ``` ```