Compiles
This commit is contained in:
parent
5441279e4c
commit
045c804f14
56 changed files with 504 additions and 403 deletions
|
@ -7,7 +7,7 @@ mod_version=12.0.0
|
|||
|
||||
minecraft_version=1.16.2
|
||||
minecraft_version_toml=16
|
||||
forge_version=33.0.7
|
||||
forge_version=33.0.37
|
||||
forge_version_toml=33
|
||||
forge_group=net.minecraftforge
|
||||
mappings_version=2-1.16.2
|
||||
|
|
|
@ -7,80 +7,88 @@
|
|||
******************************************************************************/
|
||||
package biomesoplenty.api.biome;
|
||||
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class BOPBiomes
|
||||
{
|
||||
public static Optional<Biome> alps = Optional.empty();
|
||||
public static Optional<Biome> alps_foothills = Optional.empty();
|
||||
public static Optional<Biome> bayou = Optional.empty();
|
||||
public static Optional<Biome> bog = Optional.empty();
|
||||
public static Optional<Biome> boreal_forest = Optional.empty();
|
||||
public static Optional<Biome> brushland = Optional.empty();
|
||||
public static Optional<Biome> chaparral = Optional.empty();
|
||||
public static Optional<Biome> cherry_blossom_grove = Optional.empty();
|
||||
public static Optional<Biome> cold_desert = Optional.empty();
|
||||
public static Optional<Biome> coniferous_forest = Optional.empty();
|
||||
public static Optional<Biome> dead_forest = Optional.empty();
|
||||
public static Optional<Biome> fir_clearing = Optional.empty();
|
||||
public static Optional<Biome> floodplain = Optional.empty();
|
||||
public static Optional<Biome> flower_meadow = Optional.empty();
|
||||
public static Optional<Biome> fungal_jungle = Optional.empty();
|
||||
public static Optional<Biome> grassland = Optional.empty();
|
||||
public static Optional<Biome> gravel_beach = Optional.empty();
|
||||
public static Optional<Biome> grove = Optional.empty();
|
||||
public static Optional<Biome> highland = Optional.empty();
|
||||
public static Optional<Biome> highland_moor = Optional.empty();
|
||||
public static Optional<Biome> lavender_field = Optional.empty();
|
||||
public static Optional<Biome> lush_grassland = Optional.empty();
|
||||
public static Optional<Biome> lush_swamp = Optional.empty();
|
||||
public static Optional<Biome> mangrove = Optional.empty();
|
||||
public static Optional<Biome> maple_woods = Optional.empty();
|
||||
public static Optional<Biome> marsh = Optional.empty();
|
||||
public static Optional<Biome> meadow = Optional.empty();
|
||||
public static Optional<Biome> mire = Optional.empty();
|
||||
public static Optional<Biome> muskeg = Optional.empty();
|
||||
public static Optional<Biome> mystic_grove = Optional.empty();
|
||||
public static Optional<Biome> oasis = Optional.empty();
|
||||
public static Optional<Biome> ominous_woods = Optional.empty();
|
||||
public static Optional<Biome> orchard = Optional.empty();
|
||||
public static Optional<Biome> origin_hills = Optional.empty();
|
||||
public static Optional<Biome> outback = Optional.empty();
|
||||
public static Optional<Biome> overgrown_cliffs = Optional.empty();
|
||||
public static Optional<Biome> pasture = Optional.empty();
|
||||
public static Optional<Biome> poppy_field = Optional.empty();
|
||||
public static Optional<Biome> prairie = Optional.empty();
|
||||
public static Optional<Biome> pumpkin_patch = Optional.empty();
|
||||
public static Optional<Biome> rainbow_valley = Optional.empty();
|
||||
public static Optional<Biome> rainforest = Optional.empty();
|
||||
public static Optional<Biome> redwood_forest = Optional.empty();
|
||||
public static Optional<Biome> redwood_forest_edge = Optional.empty();
|
||||
public static Optional<Biome> scrubland = Optional.empty();
|
||||
public static Optional<Biome> seasonal_forest = Optional.empty();
|
||||
public static Optional<Biome> shield = Optional.empty();
|
||||
public static Optional<Biome> shrubland = Optional.empty();
|
||||
public static Optional<Biome> silkglade = Optional.empty();
|
||||
public static Optional<Biome> snowy_coniferous_forest = Optional.empty();
|
||||
public static Optional<Biome> snowy_fir_clearing = Optional.empty();
|
||||
public static Optional<Biome> snowy_forest = Optional.empty();
|
||||
public static Optional<Biome> steppe = Optional.empty();
|
||||
public static Optional<Biome> temperate_rainforest = Optional.empty();
|
||||
public static Optional<Biome> temperate_rainforest_hills = Optional.empty();
|
||||
public static Optional<Biome> tropical_rainforest = Optional.empty();
|
||||
public static Optional<Biome> tropic_beach = Optional.empty();
|
||||
public static Optional<Biome> tropics = Optional.empty();
|
||||
public static Optional<Biome> tundra = Optional.empty();
|
||||
public static Optional<Biome> volcanic_plains = Optional.empty();
|
||||
public static Optional<Biome> volcano = Optional.empty();
|
||||
public static Optional<Biome> wasteland = Optional.empty();
|
||||
public static Optional<Biome> wetland = Optional.empty();
|
||||
public static Optional<Biome> woodland = Optional.empty();
|
||||
public static Optional<Biome> xeric_shrubland = Optional.empty();
|
||||
public static RegistryKey<Biome> alps = register("alps");
|
||||
public static RegistryKey<Biome> alps_foothills = register("alps_foothills");
|
||||
public static RegistryKey<Biome> bayou = register("bayou");
|
||||
public static RegistryKey<Biome> bog = register("bog");
|
||||
public static RegistryKey<Biome> boreal_forest = register("boreal_forest");
|
||||
public static RegistryKey<Biome> brushland = register("brushland");
|
||||
public static RegistryKey<Biome> chaparral = register("chaparral");
|
||||
public static RegistryKey<Biome> cherry_blossom_grove = register("cherry_blossom_grove");
|
||||
public static RegistryKey<Biome> cold_desert = register("cold_desert");
|
||||
public static RegistryKey<Biome> coniferous_forest = register("coniferous_forest");
|
||||
public static RegistryKey<Biome> dead_forest = register("dead_forest");
|
||||
public static RegistryKey<Biome> fir_clearing = register("fir_clearing");
|
||||
public static RegistryKey<Biome> floodplain = register("floodplain");
|
||||
public static RegistryKey<Biome> flower_meadow = register("flower_meadow");
|
||||
public static RegistryKey<Biome> fungal_jungle = register("fungal_jungle");
|
||||
public static RegistryKey<Biome> grassland = register("grassland");
|
||||
public static RegistryKey<Biome> gravel_beach = register("gravel_beach");
|
||||
public static RegistryKey<Biome> grove = register("grove");
|
||||
public static RegistryKey<Biome> highland = register("highland");
|
||||
public static RegistryKey<Biome> highland_moor = register("highland_moor");
|
||||
public static RegistryKey<Biome> lavender_field = register("lavender_field");
|
||||
public static RegistryKey<Biome> lush_grassland = register("lush_grassland");
|
||||
public static RegistryKey<Biome> lush_swamp = register("lush_swamp");
|
||||
public static RegistryKey<Biome> mangrove = register("mangrove");
|
||||
public static RegistryKey<Biome> maple_woods = register("maple_woods");
|
||||
public static RegistryKey<Biome> marsh = register("marsh");
|
||||
public static RegistryKey<Biome> meadow = register("meadow");
|
||||
public static RegistryKey<Biome> mire = register("mire");
|
||||
public static RegistryKey<Biome> muskeg = register("muskeg");
|
||||
public static RegistryKey<Biome> mystic_grove = register("mystic_grove");
|
||||
public static RegistryKey<Biome> oasis = register("oasis");
|
||||
public static RegistryKey<Biome> ominous_woods = register("ominous_woods");
|
||||
public static RegistryKey<Biome> orchard = register("orchard");
|
||||
public static RegistryKey<Biome> origin_hills = register("origin_hills");
|
||||
public static RegistryKey<Biome> outback = register("outback");
|
||||
public static RegistryKey<Biome> overgrown_cliffs = register("overgrown_cliffs");
|
||||
public static RegistryKey<Biome> pasture = register("pasture");
|
||||
public static RegistryKey<Biome> poppy_field = register("poppy_field");
|
||||
public static RegistryKey<Biome> prairie = register("prairie");
|
||||
public static RegistryKey<Biome> pumpkin_patch = register("pumpkin_patch");
|
||||
public static RegistryKey<Biome> rainbow_valley = register("rainbow_valley");
|
||||
public static RegistryKey<Biome> rainforest = register("rainforest");
|
||||
public static RegistryKey<Biome> redwood_forest = register("redwood_forest");
|
||||
public static RegistryKey<Biome> redwood_forest_edge = register("redwood_forest_edge");
|
||||
public static RegistryKey<Biome> scrubland = register("scrubland");
|
||||
public static RegistryKey<Biome> seasonal_forest = register("seasonal_forest");
|
||||
public static RegistryKey<Biome> shield = register("shield");
|
||||
public static RegistryKey<Biome> shrubland = register("shrubland");
|
||||
public static RegistryKey<Biome> silkglade = register("silkglade");
|
||||
public static RegistryKey<Biome> snowy_coniferous_forest = register("snowy_coniferous_forest");
|
||||
public static RegistryKey<Biome> snowy_fir_clearing = register("snowy_fir_clearing");
|
||||
public static RegistryKey<Biome> snowy_forest = register("snowy_forest");
|
||||
public static RegistryKey<Biome> steppe = register("steppe");
|
||||
public static RegistryKey<Biome> temperate_rainforest = register("temperate_rainforest");
|
||||
public static RegistryKey<Biome> temperate_rainforest_hills = register("temperate_rainforest_hills");
|
||||
public static RegistryKey<Biome> tropical_rainforest = register("tropical_rainforest");
|
||||
public static RegistryKey<Biome> tropic_beach = register("tropic_beach");
|
||||
public static RegistryKey<Biome> tropics = register("tropics");
|
||||
public static RegistryKey<Biome> tundra = register("tundra");
|
||||
public static RegistryKey<Biome> volcanic_plains = register("volcanic_plains");
|
||||
public static RegistryKey<Biome> volcano = register("volcano");
|
||||
public static RegistryKey<Biome> wasteland = register("wasteland");
|
||||
public static RegistryKey<Biome> wetland = register("wetland");
|
||||
public static RegistryKey<Biome> woodland = register("woodland");
|
||||
public static RegistryKey<Biome> xeric_shrubland = register("xeric_shrubland");
|
||||
|
||||
public static Optional<Biome> crystalline_chasm = Optional.empty();
|
||||
public static Optional<Biome> undergrowth = Optional.empty();
|
||||
public static Optional<Biome> visceral_heap = Optional.empty();
|
||||
public static Optional<Biome> withered_abyss = Optional.empty();
|
||||
public static RegistryKey<Biome> crystalline_chasm = register("crystalline_chasm");
|
||||
public static RegistryKey<Biome> undergrowth = register("undergrowth");
|
||||
public static RegistryKey<Biome> visceral_heap = register("visceral_heap");
|
||||
public static RegistryKey<Biome> withered_abyss = register("withered_abyss");
|
||||
|
||||
private static RegistryKey<Biome> register(String name)
|
||||
{
|
||||
return RegistryKey.create(Registry.BIOME_REGISTRY, new ResourceLocation(name));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
package biomesoplenty.api.enums;
|
||||
|
||||
import biomesoplenty.api.biome.BOPBiomes;
|
||||
import biomesoplenty.common.util.biome.BiomeUtil;
|
||||
import biomesoplenty.init.ModBiomes;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -59,7 +60,7 @@ public enum BOPClimates
|
|||
return this;
|
||||
}
|
||||
|
||||
public BOPClimates addIslandBiome(int weight, Biome biome)
|
||||
public BOPClimates addIslandBiome(int weight, RegistryKey<Biome> biome)
|
||||
{
|
||||
return this.addIslandBiome(new WeightedBiomeEntry(weight, biome));
|
||||
}
|
||||
|
@ -71,7 +72,7 @@ public enum BOPClimates
|
|||
return this;
|
||||
}
|
||||
|
||||
public Biome getRandomBiome(INoiseRandom context, Biome fallback)
|
||||
public RegistryKey<Biome> getRandomBiome(INoiseRandom context, RegistryKey<Biome> fallback)
|
||||
{
|
||||
if (this.totalBiomesWeight == 0)
|
||||
return fallback;
|
||||
|
@ -88,7 +89,7 @@ public enum BOPClimates
|
|||
return item.biome;
|
||||
}
|
||||
|
||||
public Biome getRandomIslandBiome(INoiseRandom context, Biome fallback)
|
||||
public RegistryKey<Biome> getRandomIslandBiome(INoiseRandom context, RegistryKey<Biome> fallback)
|
||||
{
|
||||
if (this.totalIslandBiomesWeight == 0)
|
||||
return fallback;
|
||||
|
@ -156,9 +157,9 @@ public enum BOPClimates
|
|||
return out;
|
||||
}
|
||||
|
||||
public static ImmutableSet<Biome> getOverworldBiomes()
|
||||
public static ImmutableSet<RegistryKey<Biome>> getOverworldBiomes()
|
||||
{
|
||||
Set<Biome> set = Sets.newHashSet();
|
||||
Set<RegistryKey<Biome>> set = Sets.newHashSet();
|
||||
|
||||
for (BOPClimates climate : BOPClimates.values())
|
||||
{
|
||||
|
@ -178,9 +179,9 @@ public enum BOPClimates
|
|||
public static class WeightedBiomeEntry
|
||||
{
|
||||
public final int weight;
|
||||
public final Biome biome;
|
||||
public final RegistryKey<Biome> biome;
|
||||
|
||||
public WeightedBiomeEntry(int weight, Biome biome)
|
||||
public WeightedBiomeEntry(int weight, RegistryKey<Biome> biome)
|
||||
{
|
||||
this.weight = weight;
|
||||
this.biome = biome;
|
||||
|
@ -194,7 +195,7 @@ public enum BOPClimates
|
|||
{
|
||||
for (WeightedBiomeEntry entry : climate.landBiomes)
|
||||
{
|
||||
System.out.println(climate.name()+" "+entry.biome.getName()+" "+entry.weight);
|
||||
System.out.println(climate.name()+" "+entry.biome.getRegistryName()+" "+entry.weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.gui.screen.*;
|
||||
import net.minecraft.command.Commands;
|
||||
import net.minecraft.resources.*;
|
||||
import net.minecraft.server.IDynamicRegistries;
|
||||
import net.minecraft.util.datafix.codec.DatapackCodec;
|
||||
import net.minecraft.util.registry.DynamicRegistries;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.gen.settings.DimensionGeneratorSettings;
|
||||
|
@ -135,7 +135,7 @@ public class GuiEventHandler
|
|||
try
|
||||
(
|
||||
SaveFormat.LevelSave save = mc.getLevelSource().createAccess(levelId);
|
||||
Minecraft.PackManager packManager = createPackManager(IDynamicRegistries.builtin(), Minecraft::loadDataPacks, Minecraft::loadWorldData, save);
|
||||
Minecraft.PackManager packManager = createPackManager(DynamicRegistries.builtin(), Minecraft::loadDataPacks, Minecraft::loadWorldData, save);
|
||||
)
|
||||
{
|
||||
DimensionGeneratorSettings settings = packManager.worldData().worldGenSettings();
|
||||
|
@ -148,10 +148,10 @@ public class GuiEventHandler
|
|||
}
|
||||
}
|
||||
|
||||
private static Minecraft.PackManager createPackManager(IDynamicRegistries.Impl registries, Function<SaveFormat.LevelSave, DatapackCodec> dataPackLoader, Function4<SaveFormat.LevelSave, IDynamicRegistries.Impl, IResourceManager, DatapackCodec, IServerConfiguration> worldDataLoader, SaveFormat.LevelSave save)
|
||||
private static Minecraft.PackManager createPackManager(DynamicRegistries.Impl registries, Function<SaveFormat.LevelSave, DatapackCodec> dataPackLoader, Function4<SaveFormat.LevelSave, DynamicRegistries.Impl, IResourceManager, DatapackCodec, IServerConfiguration> worldDataLoader, SaveFormat.LevelSave save)
|
||||
{
|
||||
DatapackCodec dataPackCodec = dataPackLoader.apply(save);
|
||||
ResourcePackList<ResourcePackInfo> resourcePackList = new ResourcePackList<>(ResourcePackInfo::new, new ServerPackFinder(), new FolderPackFinder(save.getLevelPath(FolderName.DATAPACK_DIR).toFile(), IPackNameDecorator.WORLD));
|
||||
ResourcePackList resourcePackList = new ResourcePackList(ResourcePackInfo::new, new ServerPackFinder(), new FolderPackFinder(save.getLevelPath(FolderName.DATAPACK_DIR).toFile(), IPackNameDecorator.WORLD));
|
||||
DataPackRegistries dataPackRegistries = new DataPackRegistries(Commands.EnvironmentType.INTEGRATED, 2);
|
||||
IServerConfiguration serverConfiguration = worldDataLoader.apply(save, registries, dataPackRegistries.getResourceManager(), dataPackCodec);
|
||||
return new Minecraft.PackManager(resourcePackList, dataPackRegistries, serverConfiguration);
|
||||
|
|
59
src/main/java/biomesoplenty/common/biome/BiomeMetadata.java
Normal file
59
src/main/java/biomesoplenty/common/biome/BiomeMetadata.java
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2020, the Biomes O' Plenty Team
|
||||
*
|
||||
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
|
||||
*
|
||||
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
|
||||
******************************************************************************/
|
||||
package biomesoplenty.common.biome;
|
||||
|
||||
import biomesoplenty.api.enums.BOPClimates;
|
||||
import biomesoplenty.common.util.biome.BiomeUtil;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.Biomes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BiomeMetadata
|
||||
{
|
||||
private final ImmutableMap<BOPClimates, Integer> weightMap;
|
||||
|
||||
@Nullable
|
||||
private final RegistryKey<Biome> beachBiome;
|
||||
|
||||
@Nullable
|
||||
private final RegistryKey<Biome> riverBiome;
|
||||
|
||||
protected BiomeMetadata(Map<BOPClimates, Integer> weights, @Nullable RegistryKey<Biome> beachBiome, @Nullable RegistryKey<Biome> riverBiome)
|
||||
{
|
||||
this.weightMap = ImmutableMap.copyOf(weights);
|
||||
this.beachBiome = beachBiome;
|
||||
this.riverBiome = riverBiome;
|
||||
}
|
||||
|
||||
public Map<BOPClimates, Integer> getWeightMap()
|
||||
{
|
||||
return this.weightMap;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public RegistryKey<Biome> getBeachBiome()
|
||||
{
|
||||
return this.beachBiome;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public RegistryKey<Biome> getRiverBiome()
|
||||
{
|
||||
return this.riverBiome;
|
||||
}
|
||||
|
||||
public boolean hasWeights()
|
||||
{
|
||||
return !this.weightMap.isEmpty() && !this.weightMap.entrySet().stream().allMatch((entry) -> entry.getValue().equals(0));
|
||||
}
|
||||
}
|
|
@ -18,14 +18,14 @@ import com.google.common.collect.Lists;
|
|||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.common.BiomeManager;
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
@ -48,19 +48,29 @@ public class BiomeRegistry
|
|||
defer(RegistrationType.TECHNICAL_BIOME, new ToggleableStandardBiomeRegistrationData(biome, name, true));
|
||||
}
|
||||
|
||||
public static void deferSubBiomeRegistration(Biome parent, Biome child, int weight, float rarity)
|
||||
public static void deferSubBiomeRegistration(RegistryKey<Biome> parent, RegistryKey<Biome> child, int weight, float rarity)
|
||||
{
|
||||
// Don't register sub biome if the parent or child don't exist
|
||||
if (!BiomeUtil.exists(parent) || !BiomeUtil.exists(child))
|
||||
return;
|
||||
|
||||
defer(RegistrationType.SUB_BIOME, new SubBiomeRegistrationData(parent, child, weight, rarity));
|
||||
}
|
||||
|
||||
public static void deferIslandBiomeRegistration(Biome biome, BOPClimates climate, int weight)
|
||||
public static void deferIslandBiomeRegistration(RegistryKey<Biome> key, BOPClimates climate, int weight)
|
||||
{
|
||||
defer(RegistrationType.ISLAND_BIOME, new SingleClimateRegistrationData(biome, climate, weight));
|
||||
if (!BiomeUtil.exists(key))
|
||||
return;
|
||||
|
||||
defer(RegistrationType.ISLAND_BIOME, new SingleClimateRegistrationData(key, climate, weight));
|
||||
}
|
||||
|
||||
public static void deferVanillaBiomeRegistration(Biome biome, BOPClimates climate, int weight)
|
||||
public static void deferVanillaBiomeRegistration(RegistryKey<Biome> key, BOPClimates climate, int weight)
|
||||
{
|
||||
defer(RegistrationType.VANILLA_BIOME, new SingleClimateRegistrationData(biome, climate, weight));
|
||||
if (!BiomeUtil.exists(key))
|
||||
return;
|
||||
|
||||
defer(RegistrationType.VANILLA_BIOME, new SingleClimateRegistrationData(key, climate, weight));
|
||||
}
|
||||
|
||||
public static void configureStandardBiomes()
|
||||
|
@ -74,7 +84,7 @@ public class BiomeRegistry
|
|||
StandardBiomeRegistrationData regData = registration.regData;
|
||||
|
||||
// Ignore biomes which don't have any weights set by default
|
||||
if (((BiomeTemplate)regData.getBiome()).hasWeights())
|
||||
if (regData.getMetadata().hasWeights())
|
||||
{
|
||||
String biomeName = new ResourceLocation(BiomesOPlenty.MOD_ID, regData.getName()).toString();
|
||||
Pair<BOPClimates, Integer> primaryWeight = regData.getPrimaryWeight();
|
||||
|
@ -173,7 +183,7 @@ public class BiomeRegistry
|
|||
for (DeferredRegistration<SubBiomeRegistrationData> registration : subBiomeRegistrations)
|
||||
{
|
||||
SubBiomeRegistrationData regData = registration.regData;
|
||||
String biomeName = registration.regData.getChild().delegate.name().toString();
|
||||
String biomeName = registration.regData.getChild().getRegistryName().toString();
|
||||
defaultSubBiomeEntries.put(biomeName, new BiomeConfigData.SubBiomeEntry(regData.getWeight(), regData.getRarity()));
|
||||
regDataMap.put(biomeName, registration.regData);
|
||||
}
|
||||
|
@ -220,7 +230,7 @@ public class BiomeRegistry
|
|||
for (DeferredRegistration<SingleClimateRegistrationData> registration : biomeRegistrations)
|
||||
{
|
||||
SingleClimateRegistrationData regData = registration.regData;
|
||||
String biomeName = regData.getBiome().delegate.name().toString();
|
||||
String biomeName = regData.getBiome().getRegistryName().toString();
|
||||
defaultBiomeEntries.put(biomeName, new BiomeConfigData.ToggleableBiomeEntry(true));
|
||||
}
|
||||
|
||||
|
@ -246,7 +256,7 @@ public class BiomeRegistry
|
|||
for (DeferredRegistration<SingleClimateRegistrationData> registration : biomeRegistrations)
|
||||
{
|
||||
SingleClimateRegistrationData regData = registration.regData;
|
||||
String biomeName = regData.getBiome().delegate.name().toString();
|
||||
String biomeName = regData.getBiome().getRegistryName().toString();
|
||||
|
||||
if (revisedBiomeEntries.containsKey(biomeName))
|
||||
{
|
||||
|
@ -269,7 +279,7 @@ public class BiomeRegistry
|
|||
for (DeferredRegistration<SingleClimateRegistrationData> registration : biomeRegistrations)
|
||||
{
|
||||
SingleClimateRegistrationData regData = registration.regData;
|
||||
String biomeName = registration.regData.getBiome().delegate.name().toString();
|
||||
String biomeName = registration.regData.getBiome().getRegistryName().toString();
|
||||
defaultBiomeEntries.put(biomeName, new BiomeConfigData.WeightedBiomeEntry(regData.getWeight()));
|
||||
regDataMap.put(biomeName, registration.regData);
|
||||
}
|
||||
|
@ -325,7 +335,7 @@ public class BiomeRegistry
|
|||
return configData;
|
||||
}
|
||||
|
||||
private static <T extends RegistrationData> void defer(RegistrationType type, T data)
|
||||
private static <T extends IRegistrationData> void defer(RegistrationType type, T data)
|
||||
{
|
||||
if (!deferrances.containsKey(type))
|
||||
deferrances.put(type, Lists.newArrayList());
|
||||
|
@ -341,12 +351,12 @@ public class BiomeRegistry
|
|||
|
||||
if (type == RegistrationType.SUB_BIOME)
|
||||
{
|
||||
Set<Biome> children = Sets.newHashSet();
|
||||
Set<RegistryKey<Biome>> children = Sets.newHashSet();
|
||||
deferrances.get(RegistrationType.SUB_BIOME).forEach((reg) -> {
|
||||
Biome biome = ((SubBiomeRegistrationData)reg.regData).getChild();
|
||||
RegistryKey<Biome> biome = ((SubBiomeRegistrationData)reg.regData).getChild();
|
||||
if (children.contains(biome))
|
||||
{
|
||||
throw new RuntimeException(String.format("Sub biome %s cannot be added to multiple parents", biome.delegate.name().toString()));
|
||||
throw new RuntimeException(String.format("Sub biome %s cannot be added to multiple parents", biome.getRegistryName().toString()));
|
||||
}
|
||||
children.add(biome);
|
||||
});
|
||||
|
@ -362,11 +372,12 @@ public class BiomeRegistry
|
|||
public enum RegistrationType
|
||||
{
|
||||
STANDARD_BIOME((StandardBiomeRegistrationData data) -> {
|
||||
BiomeTemplate biome = (BiomeTemplate)data.getBiome();
|
||||
Biome biome = data.getBiome();
|
||||
BiomeMetadata metadata = data.getMetadata();
|
||||
String name = data.getName();
|
||||
|
||||
// Don't register biomes with their weight set to 0, that normally have weights that are non-zero
|
||||
if (!biome.getWeightMap().isEmpty() && (data.weightMap.isEmpty() || data.weightMap.entrySet().stream().allMatch((entry) -> entry.getValue().equals(0))))
|
||||
if (!metadata.getWeightMap().isEmpty() && (data.weightMap.isEmpty() || data.weightMap.entrySet().stream().allMatch((entry) -> entry.getValue().equals(0))))
|
||||
{
|
||||
BiomesOPlenty.logger.debug("Weights absent for " + data.getName() + ", disabling...");
|
||||
return;
|
||||
|
@ -375,11 +386,6 @@ public class BiomeRegistry
|
|||
biome.setRegistryName(name);
|
||||
ForgeRegistries.BIOMES.register(biome);
|
||||
|
||||
if (biome.canSpawnInBiome)
|
||||
{
|
||||
BiomeManager.addSpawnBiome(biome);
|
||||
}
|
||||
|
||||
for (Map.Entry<BOPClimates, Integer> entry : data.getWeights().entrySet())
|
||||
{
|
||||
if (entry != null && entry.getValue() > 0)
|
||||
|
@ -387,22 +393,17 @@ public class BiomeRegistry
|
|||
BOPClimates climate = entry.getKey();
|
||||
int weight = entry.getValue();
|
||||
BiomesOPlenty.logger.debug(String.format("%s weight set to %d for climate %s", name, weight, climate.name()));
|
||||
climate.addBiome(weight, biome);
|
||||
climate.addBiome(weight, BiomeUtil.createKey(data.getBiome()));
|
||||
}
|
||||
}
|
||||
|
||||
// Set field in BOPBiomes
|
||||
try
|
||||
if (data.getMetadata() != null)
|
||||
{
|
||||
BOPBiomes.class.getField(name).set(null, Optional.of(biome));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException("Failed to set biome field " + name, e);
|
||||
ModBiomes.biomeMetadata.put(BiomeUtil.createKey(data.getBiome()), data.getMetadata());
|
||||
}
|
||||
}),
|
||||
TECHNICAL_BIOME((ToggleableStandardBiomeRegistrationData data) -> {
|
||||
BiomeTemplate biome = (BiomeTemplate)data.getBiome();
|
||||
Biome biome = data.getBiome();
|
||||
String name = data.getName();
|
||||
|
||||
if (!data.getEnabled())
|
||||
|
@ -414,40 +415,30 @@ public class BiomeRegistry
|
|||
biome.setRegistryName(name);
|
||||
ForgeRegistries.BIOMES.register(biome);
|
||||
|
||||
if (biome.canSpawnInBiome)
|
||||
if (data.getMetadata() != null)
|
||||
{
|
||||
BiomeManager.addSpawnBiome(biome);
|
||||
}
|
||||
|
||||
// Set field in BOPBiomes
|
||||
try
|
||||
{
|
||||
BOPBiomes.class.getField(name).set(null, Optional.of(biome));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException("Failed to set biome field " + name, e);
|
||||
ModBiomes.biomeMetadata.put(BiomeUtil.createKey(data.getBiome()), data.getMetadata());
|
||||
}
|
||||
}),
|
||||
SUB_BIOME((SubBiomeRegistrationData data) -> {
|
||||
if (data.getWeight() == 0)
|
||||
{
|
||||
BiomesOPlenty.logger.debug("Weights absent for sub biome" + data.getChild().getName() + ", disabling...");
|
||||
BiomesOPlenty.logger.debug("Weights absent for sub biome" + data.getChild().getRegistryName().toString() + ", disabling...");
|
||||
return;
|
||||
}
|
||||
|
||||
String childName = data.getChild().delegate.name().toString();
|
||||
String childName = data.getChild().getRegistryName().toString();
|
||||
BiomesOPlenty.logger.debug(String.format("Sub biome %s weight set to %d", childName, data.getWeight()));
|
||||
ModBiomes.subBiomes.put(BiomeUtil.getBiomeId(data.getParent()), new ModBiomes.WeightedSubBiome(data.getChild(), data.getRarity(), data.getWeight()));
|
||||
}),
|
||||
ISLAND_BIOME((SingleClimateRegistrationData data) -> {
|
||||
if (data.getWeight() == 0)
|
||||
{
|
||||
BiomesOPlenty.logger.debug("Weights absent for island biome" + data.getBiome().getName() + ", disabling...");
|
||||
BiomesOPlenty.logger.debug("Weights absent for island biome" + data.getBiome().getRegistryName().toString() + ", disabling...");
|
||||
return;
|
||||
}
|
||||
|
||||
String biomeName = data.getBiome().delegate.name().toString();
|
||||
String biomeName = data.getBiome().getRegistryName().toString();
|
||||
BiomesOPlenty.logger.debug(String.format("Island biome %s weight set to %d for climate %s", biomeName, data.getWeight(), data.getClimate().name()));
|
||||
ModBiomes.islandBiomeIds.add(BiomeUtil.getBiomeId(data.getBiome()));
|
||||
data.getClimate().addIslandBiome(data.getWeight(), data.getBiome());
|
||||
|
@ -455,37 +446,56 @@ public class BiomeRegistry
|
|||
VANILLA_BIOME((SingleClimateRegistrationData data) -> {
|
||||
if (data.getWeight() == 0)
|
||||
{
|
||||
BiomesOPlenty.logger.debug("Weights absent for vanilla biome" + data.getBiome().getName() + ", disabling...");
|
||||
BiomesOPlenty.logger.debug("Weights absent for vanilla biome" + data.getBiome().getRegistryName().toString() + ", disabling...");
|
||||
return;
|
||||
}
|
||||
|
||||
data.getClimate().addBiome(data.getWeight(), data.getBiome());
|
||||
});
|
||||
|
||||
public final Consumer<? extends RegistrationData> regFunc;
|
||||
public final Consumer<? extends IRegistrationData> regFunc;
|
||||
|
||||
RegistrationType(Consumer<? extends RegistrationData> regFunc)
|
||||
RegistrationType(Consumer<? extends IRegistrationData> regFunc)
|
||||
{
|
||||
this.regFunc = regFunc;
|
||||
}
|
||||
}
|
||||
|
||||
private static abstract class RegistrationData
|
||||
private interface IRegistrationData
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private static abstract class TemplateRegistrationData implements IRegistrationData
|
||||
{
|
||||
private final Biome biome;
|
||||
private final BiomeMetadata metadata;
|
||||
|
||||
public RegistrationData(Biome biome)
|
||||
public TemplateRegistrationData(BiomeTemplate template)
|
||||
{
|
||||
this.biome = template.build();
|
||||
this.metadata = template.buildMetadata();
|
||||
}
|
||||
|
||||
public TemplateRegistrationData(Biome biome)
|
||||
{
|
||||
this.biome = biome;
|
||||
this.metadata = null;
|
||||
}
|
||||
|
||||
public Biome getBiome()
|
||||
{
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BiomeMetadata getMetadata()
|
||||
{
|
||||
return this.metadata;
|
||||
}
|
||||
}
|
||||
|
||||
private static class StandardBiomeRegistrationData extends RegistrationData
|
||||
private static class StandardBiomeRegistrationData extends TemplateRegistrationData
|
||||
{
|
||||
private final String name;
|
||||
private Map<BOPClimates, Integer> weightMap;
|
||||
|
@ -494,7 +504,7 @@ public class BiomeRegistry
|
|||
{
|
||||
super(biome);
|
||||
this.name = name;
|
||||
this.weightMap = Maps.newHashMap(biome.getWeightMap());
|
||||
this.weightMap = Maps.newHashMap(this.getMetadata().getWeightMap());
|
||||
this.ensureSingleWeight();
|
||||
}
|
||||
|
||||
|
@ -542,28 +552,29 @@ public class BiomeRegistry
|
|||
}
|
||||
}
|
||||
|
||||
private static class SubBiomeRegistrationData extends RegistrationData
|
||||
private static class SubBiomeRegistrationData implements IRegistrationData
|
||||
{
|
||||
private final Biome parent;
|
||||
private final RegistryKey<Biome> parent;
|
||||
private final RegistryKey<Biome> child;
|
||||
private int weight;
|
||||
private float rarity;
|
||||
|
||||
public SubBiomeRegistrationData(Biome parent, Biome child, int weight, float rarity)
|
||||
public SubBiomeRegistrationData(RegistryKey<Biome> parent, RegistryKey<Biome> child, int weight, float rarity)
|
||||
{
|
||||
super(child);
|
||||
this.parent = parent;
|
||||
this.child = child;
|
||||
this.weight = weight;
|
||||
this.rarity = rarity;
|
||||
}
|
||||
|
||||
public Biome getParent()
|
||||
public RegistryKey<Biome> getParent()
|
||||
{
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
public Biome getChild()
|
||||
public RegistryKey<Biome> getChild()
|
||||
{
|
||||
return this.getBiome();
|
||||
return this.child;
|
||||
}
|
||||
|
||||
public int getWeight()
|
||||
|
@ -587,18 +598,24 @@ public class BiomeRegistry
|
|||
}
|
||||
}
|
||||
|
||||
private static class SingleClimateRegistrationData extends RegistrationData
|
||||
private static class SingleClimateRegistrationData implements IRegistrationData
|
||||
{
|
||||
private final BOPClimates climate;
|
||||
private final RegistryKey<Biome> biome;
|
||||
private int weight;
|
||||
|
||||
public SingleClimateRegistrationData(Biome biome, BOPClimates climate, int weight)
|
||||
public SingleClimateRegistrationData(RegistryKey<Biome> biome, BOPClimates climate, int weight)
|
||||
{
|
||||
super(biome);
|
||||
this.biome = biome;
|
||||
this.climate = climate;
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public RegistryKey<Biome> getBiome()
|
||||
{
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
public BOPClimates getClimate()
|
||||
{
|
||||
return this.climate;
|
||||
|
@ -615,12 +632,12 @@ public class BiomeRegistry
|
|||
}
|
||||
}
|
||||
|
||||
private static class ToggleableStandardBiomeRegistrationData extends RegistrationData
|
||||
private static class ToggleableStandardBiomeRegistrationData extends TemplateRegistrationData
|
||||
{
|
||||
private final String name;
|
||||
private boolean enabled;
|
||||
|
||||
public ToggleableStandardBiomeRegistrationData(Biome biome, String name, boolean enabled)
|
||||
public ToggleableStandardBiomeRegistrationData(BiomeTemplate biome, String name, boolean enabled)
|
||||
{
|
||||
super(biome);
|
||||
this.name = name;
|
||||
|
@ -643,7 +660,7 @@ public class BiomeRegistry
|
|||
}
|
||||
}
|
||||
|
||||
private static class DeferredRegistration<T extends RegistrationData>
|
||||
private static class DeferredRegistration<T extends IRegistrationData>
|
||||
{
|
||||
private final Consumer<T> regFunc;
|
||||
private final T regData;
|
||||
|
|
|
@ -9,6 +9,7 @@ package biomesoplenty.common.biome;
|
|||
|
||||
import biomesoplenty.api.enums.BOPClimates;
|
||||
import biomesoplenty.common.util.biome.BiomeUtil;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.BiomeGenerationSettings;
|
||||
|
@ -21,20 +22,19 @@ import java.util.Optional;
|
|||
|
||||
public class BiomeTemplate
|
||||
{
|
||||
protected Map<BOPClimates, Integer> weightMap = new HashMap<BOPClimates, Integer>();
|
||||
public boolean canSpawnInBiome;
|
||||
public int beachBiomeId = BiomeUtil.getBiomeId(Biomes.BEACH);
|
||||
public int riverBiomeId = BiomeUtil.getBiomeId(Biomes.RIVER);
|
||||
|
||||
public BiomeTemplate()
|
||||
{
|
||||
this.canSpawnInBiome = true;
|
||||
}
|
||||
private Map<BOPClimates, Integer> weightMap = new HashMap<BOPClimates, Integer>();
|
||||
private RegistryKey<Biome> beachBiome = Biomes.BEACH;
|
||||
private RegistryKey<Biome> riverBiome = Biomes.RIVER;
|
||||
|
||||
protected void configureBiome(Biome.Builder builder) {}
|
||||
protected void configureGeneration(BiomeGenerationSettings.Builder builder) {}
|
||||
protected void configureMobSpawns(MobSpawnInfo.Builder builder) {}
|
||||
|
||||
protected void configureDefaultMobSpawns(MobSpawnInfo.Builder builder)
|
||||
{
|
||||
builder.setPlayerCanSpawn();
|
||||
}
|
||||
|
||||
public final Biome build()
|
||||
{
|
||||
Biome.Builder biomeBuilder = new Biome.Builder();
|
||||
|
@ -46,6 +46,7 @@ public class BiomeTemplate
|
|||
|
||||
// Configure mob spawning
|
||||
MobSpawnInfo.Builder mobSpawnBuilder = new MobSpawnInfo.Builder();
|
||||
this.configureDefaultMobSpawns(mobSpawnBuilder);
|
||||
this.configureMobSpawns(mobSpawnBuilder);
|
||||
biomeBuilder.mobSpawnSettings(mobSpawnBuilder.build());
|
||||
|
||||
|
@ -54,51 +55,24 @@ public class BiomeTemplate
|
|||
return biomeBuilder.build();
|
||||
}
|
||||
|
||||
public final BiomeMetadata buildMetadata()
|
||||
{
|
||||
return new BiomeMetadata(this.weightMap, this.beachBiome, this.riverBiome);
|
||||
}
|
||||
|
||||
public void addWeight(BOPClimates climate, int weight)
|
||||
{
|
||||
this.weightMap.put(climate, weight);
|
||||
}
|
||||
|
||||
public void setBeachBiome(Optional<Biome> biome)
|
||||
public void setBeachBiome(RegistryKey<Biome> biome)
|
||||
{
|
||||
if (biome.isPresent())
|
||||
this.beachBiomeId = BiomeUtil.getBiomeId(biome.get());
|
||||
else
|
||||
this.beachBiomeId = -1;
|
||||
this.beachBiome = biome;
|
||||
}
|
||||
|
||||
public void setBeachBiome(Biome biome)
|
||||
public void setRiverBiome(RegistryKey<Biome> biome)
|
||||
{
|
||||
if (biome != null)
|
||||
this.beachBiomeId = BiomeUtil.getBiomeId(biome);
|
||||
else
|
||||
this.beachBiomeId = -1;
|
||||
}
|
||||
|
||||
public void setRiverBiome(Optional<Biome> biome)
|
||||
{
|
||||
if (biome.isPresent())
|
||||
this.riverBiomeId = BiomeUtil.getBiomeId(biome.get());
|
||||
else
|
||||
this.riverBiomeId = -1;
|
||||
}
|
||||
|
||||
public void setRiverBiome(Biome biome)
|
||||
{
|
||||
if (biome != null)
|
||||
this.riverBiomeId = BiomeUtil.getBiomeId(biome);
|
||||
else
|
||||
this.riverBiomeId = -1;
|
||||
}
|
||||
|
||||
public Map<BOPClimates, Integer> getWeightMap()
|
||||
{
|
||||
return this.weightMap;
|
||||
}
|
||||
|
||||
public boolean hasWeights()
|
||||
{
|
||||
return !this.weightMap.isEmpty() && !this.weightMap.entrySet().stream().allMatch((entry) -> entry.getValue().equals(0));
|
||||
this.riverBiome = biome;
|
||||
}
|
||||
|
||||
public static int calculateSkyColor(float temperature)
|
||||
|
|
|
@ -7,10 +7,12 @@
|
|||
******************************************************************************/
|
||||
package biomesoplenty.common.biome;
|
||||
|
||||
public class NetherBiomeBOP extends BiomeTemplate
|
||||
import net.minecraft.world.biome.MobSpawnInfo;
|
||||
|
||||
public class NetherBiomeTemplate extends BiomeTemplate
|
||||
{
|
||||
public NetherBiomeBOP()
|
||||
protected void configureDefaultMobSpawns(MobSpawnInfo.Builder builder)
|
||||
{
|
||||
this.canSpawnInBiome = false;
|
||||
// Do nothing
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package biomesoplenty.common.biome.nether;
|
||||
|
||||
import biomesoplenty.api.enums.BOPClimates;
|
||||
import biomesoplenty.common.biome.NetherBiomeBOP;
|
||||
import biomesoplenty.common.biome.NetherBiomeTemplate;
|
||||
import biomesoplenty.common.world.gen.feature.BOPBiomeFeatures;
|
||||
import net.minecraft.client.audio.BackgroundMusicTracks;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
|
@ -17,7 +17,7 @@ import net.minecraft.world.gen.feature.structure.StructureFeatures;
|
|||
import net.minecraft.world.gen.surfacebuilders.ConfiguredSurfaceBuilder;
|
||||
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder;
|
||||
|
||||
public class CrystallineChasmBiome extends NetherBiomeBOP
|
||||
public class CrystallineChasmBiome extends NetherBiomeTemplate
|
||||
{
|
||||
public CrystallineChasmBiome()
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@ package biomesoplenty.common.biome.nether;
|
|||
|
||||
import biomesoplenty.api.block.BOPBlocks;
|
||||
import biomesoplenty.api.enums.BOPClimates;
|
||||
import biomesoplenty.common.biome.NetherBiomeBOP;
|
||||
import biomesoplenty.common.biome.NetherBiomeTemplate;
|
||||
import biomesoplenty.common.world.biome.BiomeFeatureHelper;
|
||||
import biomesoplenty.common.world.gen.feature.BOPBiomeFeatures;
|
||||
import net.minecraft.client.audio.BackgroundMusicTracks;
|
||||
|
@ -20,7 +20,7 @@ import net.minecraft.world.gen.feature.structure.StructureFeatures;
|
|||
import net.minecraft.world.gen.surfacebuilders.ConfiguredSurfaceBuilder;
|
||||
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder;
|
||||
|
||||
public class UndergrowthBiome extends NetherBiomeBOP
|
||||
public class UndergrowthBiome extends NetherBiomeTemplate
|
||||
{
|
||||
public UndergrowthBiome()
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package biomesoplenty.common.biome.nether;
|
||||
|
||||
import biomesoplenty.api.enums.BOPClimates;
|
||||
import biomesoplenty.common.biome.NetherBiomeBOP;
|
||||
import biomesoplenty.common.biome.NetherBiomeTemplate;
|
||||
import biomesoplenty.common.world.gen.feature.BOPBiomeFeatures;
|
||||
import net.minecraft.client.audio.BackgroundMusicTracks;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
|
@ -17,7 +17,7 @@ import net.minecraft.world.gen.feature.structure.StructureFeatures;
|
|||
import net.minecraft.world.gen.surfacebuilders.ConfiguredSurfaceBuilder;
|
||||
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder;
|
||||
|
||||
public class VisceralHeapBiome extends NetherBiomeBOP
|
||||
public class VisceralHeapBiome extends NetherBiomeTemplate
|
||||
{
|
||||
public VisceralHeapBiome()
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package biomesoplenty.common.biome.nether;
|
||||
|
||||
import biomesoplenty.api.enums.BOPClimates;
|
||||
import biomesoplenty.common.biome.NetherBiomeBOP;
|
||||
import biomesoplenty.common.biome.NetherBiomeTemplate;
|
||||
import biomesoplenty.common.world.gen.feature.BOPBiomeFeatures;
|
||||
import net.minecraft.client.audio.BackgroundMusicTracks;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
|
@ -16,7 +16,7 @@ import net.minecraft.world.gen.feature.IFeatureConfig;
|
|||
import net.minecraft.world.gen.feature.structure.StructureFeatures;
|
||||
import net.minecraft.world.gen.surfacebuilders.ConfiguredSurfaceBuilder;
|
||||
|
||||
public class WitheredAbyssBiome extends NetherBiomeBOP
|
||||
public class WitheredAbyssBiome extends NetherBiomeTemplate
|
||||
{
|
||||
public WitheredAbyssBiome()
|
||||
{
|
||||
|
|
|
@ -21,8 +21,8 @@ public class AlpsBiome extends BiomeTemplate
|
|||
public AlpsBiome()
|
||||
{
|
||||
this.addWeight(BOPClimates.ICE_CAP, 5);
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setRiverBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
this.setRiverBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,8 +24,8 @@ public class AlpsFoothillsBiome extends BiomeTemplate
|
|||
{
|
||||
public AlpsFoothillsBiome()
|
||||
{
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setRiverBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
this.setRiverBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,7 +32,7 @@ public class BogBiome extends BiomeTemplate
|
|||
public BogBiome()
|
||||
{
|
||||
this.addWeight(BOPClimates.WET_BOREAL, 3);
|
||||
this.setBeachBiome((Biome) null);
|
||||
this.setBeachBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,8 +28,8 @@ public class ColdDesertBiome extends BiomeTemplate
|
|||
public ColdDesertBiome()
|
||||
{
|
||||
this.addWeight(BOPClimates.ICE_CAP, 7);
|
||||
this.setBeachBiome((Biome) null);
|
||||
this.setRiverBiome((Biome) null);
|
||||
this.setBeachBiome(null);
|
||||
this.setRiverBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,7 +32,7 @@ public class FloodplainBiome extends BiomeTemplate
|
|||
public FloodplainBiome()
|
||||
{
|
||||
this.addWeight(BOPClimates.TROPICAL, 5);
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,7 +39,7 @@ public class FungalJungleBiome extends BiomeTemplate
|
|||
public FungalJungleBiome()
|
||||
{
|
||||
this.addWeight(BOPClimates.TROPICAL, 1);
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,7 @@ public class GravelBeachBiome extends BiomeTemplate
|
|||
{
|
||||
public GravelBeachBiome()
|
||||
{
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,7 +31,7 @@ public class GroveBiome extends BiomeTemplate
|
|||
public GroveBiome()
|
||||
{
|
||||
this.addWeight(BOPClimates.MEDITERRANEAN, 7);
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,7 +29,7 @@ public class HighlandBiome extends BiomeTemplate
|
|||
public HighlandBiome()
|
||||
{
|
||||
this.addWeight(BOPClimates.COOL_TEMPERATE, 3);
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,7 +28,7 @@ public class HighlandMoorBiome extends BiomeTemplate
|
|||
{
|
||||
public HighlandMoorBiome()
|
||||
{
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,7 +31,7 @@ public class LushSwampBiome extends BiomeTemplate
|
|||
public LushSwampBiome()
|
||||
{
|
||||
this.addWeight(BOPClimates.SUBTROPICAL, 3);
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,7 +32,7 @@ public class MangroveBiome extends BiomeTemplate
|
|||
public MangroveBiome()
|
||||
{
|
||||
this.addWeight(BOPClimates.SUBTROPICAL, 10);
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,7 +31,7 @@ public class MarshBiome extends BiomeTemplate
|
|||
public MarshBiome()
|
||||
{
|
||||
this.addWeight(BOPClimates.WET_TEMPERATE, 5);
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,7 +34,7 @@ public class MireBiome extends BiomeTemplate
|
|||
public MireBiome()
|
||||
{
|
||||
this.addWeight(BOPClimates.WET_TEMPERATE, 3);
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,7 +34,7 @@ public class MuskegBiome extends BiomeTemplate
|
|||
public MuskegBiome()
|
||||
{
|
||||
this.addWeight(BOPClimates.TUNDRA, 2);
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,8 +33,8 @@ public class MysticGroveBiome extends BiomeTemplate
|
|||
public MysticGroveBiome()
|
||||
{
|
||||
this.addWeight(BOPClimates.WET_TEMPERATE, 1);
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setRiverBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
this.setRiverBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,8 +34,8 @@ public class OminousWoodsBiome extends BiomeTemplate
|
|||
public OminousWoodsBiome()
|
||||
{
|
||||
this.addWeight(BOPClimates.WET_BOREAL, 1);
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setRiverBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
this.setRiverBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,8 +26,8 @@ public class OriginHillsBiome extends BiomeTemplate
|
|||
{
|
||||
public OriginHillsBiome()
|
||||
{
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setRiverBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
this.setRiverBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,7 +31,7 @@ public class OvergrownCliffsBiome extends BiomeTemplate
|
|||
public OvergrownCliffsBiome()
|
||||
{
|
||||
this.addWeight(BOPClimates.TROPICAL, 3);
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,7 +29,7 @@ public class RainbowValleyBiome extends BiomeTemplate
|
|||
{
|
||||
public RainbowValleyBiome()
|
||||
{
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,8 +31,8 @@ public class SilkgladeBiome extends BiomeTemplate
|
|||
public SilkgladeBiome()
|
||||
{
|
||||
this.addWeight(BOPClimates.DRY_TEMPERATE, 1);
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setRiverBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
this.setRiverBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,7 +30,7 @@ public class SteppeBiome extends BiomeTemplate
|
|||
public SteppeBiome()
|
||||
{
|
||||
this.addWeight(BOPClimates.DRY_TEMPERATE, 3);
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,8 +24,8 @@ public class TropicBeachBiome extends BiomeTemplate
|
|||
{
|
||||
public TropicBeachBiome()
|
||||
{
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setRiverBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
this.setRiverBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,7 +31,7 @@ public class TropicsBiome extends BiomeTemplate
|
|||
public TropicsBiome()
|
||||
{
|
||||
this.setBeachBiome(BOPBiomes.tropic_beach);
|
||||
this.setRiverBiome((Biome)null);
|
||||
this.setRiverBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,8 +28,8 @@ public class VolcanicPlainsBiome extends BiomeTemplate
|
|||
{
|
||||
public VolcanicPlainsBiome()
|
||||
{
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setRiverBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
this.setRiverBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,7 +27,7 @@ public class VolcanoBiome extends BiomeTemplate
|
|||
{
|
||||
public VolcanoBiome()
|
||||
{
|
||||
this.setRiverBiome((Biome) null);
|
||||
this.setRiverBiome(null);
|
||||
this.setBeachBiome(BOPBiomes.volcanic_plains);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ public class WastelandBiome extends BiomeTemplate
|
|||
public WastelandBiome()
|
||||
{
|
||||
this.addWeight(BOPClimates.WASTELAND, 10);
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setRiverBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
this.setRiverBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,7 +34,7 @@ public class WetlandBiome extends BiomeTemplate
|
|||
public WetlandBiome()
|
||||
{
|
||||
this.addWeight(BOPClimates.WET_TEMPERATE, 7);
|
||||
this.setBeachBiome((Biome)null);
|
||||
this.setBeachBiome(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,12 +7,37 @@
|
|||
******************************************************************************/
|
||||
package biomesoplenty.common.util.biome;
|
||||
|
||||
import biomesoplenty.common.biome.BiomeMetadata;
|
||||
import biomesoplenty.init.ModBiomes;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class BiomeUtil
|
||||
{
|
||||
public static RegistryKey<Biome> createKey(Biome biome)
|
||||
{
|
||||
return biome == null ? null : RegistryKey.create(Registry.BIOME_REGISTRY, biome.delegate.name());
|
||||
}
|
||||
|
||||
public static RegistryKey<Biome> createKey(int id)
|
||||
{
|
||||
return createKey(getBiome(id));
|
||||
}
|
||||
|
||||
public static Biome getBiome(RegistryKey<Biome> key)
|
||||
{
|
||||
return WorldGenRegistries.BIOME.get(key);
|
||||
}
|
||||
|
||||
public static Biome getBiome(int id)
|
||||
{
|
||||
return WorldGenRegistries.BIOME.byId(id);
|
||||
}
|
||||
|
||||
public static int getBiomeId(Biome biome)
|
||||
{
|
||||
return WorldGenRegistries.BIOME.getId(biome);
|
||||
|
@ -20,6 +45,36 @@ public class BiomeUtil
|
|||
|
||||
public static int getBiomeId(RegistryKey<Biome> key)
|
||||
{
|
||||
return getBiomeId(WorldGenRegistries.BIOME.get(key));
|
||||
return getBiomeId(getBiome(key));
|
||||
}
|
||||
|
||||
public static boolean hasMetadata(RegistryKey<Biome> key)
|
||||
{
|
||||
return ModBiomes.biomeMetadata.containsKey(key);
|
||||
}
|
||||
|
||||
public static boolean hasMetadata(Biome biome)
|
||||
{
|
||||
return hasMetadata(createKey(biome));
|
||||
}
|
||||
|
||||
public static BiomeMetadata getMetadata(RegistryKey<Biome> key)
|
||||
{
|
||||
return ModBiomes.biomeMetadata.get(key);
|
||||
}
|
||||
|
||||
public static BiomeMetadata getMetadata(Biome biome)
|
||||
{
|
||||
return getMetadata(createKey(biome));
|
||||
}
|
||||
|
||||
public static boolean exists(RegistryKey<Biome> key)
|
||||
{
|
||||
return WorldGenRegistries.BIOME.containsKey(key.location());
|
||||
}
|
||||
|
||||
public static boolean exists(int id)
|
||||
{
|
||||
return getBiome(id) != null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
package biomesoplenty.common.world;
|
||||
|
||||
import net.minecraft.client.gui.screen.BiomeGeneratorTypeScreens;
|
||||
import net.minecraft.server.IDynamicRegistries;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.util.registry.DynamicRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.gen.DimensionSettings;
|
||||
import net.minecraft.world.gen.NoiseChunkGenerator;
|
||||
import net.minecraft.world.gen.settings.DimensionGeneratorSettings;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
@ -26,14 +26,14 @@ public class BOPBiomeGeneratorTypeScreen extends BiomeGeneratorTypeScreens
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ChunkGenerator generator(long seed)
|
||||
protected ChunkGenerator generator(Registry<Biome> biomeRegistry, Registry<DimensionSettings> dimensionSettingsRegistry, long seed)
|
||||
{
|
||||
return BOPWorldTypeUtil.createChunkGenerator(seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionGeneratorSettings create(IDynamicRegistries.Impl registries, long seed, boolean generateFeatures, boolean generateBonusChest)
|
||||
public DimensionGeneratorSettings create(DynamicRegistries.Impl registries, long seed, boolean generateFeatures, boolean generateBonusChest)
|
||||
{
|
||||
return BOPWorldTypeUtil.createDimensionGeneratorSettings(seed, generateFeatures, generateBonusChest);
|
||||
return BOPWorldTypeUtil.createDimensionGeneratorSettings(registries, seed, generateFeatures, generateBonusChest);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,12 @@
|
|||
package biomesoplenty.common.world;
|
||||
|
||||
import biomesoplenty.api.enums.BOPClimates;
|
||||
import biomesoplenty.common.util.biome.BiomeUtil;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.Biomes;
|
||||
import net.minecraft.world.biome.provider.BiomeProvider;
|
||||
|
@ -27,14 +30,14 @@ public class BOPBiomeProvider extends BiomeProvider
|
|||
return builder.group(Codec.LONG.fieldOf("seed").stable().forGetter((biomeProvider) -> biomeProvider.seed)).apply(builder, builder.stable(BOPBiomeProvider::new));
|
||||
});
|
||||
|
||||
private static final List<Biome> VANILLA_POSSIBLE_BIOMES = ImmutableList.of(Biomes.OCEAN, Biomes.PLAINS, Biomes.DESERT, Biomes.MOUNTAINS, Biomes.FOREST, Biomes.TAIGA, Biomes.SWAMP, Biomes.RIVER, Biomes.FROZEN_OCEAN, Biomes.FROZEN_RIVER, Biomes.SNOWY_TUNDRA, Biomes.SNOWY_MOUNTAINS, Biomes.MUSHROOM_FIELDS, Biomes.MUSHROOM_FIELD_SHORE, Biomes.BEACH, Biomes.DESERT_HILLS, Biomes.WOODED_HILLS, Biomes.TAIGA_HILLS, Biomes.MOUNTAIN_EDGE, Biomes.JUNGLE, Biomes.JUNGLE_HILLS, Biomes.JUNGLE_EDGE, Biomes.DEEP_OCEAN, Biomes.STONE_SHORE, Biomes.SNOWY_BEACH, Biomes.BIRCH_FOREST, Biomes.BIRCH_FOREST_HILLS, Biomes.DARK_FOREST, Biomes.SNOWY_TAIGA, Biomes.SNOWY_TAIGA_HILLS, Biomes.GIANT_TREE_TAIGA, Biomes.GIANT_TREE_TAIGA_HILLS, Biomes.WOODED_MOUNTAINS, Biomes.SAVANNA, Biomes.SAVANNA_PLATEAU, Biomes.BADLANDS, Biomes.WOODED_BADLANDS_PLATEAU, Biomes.BADLANDS_PLATEAU, Biomes.WARM_OCEAN, Biomes.LUKEWARM_OCEAN, Biomes.COLD_OCEAN, Biomes.DEEP_WARM_OCEAN, Biomes.DEEP_LUKEWARM_OCEAN, Biomes.DEEP_COLD_OCEAN, Biomes.DEEP_FROZEN_OCEAN, Biomes.SUNFLOWER_PLAINS, Biomes.DESERT_LAKES, Biomes.GRAVELLY_MOUNTAINS, Biomes.FLOWER_FOREST, Biomes.TAIGA_MOUNTAINS, Biomes.SWAMP_HILLS, Biomes.ICE_SPIKES, Biomes.MODIFIED_JUNGLE, Biomes.MODIFIED_JUNGLE_EDGE, Biomes.TALL_BIRCH_FOREST, Biomes.TALL_BIRCH_HILLS, Biomes.DARK_FOREST_HILLS, Biomes.SNOWY_TAIGA_MOUNTAINS, Biomes.GIANT_SPRUCE_TAIGA, Biomes.GIANT_SPRUCE_TAIGA_HILLS, Biomes.MODIFIED_GRAVELLY_MOUNTAINS, Biomes.SHATTERED_SAVANNA, Biomes.SHATTERED_SAVANNA_PLATEAU, Biomes.ERODED_BADLANDS, Biomes.MODIFIED_WOODED_BADLANDS_PLATEAU, Biomes.MODIFIED_BADLANDS_PLATEAU);
|
||||
private static final List<RegistryKey<Biome>> VANILLA_POSSIBLE_BIOMES = ImmutableList.of(Biomes.OCEAN, Biomes.PLAINS, Biomes.DESERT, Biomes.MOUNTAINS, Biomes.FOREST, Biomes.TAIGA, Biomes.SWAMP, Biomes.RIVER, Biomes.FROZEN_OCEAN, Biomes.FROZEN_RIVER, Biomes.SNOWY_TUNDRA, Biomes.SNOWY_MOUNTAINS, Biomes.MUSHROOM_FIELDS, Biomes.MUSHROOM_FIELD_SHORE, Biomes.BEACH, Biomes.DESERT_HILLS, Biomes.WOODED_HILLS, Biomes.TAIGA_HILLS, Biomes.MOUNTAIN_EDGE, Biomes.JUNGLE, Biomes.JUNGLE_HILLS, Biomes.JUNGLE_EDGE, Biomes.DEEP_OCEAN, Biomes.STONE_SHORE, Biomes.SNOWY_BEACH, Biomes.BIRCH_FOREST, Biomes.BIRCH_FOREST_HILLS, Biomes.DARK_FOREST, Biomes.SNOWY_TAIGA, Biomes.SNOWY_TAIGA_HILLS, Biomes.GIANT_TREE_TAIGA, Biomes.GIANT_TREE_TAIGA_HILLS, Biomes.WOODED_MOUNTAINS, Biomes.SAVANNA, Biomes.SAVANNA_PLATEAU, Biomes.BADLANDS, Biomes.WOODED_BADLANDS_PLATEAU, Biomes.BADLANDS_PLATEAU, Biomes.WARM_OCEAN, Biomes.LUKEWARM_OCEAN, Biomes.COLD_OCEAN, Biomes.DEEP_WARM_OCEAN, Biomes.DEEP_LUKEWARM_OCEAN, Biomes.DEEP_COLD_OCEAN, Biomes.DEEP_FROZEN_OCEAN, Biomes.SUNFLOWER_PLAINS, Biomes.DESERT_LAKES, Biomes.GRAVELLY_MOUNTAINS, Biomes.FLOWER_FOREST, Biomes.TAIGA_MOUNTAINS, Biomes.SWAMP_HILLS, Biomes.ICE_SPIKES, Biomes.MODIFIED_JUNGLE, Biomes.MODIFIED_JUNGLE_EDGE, Biomes.TALL_BIRCH_FOREST, Biomes.TALL_BIRCH_HILLS, Biomes.DARK_FOREST_HILLS, Biomes.SNOWY_TAIGA_MOUNTAINS, Biomes.GIANT_SPRUCE_TAIGA, Biomes.GIANT_SPRUCE_TAIGA_HILLS, Biomes.MODIFIED_GRAVELLY_MOUNTAINS, Biomes.SHATTERED_SAVANNA, Biomes.SHATTERED_SAVANNA_PLATEAU, Biomes.ERODED_BADLANDS, Biomes.MODIFIED_WOODED_BADLANDS_PLATEAU, Biomes.MODIFIED_BADLANDS_PLATEAU);
|
||||
|
||||
private final long seed;
|
||||
private final Layer noiseBiomeLayer;
|
||||
|
||||
public BOPBiomeProvider(long seed)
|
||||
{
|
||||
super(Stream.concat(VANILLA_POSSIBLE_BIOMES.stream(), BOPClimates.getOverworldBiomes().stream()).collect(Collectors.toList()));
|
||||
super(Stream.concat(VANILLA_POSSIBLE_BIOMES.stream(), BOPClimates.getOverworldBiomes().stream()).map(BiomeUtil::getBiome).collect(Collectors.toList()));
|
||||
this.seed = seed;
|
||||
this.noiseBiomeLayer = BOPLayerUtil.createGenLayers(seed, new BOPOverworldGenSettings());
|
||||
}
|
||||
|
@ -54,6 +57,6 @@ public class BOPBiomeProvider extends BiomeProvider
|
|||
@Override
|
||||
public Biome getNoiseBiome(int x, int y, int z)
|
||||
{
|
||||
return this.noiseBiomeLayer.get(x, z);
|
||||
return this.noiseBiomeLayer.get(WorldGenRegistries.BIOME, x, z);
|
||||
}
|
||||
}
|
|
@ -4,13 +4,16 @@ import biomesoplenty.init.ModConfig;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.MutableRegistry;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.SimpleRegistry;
|
||||
import net.minecraft.world.Dimension;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.Biomes;
|
||||
import net.minecraft.world.biome.FuzzedBiomeMagnifier;
|
||||
import net.minecraft.world.biome.provider.BiomeProvider;
|
||||
import net.minecraft.world.biome.provider.EndBiomeProvider;
|
||||
import net.minecraft.world.biome.provider.NetherBiomeProvider;
|
||||
|
@ -27,17 +30,17 @@ import java.util.OptionalLong;
|
|||
*/
|
||||
public class BOPDimensionType extends DimensionType
|
||||
{
|
||||
protected BOPDimensionType(OptionalLong p_i241242_1_, boolean p_i241242_2_, boolean p_i241242_3_, boolean p_i241242_4_, boolean p_i241242_5_, boolean p_i241242_6_, boolean p_i241242_7_, boolean p_i241242_8_, boolean p_i241242_9_, boolean p_i241242_10_, int p_i241242_11_, ResourceLocation p_i241242_12_, float p_i241242_13_)
|
||||
protected BOPDimensionType(OptionalLong p_i241972_1_, boolean p_i241972_2_, boolean p_i241972_3_, boolean p_i241972_4_, boolean p_i241972_5_, double p_i241972_6_, boolean p_i241972_8_, boolean p_i241972_9_, boolean p_i241972_10_, boolean p_i241972_11_, int p_i241972_12_, ResourceLocation p_i241972_13_, ResourceLocation p_i241972_14_, float p_i241972_15_)
|
||||
{
|
||||
super(p_i241242_1_, p_i241242_2_, p_i241242_3_, p_i241242_4_, p_i241242_5_, p_i241242_6_, p_i241242_7_, p_i241242_8_, p_i241242_9_, p_i241242_10_, p_i241242_11_, p_i241242_12_, p_i241242_13_);
|
||||
super(p_i241972_1_, p_i241972_2_, p_i241972_3_, p_i241972_4_, p_i241972_5_, p_i241972_6_, p_i241972_8_, p_i241972_9_, p_i241972_10_, p_i241972_11_, p_i241972_12_, p_i241972_13_, p_i241972_14_, p_i241972_15_);
|
||||
}
|
||||
|
||||
private static ChunkGenerator bopEndGenerator(long seed)
|
||||
private static ChunkGenerator bopEndGenerator(Registry<Biome> biomeRegistry, Registry<DimensionSettings> dimensionSettingsRegistry, long seed)
|
||||
{
|
||||
return new NoiseChunkGenerator(new EndBiomeProvider(seed), seed, DimensionSettings.Preset.END.settings());
|
||||
return new NoiseChunkGenerator(new EndBiomeProvider(biomeRegistry, seed), seed, () -> dimensionSettingsRegistry.getOrThrow(DimensionSettings.END));
|
||||
}
|
||||
|
||||
private static ChunkGenerator bopNetherGenerator(long seed)
|
||||
private static ChunkGenerator bopNetherGenerator(Registry<Biome> biomeRegistry, Registry<DimensionSettings> dimensionSettingsRegistry, long seed)
|
||||
{
|
||||
BiomeProvider biomeProvider;
|
||||
|
||||
|
@ -47,20 +50,17 @@ public class BOPDimensionType extends DimensionType
|
|||
}
|
||||
else
|
||||
{
|
||||
ImmutableList<Biome> netherBiomes = ImmutableList.of(Biomes.NETHER_WASTES, Biomes.SOUL_SAND_VALLEY, Biomes.CRIMSON_FOREST, Biomes.WARPED_FOREST, Biomes.BASALT_DELTAS);
|
||||
biomeProvider = new NetherBiomeProvider(seed, netherBiomes.stream().flatMap((biome) -> biome.optimalParameters().map((parameter) -> Pair.of(parameter, biome))).collect(ImmutableList.toImmutableList()), Optional.of(NetherBiomeProvider.Preset.NETHER));
|
||||
biomeProvider = NetherBiomeProvider.Preset.NETHER.biomeSource(biomeRegistry, seed);
|
||||
}
|
||||
|
||||
return new NoiseChunkGenerator(biomeProvider, seed, DimensionSettings.Preset.NETHER.settings());
|
||||
return new NoiseChunkGenerator(biomeProvider, seed, () -> dimensionSettingsRegistry.getOrThrow(DimensionSettings.NETHER));
|
||||
}
|
||||
|
||||
public static SimpleRegistry<Dimension> bopDimensions(long seed)
|
||||
public static SimpleRegistry<Dimension> bopDimensions(Registry<Biome> biomeRegistry, Registry<DimensionSettings> dimensionSettingsRegistry, long seed)
|
||||
{
|
||||
SimpleRegistry<Dimension> registry = new SimpleRegistry<>(Registry.LEVEL_STEM_REGISTRY, Lifecycle.experimental());
|
||||
registry.register(Dimension.NETHER, new Dimension(() -> DEFAULT_NETHER, bopNetherGenerator(seed)));
|
||||
registry.register(Dimension.END, new Dimension(() -> DEFAULT_END, bopEndGenerator(seed)));
|
||||
registry.setPersistent(Dimension.NETHER);
|
||||
registry.setPersistent(Dimension.END);
|
||||
registry.register(Dimension.NETHER, new Dimension(() -> DEFAULT_NETHER, bopNetherGenerator(biomeRegistry, dimensionSettingsRegistry, seed)), Lifecycle.stable());
|
||||
registry.register(Dimension.END, new Dimension(() -> DEFAULT_END, bopEndGenerator(biomeRegistry, dimensionSettingsRegistry, seed)), Lifecycle.stable());
|
||||
return registry;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,14 +8,17 @@
|
|||
package biomesoplenty.common.world;
|
||||
|
||||
import biomesoplenty.api.enums.BOPClimates;
|
||||
import biomesoplenty.common.util.biome.BiomeUtil;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.Biomes;
|
||||
import net.minecraft.world.biome.provider.BiomeProvider;
|
||||
import net.minecraft.world.gen.layer.Layer;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -32,7 +35,7 @@ public class BOPNetherBiomeProvider extends BiomeProvider
|
|||
|
||||
public BOPNetherBiomeProvider(long seed)
|
||||
{
|
||||
super(Stream.concat(VANILLA_POSSIBLE_BIOMES.stream(), BOPClimates.NETHER.getLandBiomes().stream().map((entry) -> entry.biome)).collect(Collectors.toList()));
|
||||
super(Stream.concat(VANILLA_POSSIBLE_BIOMES.stream(), BOPClimates.NETHER.getLandBiomes().stream().map((entry) -> entry.biome)).map(BiomeUtil::getBiome).collect(Collectors.toList()));
|
||||
this.seed = seed;
|
||||
this.noiseBiomeLayer = BOPNetherLayerUtil.createGenLayers(seed);
|
||||
}
|
||||
|
@ -52,6 +55,6 @@ public class BOPNetherBiomeProvider extends BiomeProvider
|
|||
@Override
|
||||
public Biome getNoiseBiome(int x, int y, int z)
|
||||
{
|
||||
return this.noiseBiomeLayer.get(x, z);
|
||||
return this.noiseBiomeLayer.get(WorldGenRegistries.BIOME, x, z);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,8 +12,12 @@ import com.google.common.collect.Lists;
|
|||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import net.minecraft.server.dedicated.ServerProperties;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.registry.DynamicRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.world.Dimension;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.provider.EndBiomeProvider;
|
||||
import net.minecraft.world.biome.provider.NetherBiomeProvider;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
|
@ -21,6 +25,8 @@ import net.minecraft.world.gen.DimensionSettings;
|
|||
import net.minecraft.world.gen.NoiseChunkGenerator;
|
||||
import net.minecraft.world.gen.settings.DimensionGeneratorSettings;
|
||||
import net.minecraft.world.storage.ServerWorldInfo;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.spongepowered.asm.mixin.Dynamic;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
@ -70,12 +76,15 @@ public class BOPWorldTypeUtil
|
|||
|
||||
public static ChunkGenerator createChunkGenerator(long seed)
|
||||
{
|
||||
return new NoiseChunkGenerator(new BOPBiomeProvider(seed), seed, DimensionSettings.Preset.OVERWORLD.settings());
|
||||
return new NoiseChunkGenerator(new BOPBiomeProvider(seed), seed, () -> WorldGenRegistries.NOISE_GENERATOR_SETTINGS.getOrThrow(DimensionSettings.OVERWORLD));
|
||||
}
|
||||
|
||||
public static DimensionGeneratorSettings createDimensionGeneratorSettings(long seed, boolean generateFeatures, boolean generateBonusChest)
|
||||
public static DimensionGeneratorSettings createDimensionGeneratorSettings(DynamicRegistries registries, long seed, boolean generateFeatures, boolean generateBonusChest)
|
||||
{
|
||||
return new DimensionGeneratorSettings(seed, generateFeatures, generateBonusChest, DimensionGeneratorSettings.withOverworld(BOPDimensionType.bopDimensions(seed), createChunkGenerator(seed)));
|
||||
Registry<Biome> biomeRegistry = registries.registryOrThrow(Registry.BIOME_REGISTRY);
|
||||
Registry<DimensionSettings> dimensionSettingsRegistry = registries.registryOrThrow(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY);
|
||||
Registry<DimensionType> dimensionTypeRegistry = registries.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY);
|
||||
return new DimensionGeneratorSettings(seed, generateFeatures, generateBonusChest, DimensionGeneratorSettings.withOverworld(dimensionTypeRegistry, BOPDimensionType.bopDimensions(biomeRegistry, dimensionSettingsRegistry, seed), createChunkGenerator(seed)));
|
||||
}
|
||||
|
||||
public static void setupForDedicatedServer(DedicatedServer server)
|
||||
|
@ -90,10 +99,10 @@ public class BOPWorldTypeUtil
|
|||
if (server.getWorldData() instanceof ServerWorldInfo)
|
||||
{
|
||||
ServerWorldInfo worldInfo = (ServerWorldInfo)server.getWorldData();
|
||||
worldInfo.worldGenSettings = createDimensionGeneratorSettings(worldInfo.worldGenSettings.seed(), worldInfo.worldGenSettings.generateFeatures(), worldInfo.worldGenSettings.generateBonusChest());
|
||||
worldInfo.worldGenSettings = createDimensionGeneratorSettings(DynamicRegistries.builtin(), worldInfo.worldGenSettings.seed(), worldInfo.worldGenSettings.generateFeatures(), worldInfo.worldGenSettings.generateBonusChest());
|
||||
}
|
||||
|
||||
// Replace the world gen settings in server.properties
|
||||
properties.worldGenSettings = createDimensionGeneratorSettings(properties.worldGenSettings.seed(), properties.worldGenSettings.generateFeatures(), properties.worldGenSettings.generateBonusChest());
|
||||
properties.worldGenSettings = createDimensionGeneratorSettings(DynamicRegistries.builtin(), properties.worldGenSettings.seed(), properties.worldGenSettings.generateFeatures(), properties.worldGenSettings.generateBonusChest());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ package biomesoplenty.common.world.layer;
|
|||
|
||||
import biomesoplenty.api.biome.BOPBiomes;
|
||||
import biomesoplenty.common.util.biome.BiomeUtil;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.Biomes;
|
||||
import net.minecraft.world.gen.INoiseRandom;
|
||||
|
@ -54,7 +54,7 @@ public enum BOPBiomeEdgeLayer implements ICastleTransformer
|
|||
if (this.replaceBiomeEdge(outBiomeId, northBiomeId, eastBiomeId, southBiomeId, westBiomeId, biomeId, BOPBiomes.volcano, BOPBiomes.volcanic_plains)) { return outBiomeId[0]; }
|
||||
|
||||
// line mountains with mountain edges
|
||||
if (this.replaceBiomeEdgeIfNecessary(outBiomeId, northBiomeId, eastBiomeId, southBiomeId, westBiomeId, biomeId, MOUNTAINS, MOUNTAIN_EDGE)) { return outBiomeId[0]; }
|
||||
//if (this.replaceBiomeEdgeIfNecessary(outBiomeId, northBiomeId, eastBiomeId, southBiomeId, westBiomeId, biomeId, MOUNTAINS, MOUNTAIN_EDGE)) { return outBiomeId[0]; }
|
||||
|
||||
// line special badlands with badlands
|
||||
if (this.replaceBiomeEdge(outBiomeId, northBiomeId, eastBiomeId, southBiomeId, westBiomeId, biomeId, WOODED_BADLANDS_PLATEAU, BADLANDS)) { return outBiomeId[0]; }
|
||||
|
@ -86,35 +86,9 @@ public enum BOPBiomeEdgeLayer implements ICastleTransformer
|
|||
return biomeId;
|
||||
}
|
||||
|
||||
private boolean replaceBiomeEdgeIfNecessary(int[] outId, int northBiomeId, int southBiomeId, int eastBiomeId, int westBiomeId, int biomeId, int fromBiome, int toBiome)
|
||||
private boolean replaceBiomeEdge(int[] outId, int northBiomeId, int eastBiomeId, int southBiomeId, int westBiomeId, int biomeId, RegistryKey<Biome> fromBiome, RegistryKey<Biome> toBiome)
|
||||
{
|
||||
if (!LayerUtil.isSame(biomeId, fromBiome))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.canBiomesBeNeighbors(northBiomeId, fromBiome) && this.canBiomesBeNeighbors(southBiomeId, fromBiome) && this.canBiomesBeNeighbors(westBiomeId, fromBiome) && this.canBiomesBeNeighbors(eastBiomeId, fromBiome))
|
||||
{
|
||||
outId[0] = biomeId;
|
||||
}
|
||||
else
|
||||
{
|
||||
outId[0] = toBiome;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean replaceBiomeEdge(int[] outId, int northBiomeId, int eastBiomeId, int southBiomeId, int westBiomeId, int biomeId, Optional<Biome> fromBiome, Optional<Biome> toBiome)
|
||||
{
|
||||
return fromBiome.isPresent() && toBiome.isPresent() && this.replaceBiomeEdge(outId, northBiomeId, eastBiomeId, southBiomeId, westBiomeId, biomeId, BiomeUtil.getBiomeId(fromBiome.get()), BiomeUtil.getBiomeId(toBiome.get()));
|
||||
}
|
||||
|
||||
private boolean replaceBiomeEdge(int[] outId, int northBiomeId, int eastBiomeId, int southBiomeId, int westBiomeId, int biomeId, Optional<Biome> fromBiome, int toBiome)
|
||||
{
|
||||
return fromBiome.isPresent() && this.replaceBiomeEdge(outId, northBiomeId, eastBiomeId, southBiomeId, westBiomeId, biomeId, BiomeUtil.getBiomeId(fromBiome.get()), toBiome);
|
||||
return BiomeUtil.exists(fromBiome) && BiomeUtil.exists(toBiome) && this.replaceBiomeEdge(outId, northBiomeId, eastBiomeId, southBiomeId, westBiomeId, biomeId, BiomeUtil.getBiomeId(fromBiome), BiomeUtil.getBiomeId(toBiome));
|
||||
}
|
||||
|
||||
private boolean replaceBiomeEdge(int[] outId, int northBiomeId, int eastBiomeId, int southBiomeId, int westBiomeId, int biomeId, int fromBiome, int toBiome)
|
||||
|
@ -137,27 +111,4 @@ public enum BOPBiomeEdgeLayer implements ICastleTransformer
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canBiomesBeNeighbors(int biomeIdA, int biomeIdB)
|
||||
{
|
||||
if (LayerUtil.isSame(biomeIdA, biomeIdB))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Biome biomeA = Registry.BIOME.byId(biomeIdA);
|
||||
Biome biomeB = Registry.BIOME.byId(biomeIdB);
|
||||
if (biomeA != null && biomeB != null)
|
||||
{
|
||||
Biome.TempCategory catA = biomeA.getTemperatureCategory();
|
||||
Biome.TempCategory catB = biomeB.getTemperatureCategory();
|
||||
return catA == catB || catA == Biome.TempCategory.MEDIUM || catB == Biome.TempCategory.MEDIUM;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,13 +10,11 @@ package biomesoplenty.common.world.layer;
|
|||
import biomesoplenty.api.enums.BOPClimates;
|
||||
import biomesoplenty.common.util.biome.BiomeUtil;
|
||||
import biomesoplenty.init.ModBiomes;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biomes;
|
||||
import net.minecraft.world.gen.INoiseRandom;
|
||||
import net.minecraft.world.gen.area.IArea;
|
||||
import net.minecraft.world.gen.layer.traits.IAreaTransformer2;
|
||||
import net.minecraft.world.gen.layer.traits.IDimOffset0Transformer;
|
||||
import net.minecraftforge.common.BiomeManager;
|
||||
|
||||
public enum BOPBiomeLayer implements IAreaTransformer2, IDimOffset0Transformer
|
||||
{
|
||||
|
@ -50,7 +48,7 @@ public enum BOPBiomeLayer implements IAreaTransformer2, IDimOffset0Transformer
|
|||
{
|
||||
return BiomeUtil.getBiomeId(climate.getRandomOceanBiome(context, true));
|
||||
}
|
||||
else if ((landSeaVal == MUSHROOM_FIELDS || ModBiomes.islandBiomeIds.contains(landSeaVal)) && climate.biomeType != BiomeManager.BiomeType.ICY) // TODO
|
||||
else if ((landSeaVal == MUSHROOM_FIELDS || ModBiomes.islandBiomeIds.contains(landSeaVal)) && !(climate == BOPClimates.ICE_CAP || climate == BOPClimates.TUNDRA))
|
||||
{
|
||||
// keep islands, unless it's in an icy climate in which case, replace
|
||||
return landSeaVal;
|
||||
|
|
|
@ -9,6 +9,7 @@ package biomesoplenty.common.world.layer;
|
|||
|
||||
import biomesoplenty.api.biome.BOPBiomes;
|
||||
import biomesoplenty.api.enums.BOPClimates;
|
||||
import biomesoplenty.common.util.biome.BiomeUtil;
|
||||
import biomesoplenty.common.world.BOPLayerUtil;
|
||||
import biomesoplenty.common.world.layer.traits.IAreaTransformer3;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
@ -60,9 +61,10 @@ public enum BOPMixOceansLayer implements IAreaTransformer3, IDimOffset0Transform
|
|||
break;
|
||||
|
||||
case WASTELAND:
|
||||
if (BOPBiomes.wasteland.isPresent())
|
||||
if (BiomeUtil.exists(BOPBiomes.wasteland))
|
||||
{
|
||||
oceanId = BiomeUtil.getBiomeId(BOPBiomes.wasteland.get());
|
||||
oceanId = BiomeUtil.getBiomeId(BOPBiomes.wasteland);
|
||||
break;
|
||||
}
|
||||
// Fallthrough
|
||||
|
||||
|
@ -120,9 +122,9 @@ public enum BOPMixOceansLayer implements IAreaTransformer3, IDimOffset0Transform
|
|||
return BOPLayerUtil.DEEP_FROZEN_OCEAN;
|
||||
}
|
||||
|
||||
if (BOPBiomes.wasteland.isPresent() && oceanId == BiomeUtil.getBiomeId(BOPBiomes.wasteland.get()))
|
||||
if (BiomeUtil.exists(BOPBiomes.wasteland) && oceanId == BiomeUtil.getBiomeId(BOPBiomes.wasteland))
|
||||
{
|
||||
return BiomeUtil.getBiomeId(BOPBiomes.wasteland.get());
|
||||
return BiomeUtil.getBiomeId(BOPBiomes.wasteland);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,12 @@
|
|||
******************************************************************************/
|
||||
package biomesoplenty.common.world.layer;
|
||||
|
||||
import biomesoplenty.common.biome.BiomeMetadata;
|
||||
import biomesoplenty.common.biome.BiomeRegistry;
|
||||
import biomesoplenty.common.biome.BiomeTemplate;
|
||||
import biomesoplenty.common.util.biome.BiomeUtil;
|
||||
import biomesoplenty.common.world.BOPLayerUtil;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.Biomes;
|
||||
|
@ -32,7 +36,7 @@ public enum BOPRiverMixLayer implements IAreaTransformer2, IDimOffset0Transforme
|
|||
{
|
||||
int biomeId = biomeArea.get(x, z);
|
||||
int riverId = riverArea.get(x, z);
|
||||
Biome biome = Registry.BIOME.byId(biomeId);
|
||||
RegistryKey<Biome> biome = BiomeUtil.createKey(biomeId);
|
||||
|
||||
if (BOPLayerUtil.isOcean(biomeId))
|
||||
{
|
||||
|
@ -44,12 +48,12 @@ public enum BOPRiverMixLayer implements IAreaTransformer2, IDimOffset0Transforme
|
|||
{
|
||||
return FROZEN_RIVER;
|
||||
}
|
||||
else if (biome instanceof BiomeTemplate)
|
||||
else if (BiomeUtil.hasMetadata(biome))
|
||||
{
|
||||
BiomeTemplate biomeTemplate = (BiomeTemplate)biome;
|
||||
BiomeMetadata meta = BiomeUtil.getMetadata(biome);
|
||||
|
||||
if (biomeTemplate.riverBiomeId != -1)
|
||||
return biomeTemplate.riverBiomeId;
|
||||
if (meta.getRiverBiome() != null)
|
||||
return BiomeUtil.getBiomeId(meta.getRiverBiome());
|
||||
else
|
||||
return biomeId;
|
||||
}
|
||||
|
|
|
@ -8,8 +8,11 @@
|
|||
package biomesoplenty.common.world.layer;
|
||||
|
||||
import biomesoplenty.api.biome.BOPBiomes;
|
||||
import biomesoplenty.common.biome.BiomeMetadata;
|
||||
import biomesoplenty.common.biome.BiomeTemplate;
|
||||
import biomesoplenty.common.util.biome.BiomeUtil;
|
||||
import biomesoplenty.common.world.BOPLayerUtil;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.Biomes;
|
||||
|
@ -48,7 +51,8 @@ public enum BOPShoreLayer implements ICastleTransformer
|
|||
@Override
|
||||
public int apply(INoiseRandom context, int northBiomeId, int eastBiomeId, int southBiomeId, int westBiomeId, int biomeId)
|
||||
{
|
||||
Biome biome = Registry.BIOME.byId(biomeId);
|
||||
Biome biome = BiomeUtil.getBiome(biomeId);
|
||||
RegistryKey<Biome> key = BiomeUtil.createKey(biome);
|
||||
|
||||
if (biomeId == MUSHROOM_FIELDS)
|
||||
{
|
||||
|
@ -75,11 +79,11 @@ public enum BOPShoreLayer implements ICastleTransformer
|
|||
{
|
||||
if (!BOPLayerUtil.isOcean(biomeId) && (BOPLayerUtil.isOcean(northBiomeId) || BOPLayerUtil.isOcean(eastBiomeId) || BOPLayerUtil.isOcean(southBiomeId) || BOPLayerUtil.isOcean(westBiomeId)))
|
||||
{
|
||||
if (biome instanceof BiomeTemplate)
|
||||
if (BiomeUtil.hasMetadata(biome))
|
||||
{
|
||||
BiomeTemplate biomeTemplate = (BiomeTemplate)biome;
|
||||
BiomeMetadata meta = BiomeUtil.getMetadata(biome);
|
||||
|
||||
if (biomeTemplate.beachBiomeId == -1)
|
||||
if (meta.getBeachBiome() == null)
|
||||
return biomeId;
|
||||
}
|
||||
|
||||
|
@ -90,26 +94,20 @@ public enum BOPShoreLayer implements ICastleTransformer
|
|||
{
|
||||
if (!BOPLayerUtil.isOcean(biomeId) && biomeId != RIVER && biomeId != SWAMP && (BOPLayerUtil.isOcean(northBiomeId) || BOPLayerUtil.isOcean(eastBiomeId) || BOPLayerUtil.isOcean(southBiomeId) || BOPLayerUtil.isOcean(westBiomeId)))
|
||||
{
|
||||
if (biome instanceof BiomeTemplate)
|
||||
if (BiomeUtil.hasMetadata(biome))
|
||||
{
|
||||
BiomeTemplate biomeTemplate = (BiomeTemplate)biome;
|
||||
BiomeMetadata meta = BiomeUtil.getMetadata(biome);
|
||||
|
||||
if (biomeTemplate.beachBiomeId != -1)
|
||||
{
|
||||
return biomeTemplate.beachBiomeId;
|
||||
if (meta.getBeachBiome() == null) return biomeId;
|
||||
else return BiomeUtil.getBiomeId(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
return biomeId;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (biome == Biomes.JUNGLE || biome == Biomes.JUNGLE_HILLS || biome == Biomes.JUNGLE_EDGE || biome == Biomes.MODIFIED_JUNGLE || biome == Biomes.BAMBOO_JUNGLE || biome == Biomes.BAMBOO_JUNGLE_HILLS || biome == Biomes.MODIFIED_JUNGLE_EDGE)
|
||||
if (key == Biomes.JUNGLE || key == Biomes.JUNGLE_HILLS || key == Biomes.JUNGLE_EDGE || key == Biomes.MODIFIED_JUNGLE || key == Biomes.BAMBOO_JUNGLE || key == Biomes.BAMBOO_JUNGLE_HILLS || key == Biomes.MODIFIED_JUNGLE_EDGE)
|
||||
{
|
||||
return getBiomeIdIfPresent(BOPBiomes.mangrove, biomeId);
|
||||
}
|
||||
if (biome == Biomes.TAIGA || biome == Biomes.TAIGA_MOUNTAINS || biome == Biomes.TAIGA_HILLS || biome == Biomes.GIANT_TREE_TAIGA || biome == Biomes.GIANT_SPRUCE_TAIGA || biome == Biomes.GIANT_TREE_TAIGA_HILLS || biome == Biomes.GIANT_SPRUCE_TAIGA_HILLS || biome == Biomes.BIRCH_FOREST_HILLS || biome == Biomes.BIRCH_FOREST || biome == Biomes.TALL_BIRCH_HILLS || biome == Biomes.TALL_BIRCH_FOREST || biome == Biomes.DARK_FOREST_HILLS || biome == Biomes.DARK_FOREST)
|
||||
if (key == Biomes.TAIGA || key == Biomes.TAIGA_MOUNTAINS || key == Biomes.TAIGA_HILLS || key == Biomes.GIANT_TREE_TAIGA || key == Biomes.GIANT_SPRUCE_TAIGA || key == Biomes.GIANT_TREE_TAIGA_HILLS || key == Biomes.GIANT_SPRUCE_TAIGA_HILLS || key == Biomes.BIRCH_FOREST_HILLS || key == Biomes.BIRCH_FOREST || key == Biomes.TALL_BIRCH_HILLS || key == Biomes.TALL_BIRCH_FOREST || key == Biomes.DARK_FOREST_HILLS || key == Biomes.DARK_FOREST)
|
||||
{
|
||||
return getBiomeIdIfPresent(BOPBiomes.gravel_beach, biomeId);
|
||||
}
|
||||
|
@ -131,14 +129,16 @@ public enum BOPShoreLayer implements ICastleTransformer
|
|||
return biomeId;
|
||||
}
|
||||
|
||||
private static int getBiomeIdIfPresent(Optional<Biome> biome, int fallbackId)
|
||||
private static int getBiomeIdIfPresent(RegistryKey<Biome> biome, int fallbackId)
|
||||
{
|
||||
return biome.isPresent() ? BiomeUtil.getBiomeId(biome.get()) : fallbackId;
|
||||
return BiomeUtil.exists(biome) ? BiomeUtil.getBiomeId(biome) : fallbackId;
|
||||
}
|
||||
|
||||
private static boolean isJungleCompatible(int biomeId)
|
||||
{
|
||||
if (Registry.BIOME.byId(biomeId) != null && (Registry.BIOME.byId(biomeId)).getBiomeCategory() == Biome.Category.JUNGLE)
|
||||
Biome biome = BiomeUtil.getBiome(biomeId);
|
||||
|
||||
if (biome != null && biome.getBiomeCategory() == Biome.Category.JUNGLE)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
package biomesoplenty.common.world.layer;
|
||||
|
||||
import biomesoplenty.api.enums.BOPClimates;
|
||||
import biomesoplenty.common.util.biome.BiomeUtil;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.INoiseRandom;
|
||||
|
@ -45,7 +47,7 @@ public enum LargeIslandLayer implements IAreaTransformer2, IDimOffset1Transforme
|
|||
|
||||
if (centerVal == 0 && northVal == 0 && eastVal == 0 && southVal == 0 && westVal == 0 && context.nextRandom(50) == 0)
|
||||
{
|
||||
Biome islandBiome = climate.getRandomIslandBiome(context, null);
|
||||
RegistryKey<Biome> islandBiome = climate.getRandomIslandBiome(context, null);
|
||||
|
||||
if (islandBiome == null)
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
package biomesoplenty.common.world.layer;
|
||||
|
||||
import biomesoplenty.api.enums.BOPClimates;
|
||||
import biomesoplenty.common.util.biome.BiomeUtil;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biomes;
|
||||
import net.minecraft.world.gen.INoiseRandom;
|
||||
|
|
|
@ -14,6 +14,9 @@ import biomesoplenty.common.util.biome.BiomeUtil;
|
|||
import biomesoplenty.common.world.BOPLayerUtil;
|
||||
import biomesoplenty.init.ModBiomes;
|
||||
import com.google.common.collect.Lists;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.Biomes;
|
||||
|
@ -57,6 +60,30 @@ public enum SubBiomeLayer implements IAreaTransformer2, IDimOffset1Transformer
|
|||
private static final int SNOWY_TAIGA_HILLS = BiomeUtil.getBiomeId(Biomes.SNOWY_TAIGA_HILLS);
|
||||
private static final int TAIGA_HILLS = BiomeUtil.getBiomeId(Biomes.TAIGA_HILLS);
|
||||
|
||||
private static final Int2IntMap MUTATIONS = Util.make(new Int2IntOpenHashMap(), (map) -> {
|
||||
map.put(1, 129);
|
||||
map.put(2, 130);
|
||||
map.put(3, 131);
|
||||
map.put(4, 132);
|
||||
map.put(5, 133);
|
||||
map.put(6, 134);
|
||||
map.put(12, 140);
|
||||
map.put(21, 149);
|
||||
map.put(23, 151);
|
||||
map.put(27, 155);
|
||||
map.put(28, 156);
|
||||
map.put(29, 157);
|
||||
map.put(30, 158);
|
||||
map.put(32, 160);
|
||||
map.put(33, 161);
|
||||
map.put(34, 162);
|
||||
map.put(35, 163);
|
||||
map.put(36, 164);
|
||||
map.put(37, 165);
|
||||
map.put(38, 166);
|
||||
map.put(39, 167);
|
||||
});
|
||||
|
||||
@Override
|
||||
public int applyPixel(INoiseRandom context, IArea biomeArea, IArea riverAndSubBiomesInitArea, int x, int z)
|
||||
{
|
||||
|
@ -70,11 +97,7 @@ public enum SubBiomeLayer implements IAreaTransformer2, IDimOffset1Transformer
|
|||
Biome mutatedBiome;
|
||||
if (!BOPLayerUtil.isShallowOcean(biomeId) && initVal >= 2 && tryRareBiome)
|
||||
{
|
||||
Biome biome = Registry.BIOME.byId(biomeId);
|
||||
if (biome == null || !biome.isMutated()) {
|
||||
mutatedBiome = Biome.getMutatedVariant(biome);
|
||||
return mutatedBiome == null ? biomeId : BiomeUtil.getBiomeId(mutatedBiome);
|
||||
}
|
||||
return MUTATIONS.getOrDefault(biomeId, biomeId);
|
||||
}
|
||||
|
||||
if (context.nextRandom(3) == 0 || tryRareHillsBiome)
|
||||
|
@ -88,8 +111,7 @@ public enum SubBiomeLayer implements IAreaTransformer2, IDimOffset1Transformer
|
|||
|
||||
if (subBiomeType == 0 && mutatedBiomeId != biomeId)
|
||||
{
|
||||
mutatedBiome = Biome.getMutatedVariant(Registry.BIOME.byId(mutatedBiomeId));
|
||||
mutatedBiomeId = mutatedBiome == null ? biomeId : BiomeUtil.getBiomeId(mutatedBiome);
|
||||
mutatedBiomeId = MUTATIONS.getOrDefault(mutatedBiomeId, biomeId);
|
||||
}
|
||||
|
||||
if (mutatedBiomeId != biomeId)
|
||||
|
@ -158,7 +180,7 @@ public enum SubBiomeLayer implements IAreaTransformer2, IDimOffset1Transformer
|
|||
else if (originalBiomeId == SNOWY_TAIGA) mutatedBiomeId = SNOWY_TAIGA_HILLS;
|
||||
//Use BOP orchard instead of vanilla forest
|
||||
//else if (originalBiomeId == PLAINS) mutatedBiomeId = context.random(3) == 0 ? WOODED_HILLS : FOREST;
|
||||
else if (originalBiomeId == PLAINS && BOPBiomes.orchard.isPresent()) mutatedBiomeId = BiomeUtil.getBiomeId(BOPBiomes.orchard.get());
|
||||
else if (originalBiomeId == PLAINS && BiomeUtil.exists(BOPBiomes.orchard)) mutatedBiomeId = BiomeUtil.getBiomeId(BOPBiomes.orchard);
|
||||
//////////
|
||||
else if (originalBiomeId == SNOWY_TUNDRA) mutatedBiomeId = SNOWY_MOUNTAINS;
|
||||
else if (originalBiomeId == JUNGLE) mutatedBiomeId = JUNGLE_HILLS;
|
||||
|
|
|
@ -8,32 +8,36 @@
|
|||
package biomesoplenty.init;
|
||||
|
||||
import biomesoplenty.api.enums.BOPClimates;
|
||||
import biomesoplenty.common.biome.BiomeTemplate;
|
||||
import biomesoplenty.common.biome.BiomeMetadata;
|
||||
import biomesoplenty.common.biome.BiomeRegistry;
|
||||
import biomesoplenty.common.biome.nether.*;
|
||||
import biomesoplenty.common.biome.BiomeTemplate;
|
||||
import biomesoplenty.common.biome.nether.CrystallineChasmBiome;
|
||||
import biomesoplenty.common.biome.nether.UndergrowthBiome;
|
||||
import biomesoplenty.common.biome.nether.VisceralHeapBiome;
|
||||
import biomesoplenty.common.biome.nether.WitheredAbyssBiome;
|
||||
import biomesoplenty.common.biome.overworld.*;
|
||||
import biomesoplenty.common.util.biome.BiomeUtil;
|
||||
import biomesoplenty.common.world.BOPBiomeGeneratorTypeScreen;
|
||||
import biomesoplenty.common.world.BOPBiomeProvider;
|
||||
import biomesoplenty.common.world.BOPNetherBiomeProvider;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.client.gui.screen.BiomeGeneratorTypeScreens;
|
||||
import net.minecraft.entity.villager.VillagerType;
|
||||
import net.minecraft.entity.villager.VillagerType;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.Biomes;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.common.BiomeDictionary.Type;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Map;
|
||||
|
||||
import static biomesoplenty.api.biome.BOPBiomes.*;
|
||||
|
||||
|
@ -44,6 +48,7 @@ public class ModBiomes
|
|||
|
||||
public static Multimap<Integer, WeightedSubBiome> subBiomes = HashMultimap.create();
|
||||
public static List<Integer> islandBiomeIds = Lists.newArrayList();
|
||||
public static Map<RegistryKey<Biome>, BiomeMetadata> biomeMetadata = Maps.newHashMap();
|
||||
|
||||
public static void setup()
|
||||
{
|
||||
|
@ -275,11 +280,14 @@ public class ModBiomes
|
|||
registerVillagerType(xeric_shrubland, VillagerType.DESERT);
|
||||
}
|
||||
|
||||
private static void registerVillagerType(Optional<Biome> biome, VillagerType type)
|
||||
private static void registerVillagerType(RegistryKey<Biome> key, VillagerType type)
|
||||
{
|
||||
if (biome.isPresent())
|
||||
Biome biome = BiomeUtil.getBiome(key);
|
||||
|
||||
if (biome != null)
|
||||
{
|
||||
VillagerType.BY_BIOME.put(biome.get(), type);
|
||||
// TODO
|
||||
//VillagerType.BY_BIOME.put(biome, type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -297,47 +305,28 @@ public class ModBiomes
|
|||
BiomeRegistry.deferTechnicalBiomeRegistration(biome, name);
|
||||
}
|
||||
|
||||
public static void registerSubBiome(Biome parent, Optional<Biome> child, float rarity, int weight)
|
||||
public static void registerSubBiome(RegistryKey<Biome> parent, RegistryKey<Biome> child, float rarity, int weight)
|
||||
{
|
||||
registerSubBiome(Optional.of(parent), child, rarity, weight);
|
||||
BiomeRegistry.deferSubBiomeRegistration(parent, child, weight, rarity);
|
||||
}
|
||||
|
||||
public static void registerSubBiome(Optional<Biome> parent, Optional<Biome> child, float rarity, int weight)
|
||||
public static void registerIslandBiome(RegistryKey<Biome> key, BOPClimates climate, int weight)
|
||||
{
|
||||
if (!parent.isPresent())
|
||||
return;
|
||||
|
||||
if (!child.isPresent())
|
||||
return;
|
||||
|
||||
BiomeRegistry.deferSubBiomeRegistration(parent.get(), child.get(), weight, rarity);
|
||||
BiomeRegistry.deferIslandBiomeRegistration(key, climate, weight);
|
||||
}
|
||||
|
||||
public static void registerIslandBiome(Biome biome, BOPClimates climate, int weight)
|
||||
private static void registerVanillaBiome(RegistryKey<Biome> key, BOPClimates climate, int weight)
|
||||
{
|
||||
BiomeRegistry.deferIslandBiomeRegistration(biome, climate, weight);
|
||||
}
|
||||
|
||||
public static void registerIslandBiome(Optional<Biome> biome, BOPClimates climate, int weight)
|
||||
{
|
||||
if (!biome.isPresent())
|
||||
return;
|
||||
|
||||
registerIslandBiome(biome.get(), climate, weight);
|
||||
}
|
||||
|
||||
private static void registerVanillaBiome(Biome biome, BOPClimates climate, int weight)
|
||||
{
|
||||
BiomeRegistry.deferVanillaBiomeRegistration(biome, climate, weight);
|
||||
BiomeRegistry.deferVanillaBiomeRegistration(key, climate, weight);
|
||||
}
|
||||
|
||||
public static class WeightedSubBiome
|
||||
{
|
||||
public final Biome biome;
|
||||
public final RegistryKey<Biome> biome;
|
||||
public final float rarity;
|
||||
public final int weight;
|
||||
|
||||
public WeightedSubBiome(Biome biome, float rarity, int weight)
|
||||
public WeightedSubBiome(RegistryKey<Biome> biome, float rarity, int weight)
|
||||
{
|
||||
this.biome = biome;
|
||||
this.rarity = rarity;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
modLoader="javafml"
|
||||
license="Creative Commons Attribution-NonCommercial-NoDerivatives 4.0"
|
||||
loaderVersion="[24,)"
|
||||
issueTrackerURL="https://github.com/Glitchfiend/BiomesOPlenty/issues"
|
||||
displayURL="https://minecraft.curseforge.com/projects/biomes-o-plenty"
|
||||
|
|
Loading…
Reference in a new issue