mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 03:25:18 +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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ public class ForgeDeferredRegistriesSetup
|
||||
|
||||
ForgeRegistries.DEFERRED_DATA_SERIALIZERS.register(modEventBus);
|
||||
ForgeRegistries.DEFERRED_LOOT_MODIFIER_SERIALIZERS.register(modEventBus);
|
||||
ForgeRegistries.DEFERRED_WORLD_TYPES.register(modEventBus);
|
||||
ForgeRegistries.DEFERRED_BIOME_MODIFIER_SERIALIZERS.register(modEventBus);
|
||||
ForgeRegistries.DEFERRED_FLUID_TYPES.register(modEventBus);
|
||||
ForgeRegistries.DEFERRED_BIOME_MODIFIERS.register(modEventBus);
|
||||
|
||||
@@ -43,7 +43,6 @@ import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorTy
|
||||
import net.minecraftforge.common.Tags;
|
||||
import net.minecraftforge.common.loot.GlobalLootModifierSerializer;
|
||||
import net.minecraftforge.common.world.BiomeModifier;
|
||||
import net.minecraftforge.common.world.ForgeWorldPreset;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
@@ -100,8 +99,6 @@ public class ForgeRegistries
|
||||
public static final Supplier<IForgeRegistry<EntityDataSerializer<?>>> DATA_SERIALIZERS = DEFERRED_DATA_SERIALIZERS.makeRegistry(GameData::getDataSerializersRegistryBuilder);
|
||||
static final DeferredRegister<GlobalLootModifierSerializer<?>> DEFERRED_LOOT_MODIFIER_SERIALIZERS = DeferredRegister.create(Keys.LOOT_MODIFIER_SERIALIZERS, Keys.LOOT_MODIFIER_SERIALIZERS.location().getNamespace());
|
||||
public static final Supplier<IForgeRegistry<GlobalLootModifierSerializer<?>>> LOOT_MODIFIER_SERIALIZERS = DEFERRED_LOOT_MODIFIER_SERIALIZERS.makeRegistry(GameData::getGLMSerializersRegistryBuilder);
|
||||
static final DeferredRegister<ForgeWorldPreset> DEFERRED_WORLD_TYPES = DeferredRegister.create(Keys.WORLD_TYPES, Keys.WORLD_TYPES.location().getNamespace());
|
||||
public static final Supplier<IForgeRegistry<ForgeWorldPreset>> WORLD_TYPES = DEFERRED_WORLD_TYPES.makeRegistry(GameData::getWorldTypesRegistryBuilder);
|
||||
static final DeferredRegister<Codec<? extends BiomeModifier>> DEFERRED_BIOME_MODIFIER_SERIALIZERS = DeferredRegister.create(Keys.BIOME_MODIFIER_SERIALIZERS, Keys.BIOME_MODIFIER_SERIALIZERS.location().getNamespace());
|
||||
public static final Supplier<IForgeRegistry<Codec<? extends BiomeModifier>>> BIOME_MODIFIER_SERIALIZERS = DEFERRED_BIOME_MODIFIER_SERIALIZERS.makeRegistry(() -> new RegistryBuilder<Codec<? extends BiomeModifier>>().disableSaving().disableSync());
|
||||
static final DeferredRegister<Codec<? extends StructureModifier>> DEFERRED_STRUCTURE_MODIFIER_SERIALIZERS = DeferredRegister.create(Keys.STRUCTURE_MODIFIER_SERIALIZERS, Keys.STRUCTURE_MODIFIER_SERIALIZERS.location().getNamespace());
|
||||
@@ -152,7 +149,6 @@ public class ForgeRegistries
|
||||
// Forge
|
||||
public static final ResourceKey<Registry<EntityDataSerializer<?>>> DATA_SERIALIZERS = key("forge:data_serializers");
|
||||
public static final ResourceKey<Registry<GlobalLootModifierSerializer<?>>> LOOT_MODIFIER_SERIALIZERS = key("forge:loot_modifier_serializers");
|
||||
public static final ResourceKey<Registry<ForgeWorldPreset>> WORLD_TYPES = key("forge:world_types");
|
||||
public static final ResourceKey<Registry<Codec<? extends BiomeModifier>>> BIOME_MODIFIER_SERIALIZERS = key("forge:biome_modifier_serializers");
|
||||
public static final ResourceKey<Registry<Codec<? extends StructureModifier>>> STRUCTURE_MODIFIER_SERIALIZERS = key("forge:structure_modifier_serializers");
|
||||
public static final ResourceKey<Registry<FluidType>> FLUID_TYPES = key("forge:fluid_type");
|
||||
|
||||
@@ -39,7 +39,6 @@ import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.loot.GlobalLootModifierSerializer;
|
||||
import net.minecraftforge.common.util.LogMessageAdapter;
|
||||
import net.minecraftforge.common.world.ForgeWorldPreset;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
@@ -149,11 +148,6 @@ public class GameData
|
||||
return makeRegistry(LOOT_MODIFIER_SERIALIZERS).disableSaving().disableSync();
|
||||
}
|
||||
|
||||
static RegistryBuilder<ForgeWorldPreset> getWorldTypesRegistryBuilder()
|
||||
{
|
||||
return makeRegistry(WORLD_TYPES).disableSaving().disableSync();
|
||||
}
|
||||
|
||||
static RegistryBuilder<FluidType> getFluidTypeRegistryBuilder()
|
||||
{
|
||||
return makeRegistry(FLUID_TYPES).disableSaving();
|
||||
|
||||
Reference in new issue
Block a user