From aa2791206b6703c60c5d2d5d7daddfd857700f73 Mon Sep 17 00:00:00 2001 From: Corgi Taco <66983020+CorgiTaco@users.noreply.github.com> Date: Mon, 29 Jan 2024 02:06:31 -0800 Subject: [PATCH] Add a more custom Overworld Biome Builder (#152) --- .../TerrablenderOverworldBiomeBuilder.java | 138 ++++++++++++++++++ .../main/resources/terrablender.accesswidener | 27 ++++ .../resources/META-INF/accesstransformer.cfg | 5 +- .../resources/META-INF/accesstransformer.cfg | 6 +- 4 files changed, 174 insertions(+), 2 deletions(-) create mode 100644 Common/src/main/java/terrablender/api/TerrablenderOverworldBiomeBuilder.java diff --git a/Common/src/main/java/terrablender/api/TerrablenderOverworldBiomeBuilder.java b/Common/src/main/java/terrablender/api/TerrablenderOverworldBiomeBuilder.java new file mode 100644 index 0000000..0c9ec01 --- /dev/null +++ b/Common/src/main/java/terrablender/api/TerrablenderOverworldBiomeBuilder.java @@ -0,0 +1,138 @@ +package terrablender.api; + +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.biome.Climate; +import net.minecraft.world.level.biome.OverworldBiomeBuilder; +import org.jetbrains.annotations.NotNull; + +public class TerrablenderOverworldBiomeBuilder extends OverworldBiomeBuilder { + + private final ResourceKey[][] beachBiomes; + private final ResourceKey[][] peakBiomes; + private final ResourceKey[][] peakBiomesVariant; + private final ResourceKey[][] slopeBiomes; + private final ResourceKey[][] slopeBiomesVariant; + + + /** + * @param oceans - Appearing on terrain below sea level, here is the "ocean_biomes" layout: + * [ DEEP-ICY, DEEP-COLD, DEEP-NEUTRAL, DEEP-WARM, DEEP-HOT ] + * [ SHALLOW-ICY, SHALLOW-COLD, SHALLOW-NEUTRAL, SHALLOW-WARM, SHALLOW-HOT ], + * @param middleBiomes - Appearing on terrain BELOW weirdness 0 or in unfilled("NULL(nothing)") spots in "middle_biomes_variants", here is the "middle_biomes" layout: + * [ ARID-ICY, DRY-ICY, NEUTRAL-ICY, WET-ICY, HUMID-ICY ], + * [ ARID-COLD, DRY-COLD, NEUTRAL-COLD, WET-COLD, HUMID-COLD ], + * [ ARID-NEUTRAL, DRY-NEUTRAL, NEUTRAL-NEUTRAL, WET-NEUTRAL, HUMID-NEUTRAL ], + * [ ARID-WARM, DRY-WARM, NEUTRAL-WARM, WET-WARM, HUMID-WARM ], + * [ ARID-HOT, DRY-HOT, NEUTRAL-HOT, WET-HOT, HUMID-HOT ] + * @param middleBiomesVariant - Appearing on terrain ABOVE weirdness 0, here is the "middle_biomes_variant" layout: + * [ ARID-ICY, DRY-ICY, NEUTRAL-ICY, WET-ICY, HUMID-ICY ], + * [ ARID-COLD, DRY-COLD, NEUTRAL-COLD, WET-COLD, HUMID-COLD ], + * [ ARID-NEUTRAL, DRY-NEUTRAL, NEUTRAL-NEUTRAL, WET-NEUTRAL, HUMID-NEUTRAL ], + * [ ARID-WARM, DRY-WARM, NEUTRAL-WARM, WET-WARM, HUMID-WARM ], + * [ ARID-HOT, DRY-HOT, NEUTRAL-HOT, WET-HOT, HUMID-HOT ] + * Null values may be passed in, the equivalent biome at the equivalent temperature/humidity index in the middleBiomes array will be used. + * @param plateauBiomes - Appearing on elevated flat terrain BELOW weirdness 0 or in unfilled("NULL(nothing)") spots in "plateau_biome_variants", here is the "plateau_biomes" layout: + * [ ARID-ICY, DRY-ICY, NEUTRAL-ICY, WET-ICY, HUMID-ICY ], + * [ ARID-COLD, DRY-COLD, NEUTRAL-COLD, WET-COLD, HUMID-COLD ], + * [ ARID-NEUTRAL, DRY-NEUTRAL, NEUTRAL-NEUTRAL, WET-NEUTRAL, HUMID-NEUTRAL ], + * [ ARID-WARM, DRY-WARM, NEUTRAL-WARM, WET-WARM, HUMID-WARM ], + * [ ARID-HOT, DRY-HOT, NEUTRAL-HOT, WET-HOT, HUMID-HOT ] + * @param plateauBiomesVariant - Appearing on elevated flat terrain ABOVE weirdness 0, here is the "plateau_biomes_variant" layout: + * [ ARID-ICY, DRY-ICY, NEUTRAL-ICY, WET-ICY, HUMID-ICY ], + * [ ARID-COLD, DRY-COLD, NEUTRAL-COLD, WET-COLD, HUMID-COLD ], + * [ ARID-NEUTRAL, DRY-NEUTRAL, NEUTRAL-NEUTRAL, WET-NEUTRAL, HUMID-NEUTRAL ], + * [ ARID-WARM, DRY-WARM, NEUTRAL-WARM, WET-WARM, HUMID-WARM ], + * [ ARID-HOT, DRY-HOT, NEUTRAL-HOT, WET-HOT, HUMID-HOT ] + * Null values may be passed in, the equivalent biome at the equivalent temperature/humidity index in the plateauBiomes array will be used. + * @param shatteredBiomes - Appearing on shattered terrain here is the "shattered_biomes" layout: + * [ ARID-ICY, DRY-ICY, NEUTRAL-ICY, WET-ICY, HUMID-ICY ], + * [ ARID-COLD, DRY-COLD, NEUTRAL-COLD, WET-COLD, HUMID-COLD ], + * [ ARID-NEUTRAL, DRY-NEUTRAL, NEUTRAL-NEUTRAL, WET-NEUTRAL, HUMID-NEUTRAL ], + * [ ARID-WARM, DRY-WARM, NEUTRAL-WARM, WET-WARM, HUMID-WARM ], + * [ ARID-HOT, DRY-HOT, NEUTRAL-HOT, WET-HOT, HUMID-HOT ] + * @param beachBiomes - Appearing on terrain bordering oceans, here is the "beach_biomes" layout: + * [ ARID-ICY, DRY-ICY, NEUTRAL-ICY, WET-ICY, HUMID-ICY ], + * [ ARID-COLD, DRY-COLD, NEUTRAL-COLD, WET-COLD, HUMID-COLD ], + * [ ARID-NEUTRAL, DRY-NEUTRAL, NEUTRAL-NEUTRAL, WET-NEUTRAL, HUMID-NEUTRAL ], + * [ ARID-WARM, DRY-WARM, NEUTRAL-WARM, WET-WARM, HUMID-WARM ], + * [ ARID-HOT, DRY-HOT, NEUTRAL-HOT, WET-HOT, HUMID-HOT ] + * @param peakBiomes - Appearing on mountainous terrain & BELOW weirdness 0, here is the "peak_biomes" layout: + * [ ARID-ICY, DRY-ICY, NEUTRAL-ICY, WET-ICY, HUMID-ICY ], + * [ ARID-COLD, DRY-COLD, NEUTRAL-COLD, WET-COLD, HUMID-COLD ], + * [ ARID-NEUTRAL, DRY-NEUTRAL, NEUTRAL-NEUTRAL, WET-NEUTRAL, HUMID-NEUTRAL ], + * [ ARID-WARM, DRY-WARM, NEUTRAL-WARM, WET-WARM, HUMID-WARM ], + * [ ARID-HOT, DRY-HOT, NEUTRAL-HOT, WET-HOT, HUMID-HOT ] + * @param peakBiomesVariant - Appearing on mountainous terrain & ABOVE weirdness 0, here is the "peak_biome_variants" layout: + * [ ARID-ICY, DRY-ICY, NEUTRAL-ICY, WET-ICY, HUMID-ICY ], + * [ ARID-COLD, DRY-COLD, NEUTRAL-COLD, WET-COLD, HUMID-COLD ], + * [ ARID-NEUTRAL, DRY-NEUTRAL, NEUTRAL-NEUTRAL, WET-NEUTRAL, HUMID-NEUTRAL ], + * [ ARID-WARM, DRY-WARM, NEUTRAL-WARM, WET-WARM, HUMID-WARM ], + * [ ARID-HOT, DRY-HOT, NEUTRAL-HOT, WET-HOT, HUMID-HOT ] + * Null values may be passed in, the equivalent biome at the equivalent temperature/humidity index in the peakBiomes array will be used. + * @param slopeBiomes - Appearing on sloped terrain, near mountainous terrain, & BELOW weirdness 0, here is the "slope_biomes" layout: + * [ ARID-ICY, DRY-ICY, NEUTRAL-ICY, WET-ICY, HUMID-ICY ], + * [ ARID-COLD, DRY-COLD, NEUTRAL-COLD, WET-COLD, HUMID-COLD ], + * [ ARID-NEUTRAL, DRY-NEUTRAL, NEUTRAL-NEUTRAL, WET-NEUTRAL, HUMID-NEUTRAL ], + * [ ARID-WARM, DRY-WARM, NEUTRAL-WARM, WET-WARM, HUMID-WARM ], + * [ ARID-HOT, DRY-HOT, NEUTRAL-HOT, WET-HOT, HUMID-HOT ] + * @param slopeBiomesVariant - Appearing on sloped terrain, near mountainous terrain, & ABOVE weirdness 0, here is the "slope_biome_variants" layout: + * [ ARID-ICY, DRY-ICY, NEUTRAL-ICY, WET-ICY, HUMID-ICY ], + * [ ARID-COLD, DRY-COLD, NEUTRAL-COLD, WET-COLD, HUMID-COLD ], + * [ ARID-NEUTRAL, DRY-NEUTRAL, NEUTRAL-NEUTRAL, WET-NEUTRAL, HUMID-NEUTRAL ], + * [ ARID-WARM, DRY-WARM, NEUTRAL-WARM, WET-WARM, HUMID-WARM ], + * [ ARID-HOT, DRY-HOT, NEUTRAL-HOT, WET-HOT, HUMID-HOT ] + * Null values may be passed in, the equivalent biome at the equivalent temperature/humidity index in the slopeBiomes array will be used. + */ + public TerrablenderOverworldBiomeBuilder(ResourceKey[][] oceans, ResourceKey[][] middleBiomes, + ResourceKey[][] middleBiomesVariant, ResourceKey[][] plateauBiomes, + ResourceKey[][] plateauBiomesVariant, ResourceKey[][] shatteredBiomes, + ResourceKey[][] beachBiomes, ResourceKey[][] peakBiomes, + ResourceKey[][] peakBiomesVariant, ResourceKey[][] slopeBiomes, + ResourceKey[][] slopeBiomesVariant) { + this.OCEANS = oceans; + + this.MIDDLE_BIOMES = middleBiomes; + this.MIDDLE_BIOMES_VARIANT = middleBiomesVariant; + + this.PLATEAU_BIOMES = plateauBiomes; + this.PLATEAU_BIOMES_VARIANT = plateauBiomesVariant; + + this.SHATTERED_BIOMES = shatteredBiomes; + + this.beachBiomes = beachBiomes; + + this.peakBiomes = peakBiomes; + this.peakBiomesVariant = peakBiomesVariant; + + this.slopeBiomes = slopeBiomes; + this.slopeBiomesVariant = slopeBiomesVariant; + } + + @Override + public @NotNull ResourceKey pickBeachBiome(int temp, int humidity) { + return beachBiomes[temp][humidity]; + } + + @Override + public @NotNull ResourceKey pickPeakBiome(int temp, int humidity, Climate.Parameter weirdness) { + ResourceKey peakBiome = this.peakBiomes[temp][humidity]; + if (weirdness.max() < 0L) { + return peakBiome; + } else { + ResourceKey peakVariant = peakBiomesVariant[temp][humidity]; + return peakVariant == null ? peakBiome : peakVariant; + } + } + + @Override + public @NotNull ResourceKey pickSlopeBiome(int temp, int humidity, Climate.Parameter weirdness) { + ResourceKey slopeBiome = this.slopeBiomes[temp][humidity]; + if (weirdness.max() < 0L) { + return slopeBiome; + } else { + ResourceKey slopeVariant = slopeBiomesVariant[temp][humidity]; + return slopeVariant == null ? slopeBiome : slopeVariant; + } + } +} diff --git a/Common/src/main/resources/terrablender.accesswidener b/Common/src/main/resources/terrablender.accesswidener index 7fbeaf2..02762b0 100644 --- a/Common/src/main/resources/terrablender.accesswidener +++ b/Common/src/main/resources/terrablender.accesswidener @@ -16,7 +16,34 @@ accessible class net/minecraft/world/level/biome/Climate$DistanceMetric accessible method net/minecraft/world/level/biome/MultiNoiseBiomeSource parameters ()Lnet/minecraft/world/level/biome/Climate$ParameterList; # OverworldBiomeBuilder +accessible class net/minecraft/world/level/biome/OverworldBiomeBuilder +extendable class net/minecraft/world/level/biome/OverworldBiomeBuilder +accessible field net/minecraft/world/level/biome/OverworldBiomeBuilder OCEANS [[Lnet/minecraft/resources/ResourceKey; +accessible field net/minecraft/world/level/biome/OverworldBiomeBuilder MIDDLE_BIOMES [[Lnet/minecraft/resources/ResourceKey; +accessible field net/minecraft/world/level/biome/OverworldBiomeBuilder MIDDLE_BIOMES_VARIANT [[Lnet/minecraft/resources/ResourceKey; +accessible field net/minecraft/world/level/biome/OverworldBiomeBuilder PLATEAU_BIOMES [[Lnet/minecraft/resources/ResourceKey; +accessible field net/minecraft/world/level/biome/OverworldBiomeBuilder PLATEAU_BIOMES_VARIANT [[Lnet/minecraft/resources/ResourceKey; +accessible field net/minecraft/world/level/biome/OverworldBiomeBuilder SHATTERED_BIOMES [[Lnet/minecraft/resources/ResourceKey; +accessible field net/minecraft/world/level/biome/OverworldBiomeBuilder temperatures [Lnet/minecraft/world/level/biome/Climate$Parameter; +accessible field net/minecraft/world/level/biome/OverworldBiomeBuilder humidities [Lnet/minecraft/world/level/biome/Climate$Parameter; +mutable field net/minecraft/world/level/biome/OverworldBiomeBuilder OCEANS [[Lnet/minecraft/resources/ResourceKey; +mutable field net/minecraft/world/level/biome/OverworldBiomeBuilder MIDDLE_BIOMES [[Lnet/minecraft/resources/ResourceKey; +mutable field net/minecraft/world/level/biome/OverworldBiomeBuilder MIDDLE_BIOMES_VARIANT [[Lnet/minecraft/resources/ResourceKey; +mutable field net/minecraft/world/level/biome/OverworldBiomeBuilder PLATEAU_BIOMES [[Lnet/minecraft/resources/ResourceKey; +mutable field net/minecraft/world/level/biome/OverworldBiomeBuilder PLATEAU_BIOMES_VARIANT [[Lnet/minecraft/resources/ResourceKey; +mutable field net/minecraft/world/level/biome/OverworldBiomeBuilder SHATTERED_BIOMES [[Lnet/minecraft/resources/ResourceKey; +accessible field net/minecraft/world/level/biome/OverworldBiomeBuilder FULL_RANGE Lnet/minecraft/world/level/biome/Climate$Parameter; accessible method net/minecraft/world/level/biome/OverworldBiomeBuilder addBiomes (Ljava/util/function/Consumer;)V +accessible method net/minecraft/world/level/biome/OverworldBiomeBuilder pickBeachBiome (II)Lnet/minecraft/resources/ResourceKey; +accessible method net/minecraft/world/level/biome/OverworldBiomeBuilder pickPeakBiome (IILnet/minecraft/world/level/biome/Climate$Parameter;)Lnet/minecraft/resources/ResourceKey; +accessible method net/minecraft/world/level/biome/OverworldBiomeBuilder pickSlopeBiome (IILnet/minecraft/world/level/biome/Climate$Parameter;)Lnet/minecraft/resources/ResourceKey; +extendable method net/minecraft/world/level/biome/OverworldBiomeBuilder pickBeachBiome (II)Lnet/minecraft/resources/ResourceKey; +extendable method net/minecraft/world/level/biome/OverworldBiomeBuilder pickPeakBiome (IILnet/minecraft/world/level/biome/Climate$Parameter;)Lnet/minecraft/resources/ResourceKey; +extendable method net/minecraft/world/level/biome/OverworldBiomeBuilder pickSlopeBiome (IILnet/minecraft/world/level/biome/Climate$Parameter;)Lnet/minecraft/resources/ResourceKey; +accessible method net/minecraft/world/level/biome/OverworldBiomeBuilder addUndergroundBiomes (Ljava/util/function/Consumer;)V +extendable method net/minecraft/world/level/biome/OverworldBiomeBuilder addUndergroundBiomes (Ljava/util/function/Consumer;)V +accessible method net/minecraft/world/level/biome/OverworldBiomeBuilder addUndergroundBiome (Ljava/util/function/Consumer;Lnet/minecraft/world/level/biome/Climate$Parameter;Lnet/minecraft/world/level/biome/Climate$Parameter;Lnet/minecraft/world/level/biome/Climate$Parameter;Lnet/minecraft/world/level/biome/Climate$Parameter;Lnet/minecraft/world/level/biome/Climate$Parameter;FLnet/minecraft/resources/ResourceKey;)V +accessible method net/minecraft/world/level/biome/OverworldBiomeBuilder addBottomBiome (Ljava/util/function/Consumer;Lnet/minecraft/world/level/biome/Climate$Parameter;Lnet/minecraft/world/level/biome/Climate$Parameter;Lnet/minecraft/world/level/biome/Climate$Parameter;Lnet/minecraft/world/level/biome/Climate$Parameter;Lnet/minecraft/world/level/biome/Climate$Parameter;FLnet/minecraft/resources/ResourceKey;)V # SurfaceRules accessible class net/minecraft/world/level/levelgen/SurfaceRules$Context diff --git a/Forge/src/main/resources/META-INF/accesstransformer.cfg b/Forge/src/main/resources/META-INF/accesstransformer.cfg index 986409b..d01891a 100644 --- a/Forge/src/main/resources/META-INF/accesstransformer.cfg +++ b/Forge/src/main/resources/META-INF/accesstransformer.cfg @@ -29,7 +29,10 @@ protected-f net.minecraft.world.level.levelgen.NoiseChunk * public net.minecraft.world.level.biome.MultiNoiseBiomeSource m_274409_()Lnet/minecraft/world/level/biome/Climate$ParameterList; #parameters # OverworldBiomeBuilder -public net.minecraft.world.level.biome.OverworldBiomeBuilder m_187175_(Ljava/util/function/Consumer;)V #addBiomes +public-f net.minecraft.world.level.biome.OverworldBiomeBuilder +public-f net.minecraft.world.level.biome.OverworldBiomeBuilder * +public net.minecraft.world.level.biome.OverworldBiomeBuilder *() + # SurfaceRules public-f net.minecraft.world.level.levelgen.SurfaceRules$Context diff --git a/NeoForge/src/main/resources/META-INF/accesstransformer.cfg b/NeoForge/src/main/resources/META-INF/accesstransformer.cfg index 650ef21..bd6da91 100644 --- a/NeoForge/src/main/resources/META-INF/accesstransformer.cfg +++ b/NeoForge/src/main/resources/META-INF/accesstransformer.cfg @@ -29,7 +29,11 @@ protected-f net.minecraft.world.level.levelgen.NoiseChunk * public net.minecraft.world.level.biome.MultiNoiseBiomeSource parameters()Lnet/minecraft/world/level/biome/Climate$ParameterList; #parameters # OverworldBiomeBuilder -public net.minecraft.world.level.biome.OverworldBiomeBuilder addBiomes(Ljava/util/function/Consumer;)V #addBiomes +public-f net.minecraft.world.level.biome.OverworldBiomeBuilder +public-f net.minecraft.world.level.biome.OverworldBiomeBuilder + +public-f net.minecraft.world.level.biome.OverworldBiomeBuilder * +public net.minecraft.world.level.biome.OverworldBiomeBuilder *() # SurfaceRules public-f net.minecraft.world.level.levelgen.SurfaceRules$Context