From 045c804f14c18d1f5931686e5498a9fc98b24751 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Mon, 7 Sep 2020 12:10:07 +1000 Subject: [PATCH] Compiles --- gradle.properties | 2 +- .../biomesoplenty/api/biome/BOPBiomes.java | 146 +++++++++-------- .../biomesoplenty/api/enums/BOPClimates.java | 17 +- .../client/handler/GuiEventHandler.java | 8 +- .../common/biome/BiomeMetadata.java | 59 +++++++ .../common/biome/BiomeRegistry.java | 153 ++++++++++-------- .../common/biome/BiomeTemplate.java | 64 +++----- ...BiomeBOP.java => NetherBiomeTemplate.java} | 8 +- .../biome/nether/CrystallineChasmBiome.java | 4 +- .../common/biome/nether/UndergrowthBiome.java | 4 +- .../biome/nether/VisceralHeapBiome.java | 4 +- .../biome/nether/WitheredAbyssBiome.java | 4 +- .../common/biome/overworld/AlpsBiome.java | 4 +- .../biome/overworld/AlpsFoothillsBiome.java | 4 +- .../common/biome/overworld/BogBiome.java | 2 +- .../biome/overworld/ColdDesertBiome.java | 4 +- .../biome/overworld/FloodplainBiome.java | 2 +- .../biome/overworld/FungalJungleBiome.java | 2 +- .../biome/overworld/GravelBeachBiome.java | 2 +- .../common/biome/overworld/GroveBiome.java | 2 +- .../common/biome/overworld/HighlandBiome.java | 2 +- .../biome/overworld/HighlandMoorBiome.java | 2 +- .../biome/overworld/LushSwampBiome.java | 2 +- .../common/biome/overworld/MangroveBiome.java | 2 +- .../common/biome/overworld/MarshBiome.java | 2 +- .../common/biome/overworld/MireBiome.java | 2 +- .../common/biome/overworld/MuskegBiome.java | 2 +- .../biome/overworld/MysticGroveBiome.java | 4 +- .../biome/overworld/OminousWoodsBiome.java | 4 +- .../biome/overworld/OriginHillsBiome.java | 4 +- .../biome/overworld/OvergrownCliffsBiome.java | 2 +- .../biome/overworld/RainbowValleyBiome.java | 2 +- .../biome/overworld/SilkgladeBiome.java | 4 +- .../common/biome/overworld/SteppeBiome.java | 2 +- .../biome/overworld/TropicBeachBiome.java | 4 +- .../common/biome/overworld/TropicsBiome.java | 2 +- .../biome/overworld/VolcanicPlainsBiome.java | 4 +- .../common/biome/overworld/VolcanoBiome.java | 2 +- .../biome/overworld/WastelandBiome.java | 4 +- .../common/biome/overworld/WetlandBiome.java | 2 +- .../common/util/biome/BiomeUtil.java | 57 ++++++- .../world/BOPBiomeGeneratorTypeScreen.java | 12 +- .../common/world/BOPBiomeProvider.java | 9 +- .../common/world/BOPDimensionType.java | 26 +-- .../common/world/BOPNetherBiomeProvider.java | 7 +- .../common/world/BOPWorldTypeUtil.java | 19 ++- .../common/world/layer/BOPBiomeEdgeLayer.java | 57 +------ .../common/world/layer/BOPBiomeLayer.java | 4 +- .../common/world/layer/BOPMixOceansLayer.java | 10 +- .../common/world/layer/BOPRiverMixLayer.java | 14 +- .../common/world/layer/BOPShoreLayer.java | 38 ++--- .../common/world/layer/LargeIslandLayer.java | 4 +- .../common/world/layer/NetherBiomeLayer.java | 1 + .../common/world/layer/SubBiomeLayer.java | 38 ++++- .../java/biomesoplenty/init/ModBiomes.java | 61 +++---- src/main/resources/META-INF/mods.toml | 1 + 56 files changed, 504 insertions(+), 403 deletions(-) create mode 100644 src/main/java/biomesoplenty/common/biome/BiomeMetadata.java rename src/main/java/biomesoplenty/common/biome/{NetherBiomeBOP.java => NetherBiomeTemplate.java} (70%) diff --git a/gradle.properties b/gradle.properties index 0849608e0..057405fda 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/src/main/java/biomesoplenty/api/biome/BOPBiomes.java b/src/main/java/biomesoplenty/api/biome/BOPBiomes.java index 58c30b678..e5bf0f3af 100644 --- a/src/main/java/biomesoplenty/api/biome/BOPBiomes.java +++ b/src/main/java/biomesoplenty/api/biome/BOPBiomes.java @@ -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 alps = Optional.empty(); - public static Optional alps_foothills = Optional.empty(); - public static Optional bayou = Optional.empty(); - public static Optional bog = Optional.empty(); - public static Optional boreal_forest = Optional.empty(); - public static Optional brushland = Optional.empty(); - public static Optional chaparral = Optional.empty(); - public static Optional cherry_blossom_grove = Optional.empty(); - public static Optional cold_desert = Optional.empty(); - public static Optional coniferous_forest = Optional.empty(); - public static Optional dead_forest = Optional.empty(); - public static Optional fir_clearing = Optional.empty(); - public static Optional floodplain = Optional.empty(); - public static Optional flower_meadow = Optional.empty(); - public static Optional fungal_jungle = Optional.empty(); - public static Optional grassland = Optional.empty(); - public static Optional gravel_beach = Optional.empty(); - public static Optional grove = Optional.empty(); - public static Optional highland = Optional.empty(); - public static Optional highland_moor = Optional.empty(); - public static Optional lavender_field = Optional.empty(); - public static Optional lush_grassland = Optional.empty(); - public static Optional lush_swamp = Optional.empty(); - public static Optional mangrove = Optional.empty(); - public static Optional maple_woods = Optional.empty(); - public static Optional marsh = Optional.empty(); - public static Optional meadow = Optional.empty(); - public static Optional mire = Optional.empty(); - public static Optional muskeg = Optional.empty(); - public static Optional mystic_grove = Optional.empty(); - public static Optional oasis = Optional.empty(); - public static Optional ominous_woods = Optional.empty(); - public static Optional orchard = Optional.empty(); - public static Optional origin_hills = Optional.empty(); - public static Optional outback = Optional.empty(); - public static Optional overgrown_cliffs = Optional.empty(); - public static Optional pasture = Optional.empty(); - public static Optional poppy_field = Optional.empty(); - public static Optional prairie = Optional.empty(); - public static Optional pumpkin_patch = Optional.empty(); - public static Optional rainbow_valley = Optional.empty(); - public static Optional rainforest = Optional.empty(); - public static Optional redwood_forest = Optional.empty(); - public static Optional redwood_forest_edge = Optional.empty(); - public static Optional scrubland = Optional.empty(); - public static Optional seasonal_forest = Optional.empty(); - public static Optional shield = Optional.empty(); - public static Optional shrubland = Optional.empty(); - public static Optional silkglade = Optional.empty(); - public static Optional snowy_coniferous_forest = Optional.empty(); - public static Optional snowy_fir_clearing = Optional.empty(); - public static Optional snowy_forest = Optional.empty(); - public static Optional steppe = Optional.empty(); - public static Optional temperate_rainforest = Optional.empty(); - public static Optional temperate_rainforest_hills = Optional.empty(); - public static Optional tropical_rainforest = Optional.empty(); - public static Optional tropic_beach = Optional.empty(); - public static Optional tropics = Optional.empty(); - public static Optional tundra = Optional.empty(); - public static Optional volcanic_plains = Optional.empty(); - public static Optional volcano = Optional.empty(); - public static Optional wasteland = Optional.empty(); - public static Optional wetland = Optional.empty(); - public static Optional woodland = Optional.empty(); - public static Optional xeric_shrubland = Optional.empty(); + public static RegistryKey alps = register("alps"); + public static RegistryKey alps_foothills = register("alps_foothills"); + public static RegistryKey bayou = register("bayou"); + public static RegistryKey bog = register("bog"); + public static RegistryKey boreal_forest = register("boreal_forest"); + public static RegistryKey brushland = register("brushland"); + public static RegistryKey chaparral = register("chaparral"); + public static RegistryKey cherry_blossom_grove = register("cherry_blossom_grove"); + public static RegistryKey cold_desert = register("cold_desert"); + public static RegistryKey coniferous_forest = register("coniferous_forest"); + public static RegistryKey dead_forest = register("dead_forest"); + public static RegistryKey fir_clearing = register("fir_clearing"); + public static RegistryKey floodplain = register("floodplain"); + public static RegistryKey flower_meadow = register("flower_meadow"); + public static RegistryKey fungal_jungle = register("fungal_jungle"); + public static RegistryKey grassland = register("grassland"); + public static RegistryKey gravel_beach = register("gravel_beach"); + public static RegistryKey grove = register("grove"); + public static RegistryKey highland = register("highland"); + public static RegistryKey highland_moor = register("highland_moor"); + public static RegistryKey lavender_field = register("lavender_field"); + public static RegistryKey lush_grassland = register("lush_grassland"); + public static RegistryKey lush_swamp = register("lush_swamp"); + public static RegistryKey mangrove = register("mangrove"); + public static RegistryKey maple_woods = register("maple_woods"); + public static RegistryKey marsh = register("marsh"); + public static RegistryKey meadow = register("meadow"); + public static RegistryKey mire = register("mire"); + public static RegistryKey muskeg = register("muskeg"); + public static RegistryKey mystic_grove = register("mystic_grove"); + public static RegistryKey oasis = register("oasis"); + public static RegistryKey ominous_woods = register("ominous_woods"); + public static RegistryKey orchard = register("orchard"); + public static RegistryKey origin_hills = register("origin_hills"); + public static RegistryKey outback = register("outback"); + public static RegistryKey overgrown_cliffs = register("overgrown_cliffs"); + public static RegistryKey pasture = register("pasture"); + public static RegistryKey poppy_field = register("poppy_field"); + public static RegistryKey prairie = register("prairie"); + public static RegistryKey pumpkin_patch = register("pumpkin_patch"); + public static RegistryKey rainbow_valley = register("rainbow_valley"); + public static RegistryKey rainforest = register("rainforest"); + public static RegistryKey redwood_forest = register("redwood_forest"); + public static RegistryKey redwood_forest_edge = register("redwood_forest_edge"); + public static RegistryKey scrubland = register("scrubland"); + public static RegistryKey seasonal_forest = register("seasonal_forest"); + public static RegistryKey shield = register("shield"); + public static RegistryKey shrubland = register("shrubland"); + public static RegistryKey silkglade = register("silkglade"); + public static RegistryKey snowy_coniferous_forest = register("snowy_coniferous_forest"); + public static RegistryKey snowy_fir_clearing = register("snowy_fir_clearing"); + public static RegistryKey snowy_forest = register("snowy_forest"); + public static RegistryKey steppe = register("steppe"); + public static RegistryKey temperate_rainforest = register("temperate_rainforest"); + public static RegistryKey temperate_rainforest_hills = register("temperate_rainforest_hills"); + public static RegistryKey tropical_rainforest = register("tropical_rainforest"); + public static RegistryKey tropic_beach = register("tropic_beach"); + public static RegistryKey tropics = register("tropics"); + public static RegistryKey tundra = register("tundra"); + public static RegistryKey volcanic_plains = register("volcanic_plains"); + public static RegistryKey volcano = register("volcano"); + public static RegistryKey wasteland = register("wasteland"); + public static RegistryKey wetland = register("wetland"); + public static RegistryKey woodland = register("woodland"); + public static RegistryKey xeric_shrubland = register("xeric_shrubland"); - public static Optional crystalline_chasm = Optional.empty(); - public static Optional undergrowth = Optional.empty(); - public static Optional visceral_heap = Optional.empty(); - public static Optional withered_abyss = Optional.empty(); + public static RegistryKey crystalline_chasm = register("crystalline_chasm"); + public static RegistryKey undergrowth = register("undergrowth"); + public static RegistryKey visceral_heap = register("visceral_heap"); + public static RegistryKey withered_abyss = register("withered_abyss"); + + private static RegistryKey register(String name) + { + return RegistryKey.create(Registry.BIOME_REGISTRY, new ResourceLocation(name)); + } } diff --git a/src/main/java/biomesoplenty/api/enums/BOPClimates.java b/src/main/java/biomesoplenty/api/enums/BOPClimates.java index fce2452a2..32d843780 100644 --- a/src/main/java/biomesoplenty/api/enums/BOPClimates.java +++ b/src/main/java/biomesoplenty/api/enums/BOPClimates.java @@ -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) { 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 getRandomBiome(INoiseRandom context, RegistryKey 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 getRandomIslandBiome(INoiseRandom context, RegistryKey fallback) { if (this.totalIslandBiomesWeight == 0) return fallback; @@ -156,9 +157,9 @@ public enum BOPClimates return out; } - public static ImmutableSet getOverworldBiomes() + public static ImmutableSet> getOverworldBiomes() { - Set set = Sets.newHashSet(); + Set> 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; - public WeightedBiomeEntry(int weight, Biome biome) + public WeightedBiomeEntry(int weight, RegistryKey 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); } } } diff --git a/src/main/java/biomesoplenty/client/handler/GuiEventHandler.java b/src/main/java/biomesoplenty/client/handler/GuiEventHandler.java index ec790c417..d5d970752 100644 --- a/src/main/java/biomesoplenty/client/handler/GuiEventHandler.java +++ b/src/main/java/biomesoplenty/client/handler/GuiEventHandler.java @@ -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 dataPackLoader, Function4 worldDataLoader, SaveFormat.LevelSave save) + private static Minecraft.PackManager createPackManager(DynamicRegistries.Impl registries, Function dataPackLoader, Function4 worldDataLoader, SaveFormat.LevelSave save) { DatapackCodec dataPackCodec = dataPackLoader.apply(save); - ResourcePackList 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); diff --git a/src/main/java/biomesoplenty/common/biome/BiomeMetadata.java b/src/main/java/biomesoplenty/common/biome/BiomeMetadata.java new file mode 100644 index 000000000..3b5d9d5fb --- /dev/null +++ b/src/main/java/biomesoplenty/common/biome/BiomeMetadata.java @@ -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 weightMap; + + @Nullable + private final RegistryKey beachBiome; + + @Nullable + private final RegistryKey riverBiome; + + protected BiomeMetadata(Map weights, @Nullable RegistryKey beachBiome, @Nullable RegistryKey riverBiome) + { + this.weightMap = ImmutableMap.copyOf(weights); + this.beachBiome = beachBiome; + this.riverBiome = riverBiome; + } + + public Map getWeightMap() + { + return this.weightMap; + } + + @Nullable + public RegistryKey getBeachBiome() + { + return this.beachBiome; + } + + @Nullable + public RegistryKey getRiverBiome() + { + return this.riverBiome; + } + + public boolean hasWeights() + { + return !this.weightMap.isEmpty() && !this.weightMap.entrySet().stream().allMatch((entry) -> entry.getValue().equals(0)); + } +} diff --git a/src/main/java/biomesoplenty/common/biome/BiomeRegistry.java b/src/main/java/biomesoplenty/common/biome/BiomeRegistry.java index b2f449a0e..cee7fab60 100644 --- a/src/main/java/biomesoplenty/common/biome/BiomeRegistry.java +++ b/src/main/java/biomesoplenty/common/biome/BiomeRegistry.java @@ -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 parent, RegistryKey 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 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 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 primaryWeight = regData.getPrimaryWeight(); @@ -173,7 +183,7 @@ public class BiomeRegistry for (DeferredRegistration 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 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 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 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 void defer(RegistrationType type, T data) + private static 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 children = Sets.newHashSet(); + Set> children = Sets.newHashSet(); deferrances.get(RegistrationType.SUB_BIOME).forEach((reg) -> { - Biome biome = ((SubBiomeRegistrationData)reg.regData).getChild(); + RegistryKey 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 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 regFunc; + public final Consumer regFunc; - RegistrationType(Consumer regFunc) + RegistrationType(Consumer 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 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 parent; + private final RegistryKey child; private int weight; private float rarity; - public SubBiomeRegistrationData(Biome parent, Biome child, int weight, float rarity) + public SubBiomeRegistrationData(RegistryKey parent, RegistryKey child, int weight, float rarity) { - super(child); this.parent = parent; + this.child = child; this.weight = weight; this.rarity = rarity; } - public Biome getParent() + public RegistryKey getParent() { return this.parent; } - public Biome getChild() + public RegistryKey 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; private int weight; - public SingleClimateRegistrationData(Biome biome, BOPClimates climate, int weight) + public SingleClimateRegistrationData(RegistryKey biome, BOPClimates climate, int weight) { - super(biome); + this.biome = biome; this.climate = climate; this.weight = weight; } + public RegistryKey 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 + private static class DeferredRegistration { private final Consumer regFunc; private final T regData; diff --git a/src/main/java/biomesoplenty/common/biome/BiomeTemplate.java b/src/main/java/biomesoplenty/common/biome/BiomeTemplate.java index 9b9e6685d..d29973adc 100644 --- a/src/main/java/biomesoplenty/common/biome/BiomeTemplate.java +++ b/src/main/java/biomesoplenty/common/biome/BiomeTemplate.java @@ -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 weightMap = new HashMap(); - public boolean canSpawnInBiome; - public int beachBiomeId = BiomeUtil.getBiomeId(Biomes.BEACH); - public int riverBiomeId = BiomeUtil.getBiomeId(Biomes.RIVER); - - public BiomeTemplate() - { - this.canSpawnInBiome = true; - } + private Map weightMap = new HashMap(); + private RegistryKey beachBiome = Biomes.BEACH; + private RegistryKey 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) + public void setBeachBiome(RegistryKey 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) { - if (biome != null) - this.beachBiomeId = BiomeUtil.getBiomeId(biome); - else - this.beachBiomeId = -1; - } - - public void setRiverBiome(Optional 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 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) diff --git a/src/main/java/biomesoplenty/common/biome/NetherBiomeBOP.java b/src/main/java/biomesoplenty/common/biome/NetherBiomeTemplate.java similarity index 70% rename from src/main/java/biomesoplenty/common/biome/NetherBiomeBOP.java rename to src/main/java/biomesoplenty/common/biome/NetherBiomeTemplate.java index ab497599c..af2138762 100644 --- a/src/main/java/biomesoplenty/common/biome/NetherBiomeBOP.java +++ b/src/main/java/biomesoplenty/common/biome/NetherBiomeTemplate.java @@ -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 } } diff --git a/src/main/java/biomesoplenty/common/biome/nether/CrystallineChasmBiome.java b/src/main/java/biomesoplenty/common/biome/nether/CrystallineChasmBiome.java index a24b85a97..ce60b0da5 100644 --- a/src/main/java/biomesoplenty/common/biome/nether/CrystallineChasmBiome.java +++ b/src/main/java/biomesoplenty/common/biome/nether/CrystallineChasmBiome.java @@ -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() { diff --git a/src/main/java/biomesoplenty/common/biome/nether/UndergrowthBiome.java b/src/main/java/biomesoplenty/common/biome/nether/UndergrowthBiome.java index 682e8610b..8ceec22d3 100644 --- a/src/main/java/biomesoplenty/common/biome/nether/UndergrowthBiome.java +++ b/src/main/java/biomesoplenty/common/biome/nether/UndergrowthBiome.java @@ -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() { diff --git a/src/main/java/biomesoplenty/common/biome/nether/VisceralHeapBiome.java b/src/main/java/biomesoplenty/common/biome/nether/VisceralHeapBiome.java index aa05a2b66..22d7b4bcc 100644 --- a/src/main/java/biomesoplenty/common/biome/nether/VisceralHeapBiome.java +++ b/src/main/java/biomesoplenty/common/biome/nether/VisceralHeapBiome.java @@ -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() { diff --git a/src/main/java/biomesoplenty/common/biome/nether/WitheredAbyssBiome.java b/src/main/java/biomesoplenty/common/biome/nether/WitheredAbyssBiome.java index 3e314c5b0..761cdcbeb 100644 --- a/src/main/java/biomesoplenty/common/biome/nether/WitheredAbyssBiome.java +++ b/src/main/java/biomesoplenty/common/biome/nether/WitheredAbyssBiome.java @@ -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() { diff --git a/src/main/java/biomesoplenty/common/biome/overworld/AlpsBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/AlpsBiome.java index 98e90924f..656f74a0a 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/AlpsBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/AlpsBiome.java @@ -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 diff --git a/src/main/java/biomesoplenty/common/biome/overworld/AlpsFoothillsBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/AlpsFoothillsBiome.java index 6691f7db7..737caaec6 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/AlpsFoothillsBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/AlpsFoothillsBiome.java @@ -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 diff --git a/src/main/java/biomesoplenty/common/biome/overworld/BogBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/BogBiome.java index 488f3eca8..11fd8f188 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/BogBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/BogBiome.java @@ -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 diff --git a/src/main/java/biomesoplenty/common/biome/overworld/ColdDesertBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/ColdDesertBiome.java index b5272374b..d3ab8bf73 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/ColdDesertBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/ColdDesertBiome.java @@ -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 diff --git a/src/main/java/biomesoplenty/common/biome/overworld/FloodplainBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/FloodplainBiome.java index dbd8ce082..ae0f609a9 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/FloodplainBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/FloodplainBiome.java @@ -32,7 +32,7 @@ public class FloodplainBiome extends BiomeTemplate public FloodplainBiome() { this.addWeight(BOPClimates.TROPICAL, 5); - this.setBeachBiome((Biome)null); + this.setBeachBiome(null); } @Override diff --git a/src/main/java/biomesoplenty/common/biome/overworld/FungalJungleBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/FungalJungleBiome.java index 322c7ec3f..a55d6ba39 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/FungalJungleBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/FungalJungleBiome.java @@ -39,7 +39,7 @@ public class FungalJungleBiome extends BiomeTemplate public FungalJungleBiome() { this.addWeight(BOPClimates.TROPICAL, 1); - this.setBeachBiome((Biome)null); + this.setBeachBiome(null); } @Override diff --git a/src/main/java/biomesoplenty/common/biome/overworld/GravelBeachBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/GravelBeachBiome.java index e6392ef98..97b1dbb82 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/GravelBeachBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/GravelBeachBiome.java @@ -19,7 +19,7 @@ public class GravelBeachBiome extends BiomeTemplate { public GravelBeachBiome() { - this.setBeachBiome((Biome)null); + this.setBeachBiome(null); } @Override diff --git a/src/main/java/biomesoplenty/common/biome/overworld/GroveBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/GroveBiome.java index 34cfd4995..5fb769974 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/GroveBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/GroveBiome.java @@ -31,7 +31,7 @@ public class GroveBiome extends BiomeTemplate public GroveBiome() { this.addWeight(BOPClimates.MEDITERRANEAN, 7); - this.setBeachBiome((Biome)null); + this.setBeachBiome(null); } @Override diff --git a/src/main/java/biomesoplenty/common/biome/overworld/HighlandBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/HighlandBiome.java index 279e90ad4..227c49716 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/HighlandBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/HighlandBiome.java @@ -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 diff --git a/src/main/java/biomesoplenty/common/biome/overworld/HighlandMoorBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/HighlandMoorBiome.java index 45c1d16b4..cf6589e20 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/HighlandMoorBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/HighlandMoorBiome.java @@ -28,7 +28,7 @@ public class HighlandMoorBiome extends BiomeTemplate { public HighlandMoorBiome() { - this.setBeachBiome((Biome)null); + this.setBeachBiome(null); } @Override diff --git a/src/main/java/biomesoplenty/common/biome/overworld/LushSwampBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/LushSwampBiome.java index 9bed404f4..a0c3e4d9d 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/LushSwampBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/LushSwampBiome.java @@ -31,7 +31,7 @@ public class LushSwampBiome extends BiomeTemplate public LushSwampBiome() { this.addWeight(BOPClimates.SUBTROPICAL, 3); - this.setBeachBiome((Biome)null); + this.setBeachBiome(null); } @Override diff --git a/src/main/java/biomesoplenty/common/biome/overworld/MangroveBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/MangroveBiome.java index 9708b5a2b..39d7025a5 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/MangroveBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/MangroveBiome.java @@ -32,7 +32,7 @@ public class MangroveBiome extends BiomeTemplate public MangroveBiome() { this.addWeight(BOPClimates.SUBTROPICAL, 10); - this.setBeachBiome((Biome)null); + this.setBeachBiome(null); } @Override diff --git a/src/main/java/biomesoplenty/common/biome/overworld/MarshBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/MarshBiome.java index f1e180d91..ae728d263 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/MarshBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/MarshBiome.java @@ -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 diff --git a/src/main/java/biomesoplenty/common/biome/overworld/MireBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/MireBiome.java index 5e46f5243..4b4609ac8 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/MireBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/MireBiome.java @@ -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 diff --git a/src/main/java/biomesoplenty/common/biome/overworld/MuskegBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/MuskegBiome.java index 3a75419b9..39ead8b0f 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/MuskegBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/MuskegBiome.java @@ -34,7 +34,7 @@ public class MuskegBiome extends BiomeTemplate public MuskegBiome() { this.addWeight(BOPClimates.TUNDRA, 2); - this.setBeachBiome((Biome)null); + this.setBeachBiome(null); } @Override diff --git a/src/main/java/biomesoplenty/common/biome/overworld/MysticGroveBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/MysticGroveBiome.java index 6c7e8fd45..dc8f9f9f0 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/MysticGroveBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/MysticGroveBiome.java @@ -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 diff --git a/src/main/java/biomesoplenty/common/biome/overworld/OminousWoodsBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/OminousWoodsBiome.java index fd63f29bd..27cc61c29 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/OminousWoodsBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/OminousWoodsBiome.java @@ -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 diff --git a/src/main/java/biomesoplenty/common/biome/overworld/OriginHillsBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/OriginHillsBiome.java index a8c906cea..5406fd98f 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/OriginHillsBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/OriginHillsBiome.java @@ -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 diff --git a/src/main/java/biomesoplenty/common/biome/overworld/OvergrownCliffsBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/OvergrownCliffsBiome.java index 70e103ada..532e427c9 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/OvergrownCliffsBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/OvergrownCliffsBiome.java @@ -31,7 +31,7 @@ public class OvergrownCliffsBiome extends BiomeTemplate public OvergrownCliffsBiome() { this.addWeight(BOPClimates.TROPICAL, 3); - this.setBeachBiome((Biome)null); + this.setBeachBiome(null); } @Override diff --git a/src/main/java/biomesoplenty/common/biome/overworld/RainbowValleyBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/RainbowValleyBiome.java index de06b0e50..592f4e14a 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/RainbowValleyBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/RainbowValleyBiome.java @@ -29,7 +29,7 @@ public class RainbowValleyBiome extends BiomeTemplate { public RainbowValleyBiome() { - this.setBeachBiome((Biome)null); + this.setBeachBiome(null); } @Override diff --git a/src/main/java/biomesoplenty/common/biome/overworld/SilkgladeBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/SilkgladeBiome.java index a29c41561..412a01f9e 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/SilkgladeBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/SilkgladeBiome.java @@ -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 diff --git a/src/main/java/biomesoplenty/common/biome/overworld/SteppeBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/SteppeBiome.java index 91b73a4a6..3293b7fa6 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/SteppeBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/SteppeBiome.java @@ -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 diff --git a/src/main/java/biomesoplenty/common/biome/overworld/TropicBeachBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/TropicBeachBiome.java index 03d1c0ece..8b78aaad1 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/TropicBeachBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/TropicBeachBiome.java @@ -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 diff --git a/src/main/java/biomesoplenty/common/biome/overworld/TropicsBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/TropicsBiome.java index 6dfa7faf8..28abf0147 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/TropicsBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/TropicsBiome.java @@ -31,7 +31,7 @@ public class TropicsBiome extends BiomeTemplate public TropicsBiome() { this.setBeachBiome(BOPBiomes.tropic_beach); - this.setRiverBiome((Biome)null); + this.setRiverBiome(null); } @Override diff --git a/src/main/java/biomesoplenty/common/biome/overworld/VolcanicPlainsBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/VolcanicPlainsBiome.java index 80d817cb1..bd5106c38 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/VolcanicPlainsBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/VolcanicPlainsBiome.java @@ -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 diff --git a/src/main/java/biomesoplenty/common/biome/overworld/VolcanoBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/VolcanoBiome.java index 3ccdd2d98..5a4007469 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/VolcanoBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/VolcanoBiome.java @@ -27,7 +27,7 @@ public class VolcanoBiome extends BiomeTemplate { public VolcanoBiome() { - this.setRiverBiome((Biome) null); + this.setRiverBiome(null); this.setBeachBiome(BOPBiomes.volcanic_plains); } diff --git a/src/main/java/biomesoplenty/common/biome/overworld/WastelandBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/WastelandBiome.java index bb47bc5ab..ca73a8691 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/WastelandBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/WastelandBiome.java @@ -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 diff --git a/src/main/java/biomesoplenty/common/biome/overworld/WetlandBiome.java b/src/main/java/biomesoplenty/common/biome/overworld/WetlandBiome.java index 8211205a1..cb5b62247 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/WetlandBiome.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/WetlandBiome.java @@ -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 diff --git a/src/main/java/biomesoplenty/common/util/biome/BiomeUtil.java b/src/main/java/biomesoplenty/common/util/biome/BiomeUtil.java index a2ba13435..b29364813 100644 --- a/src/main/java/biomesoplenty/common/util/biome/BiomeUtil.java +++ b/src/main/java/biomesoplenty/common/util/biome/BiomeUtil.java @@ -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 createKey(Biome biome) + { + return biome == null ? null : RegistryKey.create(Registry.BIOME_REGISTRY, biome.delegate.name()); + } + + public static RegistryKey createKey(int id) + { + return createKey(getBiome(id)); + } + + public static Biome getBiome(RegistryKey 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 key) { - return getBiomeId(WorldGenRegistries.BIOME.get(key)); + return getBiomeId(getBiome(key)); + } + + public static boolean hasMetadata(RegistryKey key) + { + return ModBiomes.biomeMetadata.containsKey(key); + } + + public static boolean hasMetadata(Biome biome) + { + return hasMetadata(createKey(biome)); + } + + public static BiomeMetadata getMetadata(RegistryKey key) + { + return ModBiomes.biomeMetadata.get(key); + } + + public static BiomeMetadata getMetadata(Biome biome) + { + return getMetadata(createKey(biome)); + } + + public static boolean exists(RegistryKey key) + { + return WorldGenRegistries.BIOME.containsKey(key.location()); + } + + public static boolean exists(int id) + { + return getBiome(id) != null; } } diff --git a/src/main/java/biomesoplenty/common/world/BOPBiomeGeneratorTypeScreen.java b/src/main/java/biomesoplenty/common/world/BOPBiomeGeneratorTypeScreen.java index ca68ad1a2..0a531cd04 100644 --- a/src/main/java/biomesoplenty/common/world/BOPBiomeGeneratorTypeScreen.java +++ b/src/main/java/biomesoplenty/common/world/BOPBiomeGeneratorTypeScreen.java @@ -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 biomeRegistry, Registry 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); } } diff --git a/src/main/java/biomesoplenty/common/world/BOPBiomeProvider.java b/src/main/java/biomesoplenty/common/world/BOPBiomeProvider.java index dfbc1e888..aff45f348 100644 --- a/src/main/java/biomesoplenty/common/world/BOPBiomeProvider.java +++ b/src/main/java/biomesoplenty/common/world/BOPBiomeProvider.java @@ -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 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> 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); } } \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/BOPDimensionType.java b/src/main/java/biomesoplenty/common/world/BOPDimensionType.java index 68d3b1172..9d7745c81 100644 --- a/src/main/java/biomesoplenty/common/world/BOPDimensionType.java +++ b/src/main/java/biomesoplenty/common/world/BOPDimensionType.java @@ -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 biomeRegistry, Registry 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 biomeRegistry, Registry dimensionSettingsRegistry, long seed) { BiomeProvider biomeProvider; @@ -47,20 +50,17 @@ public class BOPDimensionType extends DimensionType } else { - ImmutableList 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 bopDimensions(long seed) + public static SimpleRegistry bopDimensions(Registry biomeRegistry, Registry dimensionSettingsRegistry, long seed) { SimpleRegistry 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; } } diff --git a/src/main/java/biomesoplenty/common/world/BOPNetherBiomeProvider.java b/src/main/java/biomesoplenty/common/world/BOPNetherBiomeProvider.java index de7699ad9..28cca9c66 100644 --- a/src/main/java/biomesoplenty/common/world/BOPNetherBiomeProvider.java +++ b/src/main/java/biomesoplenty/common/world/BOPNetherBiomeProvider.java @@ -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); } } diff --git a/src/main/java/biomesoplenty/common/world/BOPWorldTypeUtil.java b/src/main/java/biomesoplenty/common/world/BOPWorldTypeUtil.java index 81bab20a0..6aea442bc 100644 --- a/src/main/java/biomesoplenty/common/world/BOPWorldTypeUtil.java +++ b/src/main/java/biomesoplenty/common/world/BOPWorldTypeUtil.java @@ -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 biomeRegistry = registries.registryOrThrow(Registry.BIOME_REGISTRY); + Registry dimensionSettingsRegistry = registries.registryOrThrow(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY); + Registry 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()); } } diff --git a/src/main/java/biomesoplenty/common/world/layer/BOPBiomeEdgeLayer.java b/src/main/java/biomesoplenty/common/world/layer/BOPBiomeEdgeLayer.java index d82f18b30..543fc19a1 100644 --- a/src/main/java/biomesoplenty/common/world/layer/BOPBiomeEdgeLayer.java +++ b/src/main/java/biomesoplenty/common/world/layer/BOPBiomeEdgeLayer.java @@ -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 fromBiome, RegistryKey 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 fromBiome, Optional 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 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; - } - } - } } diff --git a/src/main/java/biomesoplenty/common/world/layer/BOPBiomeLayer.java b/src/main/java/biomesoplenty/common/world/layer/BOPBiomeLayer.java index f50394553..cd7022b9a 100644 --- a/src/main/java/biomesoplenty/common/world/layer/BOPBiomeLayer.java +++ b/src/main/java/biomesoplenty/common/world/layer/BOPBiomeLayer.java @@ -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; diff --git a/src/main/java/biomesoplenty/common/world/layer/BOPMixOceansLayer.java b/src/main/java/biomesoplenty/common/world/layer/BOPMixOceansLayer.java index e88743b5e..ee9f143e8 100644 --- a/src/main/java/biomesoplenty/common/world/layer/BOPMixOceansLayer.java +++ b/src/main/java/biomesoplenty/common/world/layer/BOPMixOceansLayer.java @@ -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); } } diff --git a/src/main/java/biomesoplenty/common/world/layer/BOPRiverMixLayer.java b/src/main/java/biomesoplenty/common/world/layer/BOPRiverMixLayer.java index 4d7288ae6..6daf94dea 100644 --- a/src/main/java/biomesoplenty/common/world/layer/BOPRiverMixLayer.java +++ b/src/main/java/biomesoplenty/common/world/layer/BOPRiverMixLayer.java @@ -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 = 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; } diff --git a/src/main/java/biomesoplenty/common/world/layer/BOPShoreLayer.java b/src/main/java/biomesoplenty/common/world/layer/BOPShoreLayer.java index f2682d676..6270731a2 100644 --- a/src/main/java/biomesoplenty/common/world/layer/BOPShoreLayer.java +++ b/src/main/java/biomesoplenty/common/world/layer/BOPShoreLayer.java @@ -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 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; - } - else - { - return biomeId; - } + if (meta.getBeachBiome() == null) return biomeId; + else return BiomeUtil.getBiomeId(key); } 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, int fallbackId) + private static int getBiomeIdIfPresent(RegistryKey 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; } diff --git a/src/main/java/biomesoplenty/common/world/layer/LargeIslandLayer.java b/src/main/java/biomesoplenty/common/world/layer/LargeIslandLayer.java index 74575a8e3..c81553ea4 100644 --- a/src/main/java/biomesoplenty/common/world/layer/LargeIslandLayer.java +++ b/src/main/java/biomesoplenty/common/world/layer/LargeIslandLayer.java @@ -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 islandBiome = climate.getRandomIslandBiome(context, null); if (islandBiome == null) { diff --git a/src/main/java/biomesoplenty/common/world/layer/NetherBiomeLayer.java b/src/main/java/biomesoplenty/common/world/layer/NetherBiomeLayer.java index dbfccb963..3db7e66c4 100644 --- a/src/main/java/biomesoplenty/common/world/layer/NetherBiomeLayer.java +++ b/src/main/java/biomesoplenty/common/world/layer/NetherBiomeLayer.java @@ -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; diff --git a/src/main/java/biomesoplenty/common/world/layer/SubBiomeLayer.java b/src/main/java/biomesoplenty/common/world/layer/SubBiomeLayer.java index 95c7a2ce5..939938c99 100644 --- a/src/main/java/biomesoplenty/common/world/layer/SubBiomeLayer.java +++ b/src/main/java/biomesoplenty/common/world/layer/SubBiomeLayer.java @@ -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; diff --git a/src/main/java/biomesoplenty/init/ModBiomes.java b/src/main/java/biomesoplenty/init/ModBiomes.java index 000e6a9e2..8ac6bdf22 100644 --- a/src/main/java/biomesoplenty/init/ModBiomes.java +++ b/src/main/java/biomesoplenty/init/ModBiomes.java @@ -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 subBiomes = HashMultimap.create(); public static List islandBiomeIds = Lists.newArrayList(); + public static Map, 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, VillagerType type) + private static void registerVillagerType(RegistryKey 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 child, float rarity, int weight) + public static void registerSubBiome(RegistryKey parent, RegistryKey child, float rarity, int weight) { - registerSubBiome(Optional.of(parent), child, rarity, weight); - } - - public static void registerSubBiome(Optional parent, Optional child, float rarity, int weight) - { - if (!parent.isPresent()) - return; - - if (!child.isPresent()) - return; - - BiomeRegistry.deferSubBiomeRegistration(parent.get(), child.get(), weight, rarity); + BiomeRegistry.deferSubBiomeRegistration(parent, child, weight, rarity); } - public static void registerIslandBiome(Biome biome, BOPClimates climate, int weight) + public static void registerIslandBiome(RegistryKey key, BOPClimates climate, int weight) { - BiomeRegistry.deferIslandBiomeRegistration(biome, climate, weight); + BiomeRegistry.deferIslandBiomeRegistration(key, climate, weight); } - public static void registerIslandBiome(Optional biome, BOPClimates climate, int weight) + private static void registerVanillaBiome(RegistryKey key, 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; public final float rarity; public final int weight; - public WeightedSubBiome(Biome biome, float rarity, int weight) + public WeightedSubBiome(RegistryKey biome, float rarity, int weight) { this.biome = biome; this.rarity = rarity; diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index e40fa77be..92256d5a2 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -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"