mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-23 21:49:46 +00:00
Remove ForgeWorldPreset and related code (#8756)
Vanilla has a working replacement.
This commit is contained in:
1 parent
4f95a20c5e
commit
2ae640b530
8 files changed
-205
No files matched your search
@@ -97,21 +97,12 @@ public class ForgeConfig {
|
||||
* General configuration that doesn't need to be synchronized but needs to be available before server startup
|
||||
*/
|
||||
public static class Common {
|
||||
public final ForgeConfigSpec.ConfigValue<? extends String> defaultWorldType;
|
||||
|
||||
Common(ForgeConfigSpec.Builder builder) {
|
||||
builder.comment("General configuration settings")
|
||||
.push("general");
|
||||
|
||||
defaultWorldType = builder
|
||||
.comment("Defines a default world type to use. The vanilla default world type is represented by 'default'.",
|
||||
"The modded world types are registry names which should include the registry namespace, such as 'examplemod:example_world_type'.")
|
||||
.translation("forge.configgui.defaultWorldType")
|
||||
.define("defaultWorldType", "default");
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -102,7 +102,6 @@ import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.common.util.Lazy;
|
||||
import net.minecraftforge.common.util.MavenVersionStringHelper;
|
||||
import net.minecraftforge.common.world.BiomeGenerationSettingsBuilder;
|
||||
import net.minecraftforge.common.world.ForgeWorldPreset;
|
||||
import net.minecraftforge.common.world.MobSpawnSettingsBuilder;
|
||||
import net.minecraftforge.event.AnvilUpdateEvent;
|
||||
import net.minecraftforge.event.DifficultyChangeEvent;
|
||||
@@ -824,14 +823,6 @@ public class ForgeHooks
|
||||
throw new RuntimeException("Mod fluids must override getFluidType.");
|
||||
}
|
||||
|
||||
public static String getDefaultWorldPreset()
|
||||
{
|
||||
ForgeWorldPreset def = ForgeWorldPreset.getDefaultWorldPreset();
|
||||
if (def != null)
|
||||
return ForgeRegistries.WORLD_TYPES.get().getKey(def).toString();
|
||||
return "default";
|
||||
}
|
||||
|
||||
public static TagKey<Block> getTagFromVanillaTier(Tiers tier)
|
||||
{
|
||||
return switch(tier)
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.world;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.StringUtil;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
import net.minecraftforge.common.ForgeConfig;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class ForgeWorldPreset
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public static ForgeWorldPreset getDefaultWorldPreset()
|
||||
{
|
||||
String defaultWorldType = ForgeConfig.COMMON.defaultWorldType.get();
|
||||
|
||||
if (StringUtil.isNullOrEmpty(defaultWorldType) || "default".equals(defaultWorldType))
|
||||
return null; // use vanilla
|
||||
|
||||
ForgeWorldPreset def = ForgeRegistries.WORLD_TYPES.get().getValue(new ResourceLocation(defaultWorldType));
|
||||
if (def == null)
|
||||
{
|
||||
LOGGER.error("The defaultWorldType '{}' specified in the forge config has not been registered. The vanilla default generator will be used.", defaultWorldType);
|
||||
}
|
||||
|
||||
return def;
|
||||
}
|
||||
|
||||
private final IChunkGeneratorFactory factory;
|
||||
|
||||
public ForgeWorldPreset(IChunkGeneratorFactory factory)
|
||||
{
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
public ForgeWorldPreset(IBasicChunkGeneratorFactory factory)
|
||||
{
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
public String getTranslationKey()
|
||||
{
|
||||
return Util.makeDescriptionId("generator", ForgeRegistries.WORLD_TYPES.get().getKey(this));
|
||||
}
|
||||
|
||||
public Component getDisplayName()
|
||||
{
|
||||
return Component.translatable(getTranslationKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from both the dedicated server and the world creation screen in the client.
|
||||
* to construct the DimensionGEneratorSettings:
|
||||
* @return The constructed chunk generator.
|
||||
*/
|
||||
public ChunkGenerator createChunkGenerator(RegistryAccess registryAccess, long seed, String generatorSettings)
|
||||
{
|
||||
return this.factory.createChunkGenerator(registryAccess, seed, generatorSettings);
|
||||
}
|
||||
|
||||
public WorldGenSettings createSettings(RegistryAccess registryAccess, long seed, boolean generateStructures, boolean generateLoot, String generatorSettings)
|
||||
{
|
||||
return this.factory.createSettings(registryAccess, seed, generateStructures, generateLoot, generatorSettings);
|
||||
}
|
||||
|
||||
public interface IChunkGeneratorFactory
|
||||
{
|
||||
ChunkGenerator createChunkGenerator(RegistryAccess dynamicRegistries, long seed, String generatorSettings);
|
||||
|
||||
default WorldGenSettings createSettings(RegistryAccess dynamicRegistries, long seed, boolean generateStructures, boolean bonusChest, String generatorSettings) {
|
||||
Registry<DimensionType> dimensionTypeRegistry = dynamicRegistries.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY);
|
||||
Registry<LevelStem> levelStemRegistry = dynamicRegistries.registryOrThrow(Registry.LEVEL_STEM_REGISTRY);
|
||||
return new WorldGenSettings(seed, generateStructures, bonusChest,
|
||||
WorldGenSettings.withOverworld(dimensionTypeRegistry,
|
||||
levelStemRegistry,
|
||||
createChunkGenerator(dynamicRegistries, seed, generatorSettings)));
|
||||
}
|
||||
}
|
||||
|
||||
public interface IBasicChunkGeneratorFactory extends IChunkGeneratorFactory
|
||||
{
|
||||
ChunkGenerator createChunkGenerator(RegistryAccess registryAccess, long seed);
|
||||
|
||||
default ChunkGenerator createChunkGenerator(RegistryAccess registryAccess, long seed, String generatorSettings)
|
||||
{
|
||||
return createChunkGenerator(registryAccess, seed);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user