Create/Load of Worlds with WorldPreset appears to work
This commit is contained in:
parent
409534e6f1
commit
416ff1644e
27 changed files with 187 additions and 195 deletions
|
@ -81,7 +81,7 @@ public class BCLib implements ModInitializer {
|
|||
VersionChecker.registerMod(MOD_ID);
|
||||
|
||||
|
||||
if (false && isDevEnvironment()) {
|
||||
if (true && isDevEnvironment()) {
|
||||
BCLBiome theYellow = BCLBiomeBuilder
|
||||
.start(makeID("the_yellow"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
|
|
|
@ -30,7 +30,6 @@ import net.minecraft.world.level.dimension.LevelStem;
|
|||
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.RandomState;
|
||||
import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||
import net.minecraft.world.level.levelgen.synth.NormalNoise;
|
||||
|
||||
|
@ -157,12 +156,12 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator implements Resto
|
|||
}
|
||||
|
||||
@Override
|
||||
public WorldDimensions enforceGeneratorInWorldGenSettings(
|
||||
public Registry<LevelStem> enforceGeneratorInWorldGenSettings(
|
||||
RegistryAccess access,
|
||||
ResourceKey<LevelStem> dimensionKey,
|
||||
ResourceKey<DimensionType> dimensionTypeKey,
|
||||
ChunkGenerator loadedChunkGenerator,
|
||||
WorldDimensions worldDims
|
||||
Registry<LevelStem> dimensionRegistry
|
||||
) {
|
||||
BCLib.LOGGER.info("Enforcing Correct Generator for " + dimensionKey.location().toString() + ".");
|
||||
|
||||
|
@ -195,7 +194,7 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator implements Resto
|
|||
dimensionKey,
|
||||
dimensionTypeKey,
|
||||
access,
|
||||
worldDims,
|
||||
dimensionRegistry,
|
||||
referenceGenerator
|
||||
);
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.betterx.worlds.together.world.event.WorldEvents;
|
|||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -22,7 +23,6 @@ import net.minecraft.tags.TagLoader;
|
|||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
|
||||
|
@ -149,14 +149,14 @@ public class LevelGenEvents {
|
|||
}
|
||||
|
||||
private static void finalizeStem(
|
||||
WorldGenSettings settings,
|
||||
Registry<LevelStem> dimensionRegistry,
|
||||
ResourceKey<LevelStem> dimension,
|
||||
LevelStem levelStem
|
||||
) {
|
||||
InternalBiomeAPI.applyModifications(levelStem.generator().getBiomeSource(), dimension);
|
||||
}
|
||||
|
||||
private static void finalizedWorldLoad(WorldGenSettings worldGenSettings) {
|
||||
private static void finalizedWorldLoad(Registry<LevelStem> dimensionRegistry) {
|
||||
PoiManager.updateStates();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import net.minecraft.resources.ResourceKey;
|
|||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPresets;
|
||||
|
||||
|
@ -64,11 +63,11 @@ public class LevelGenUtil {
|
|||
}
|
||||
|
||||
|
||||
public static WorldDimensions replaceGenerator(
|
||||
public static Registry<LevelStem> replaceGenerator(
|
||||
ResourceKey<LevelStem> dimensionKey,
|
||||
ResourceKey<DimensionType> dimensionTypeKey,
|
||||
RegistryAccess registryAccess,
|
||||
WorldDimensions worldDimensions,
|
||||
Registry<LevelStem> dimensionRegistry,
|
||||
ChunkGenerator generator
|
||||
) {
|
||||
Registry<DimensionType> dimensionTypeRegistry = registryAccess.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY);
|
||||
|
@ -76,10 +75,10 @@ public class LevelGenUtil {
|
|||
dimensionKey,
|
||||
dimensionTypeKey,
|
||||
dimensionTypeRegistry,
|
||||
worldDimensions.dimensions(),
|
||||
dimensionRegistry,
|
||||
generator
|
||||
);
|
||||
return new WorldDimensions(newDimensions);
|
||||
return newDimensions;
|
||||
}
|
||||
|
||||
public static Registry<LevelStem> withDimension(
|
||||
|
|
|
@ -44,7 +44,7 @@ public class BCLBiome extends BCLBiomeSettings implements BiomeData {
|
|||
instance,
|
||||
BCLBiome::new
|
||||
));
|
||||
public static final KeyDispatchDataCodec<BCLBiome> KEY_CODEC = KeyDispatchDataCodec.of(CODEC);
|
||||
public static final KeyDispatchDataCodec<? extends BCLBiome> KEY_CODEC = KeyDispatchDataCodec.of(CODEC);
|
||||
|
||||
public KeyDispatchDataCodec<? extends BCLBiome> codec() {
|
||||
return KEY_CODEC;
|
||||
|
@ -425,7 +425,7 @@ public class BCLBiome extends BCLBiomeSettings implements BiomeData {
|
|||
}
|
||||
|
||||
public ResourceKey<BCLBiome> getBCLBiomeKey() {
|
||||
return ResourceKey.create(BCLBiomeRegistry.BCL_BIOMES_REGISTRY, biomeID);
|
||||
return (ResourceKey<BCLBiome>) (Object) ResourceKey.create(BCLBiomeRegistry.BCL_BIOMES_REGISTRY, biomeID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,7 +16,6 @@ import net.minecraft.resources.ResourceLocation;
|
|||
import net.minecraft.util.KeyDispatchDataCodec;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
|
@ -81,6 +80,7 @@ public class BCLBiomeRegistry {
|
|||
return ResourceKey.createRegistryKey(location);
|
||||
}
|
||||
|
||||
|
||||
private static Codec<? extends BCLBiome> bootstrapCodecs(Registry<Codec<? extends BCLBiome>> registry) {
|
||||
return Registry.register(registry, BCLib.makeID("biome"), BCLBiome.KEY_CODEC.codec());
|
||||
}
|
||||
|
@ -153,8 +153,8 @@ public class BCLBiomeRegistry {
|
|||
|
||||
private static Registry<BCLBiome> getBclBiomesRegistry(RegistryAccess access) {
|
||||
if (access != null) {
|
||||
return ((Optional<Registry<BCLBiome>>) access
|
||||
.registry(BCLBiomeRegistry.BCL_BIOMES_REGISTRY))
|
||||
return access
|
||||
.registry(BCLBiomeRegistry.BCL_BIOMES_REGISTRY)
|
||||
.orElse(BUILTIN_BCL_BIOMES);
|
||||
} else {
|
||||
return BUILTIN_BCL_BIOMES;
|
||||
|
|
|
@ -26,6 +26,7 @@ import net.minecraft.world.level.chunk.ChunkGenerator;
|
|||
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPresets;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
|
@ -269,13 +270,13 @@ public class WorldSetupScreen extends LayoutScreen {
|
|||
ChunkGenerator chunkGenerator
|
||||
) {
|
||||
createWorldScreen.worldGenSettingsComponent.updateSettings(
|
||||
(registryAccess, worldDimensions) -> LevelGenUtil.replaceGenerator(
|
||||
(registryAccess, worldDimensions) -> new WorldDimensions(LevelGenUtil.replaceGenerator(
|
||||
dimensionKey,
|
||||
dimensionTypeKey,
|
||||
registryAccess,
|
||||
worldDimensions,
|
||||
worldDimensions.dimensions(),
|
||||
chunkGenerator
|
||||
)
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
@Mixin(RegistryDataLoader.class)
|
||||
public interface RegistryDataLoaderMixin {
|
||||
public class RegistryDataLoaderMixin {
|
||||
@Accessor("WORLDGEN_REGISTRIES")
|
||||
@Mutable
|
||||
static void wt_set_WORLDGEN_REGISTRIES(List<RegistryDataLoader.RegistryData<?>> list) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.betterx.worlds.together;
|
||||
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeData;
|
||||
import org.betterx.worlds.together.surfaceRules.AssignedSurfaceRule;
|
||||
import org.betterx.worlds.together.surfaceRules.SurfaceRuleRegistry;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class WorldsTogetherDatagen implements DataGeneratorEntrypoint {
|
|||
|
||||
public static class CustomRegistriesDataProvider implements DataProvider {
|
||||
public static final List<RegistryDataLoader.RegistryData<?>> REGISTRIES = List.of(
|
||||
new RegistryDataLoader.RegistryData<>(BCLBiomeRegistry.BCL_BIOMES_REGISTRY, BCLBiome.CODEC),
|
||||
new RegistryDataLoader.RegistryData<>(BCLBiomeRegistry.BCL_BIOMES_REGISTRY, BiomeData.CODEC),
|
||||
new RegistryDataLoader.RegistryData<>(
|
||||
SurfaceRuleRegistry.SURFACE_RULES_REGISTRY,
|
||||
AssignedSurfaceRule.CODEC
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package org.betterx.worlds.together.chunkgenerator;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
|
||||
public class ChunkGeneratorUtils {
|
||||
public static void restoreOriginalBiomeSourceInAllDimension(WorldGenSettings settings) {
|
||||
for (var entry : settings.dimensions().dimensions().entrySet()) {
|
||||
public static void restoreOriginalBiomeSourceInAllDimension(Registry<LevelStem> dimensionRegistry) {
|
||||
for (var entry : dimensionRegistry.entrySet()) {
|
||||
ResourceKey<LevelStem> key = entry.getKey();
|
||||
LevelStem stem = entry.getValue();
|
||||
|
||||
|
|
|
@ -4,21 +4,21 @@ import org.betterx.worlds.together.biomesource.BiomeSourceFromRegistry;
|
|||
import org.betterx.worlds.together.biomesource.BiomeSourceWithConfig;
|
||||
import org.betterx.worlds.together.biomesource.MergeableBiomeSource;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
|
||||
public interface EnforceableChunkGenerator<G extends ChunkGenerator> {
|
||||
WorldDimensions enforceGeneratorInWorldGenSettings(
|
||||
Registry<LevelStem> enforceGeneratorInWorldGenSettings(
|
||||
RegistryAccess access,
|
||||
ResourceKey<LevelStem> dimensionKey,
|
||||
ResourceKey<DimensionType> dimensionTypeKey,
|
||||
ChunkGenerator loadedChunkGenerator,
|
||||
WorldDimensions worldDims
|
||||
Registry<LevelStem> dimensionRegistry
|
||||
);
|
||||
|
||||
default boolean togetherShouldRepair(ChunkGenerator chunkGenerator) {
|
||||
|
|
|
@ -4,7 +4,6 @@ import org.betterx.worlds.together.WorldsTogether;
|
|||
import org.betterx.worlds.together.biomesource.BiomeSourceWithConfig;
|
||||
import org.betterx.worlds.together.biomesource.ReloadableBiomeSource;
|
||||
import org.betterx.worlds.together.chunkgenerator.EnforceableChunkGenerator;
|
||||
import org.betterx.worlds.together.mixin.common.WorldPresetAccessor;
|
||||
import org.betterx.worlds.together.world.BiomeSourceWithNoiseRelatedSettings;
|
||||
import org.betterx.worlds.together.world.BiomeSourceWithSeed;
|
||||
import org.betterx.worlds.together.world.WorldConfig;
|
||||
|
@ -30,8 +29,6 @@ import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
|||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||
import net.minecraft.world.level.levelgen.synth.NormalNoise;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
public class WorldGenUtil {
|
||||
|
@ -80,7 +77,7 @@ public class WorldGenUtil {
|
|||
);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
// @ApiStatus.Internal
|
||||
//TODO: 1.19.3 Disabled for now
|
||||
// public static Pair<WorldDimensions, RegistryAccess.Frozen> defaultWorldDataSupplier(
|
||||
// RegistryOps<JsonElement> loaderOps,
|
||||
|
@ -106,28 +103,28 @@ public class WorldGenUtil {
|
|||
// return Pair.of(worldGenSettings, frozen);
|
||||
// }
|
||||
|
||||
private static final Map<ResourceKey<WorldPreset>, Map<ResourceKey<LevelStem>, LevelStem>> WORLD_PRESET_MAP = new HashMap<>();
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static Map<ResourceKey<LevelStem>, LevelStem> getDimensionsWithModData(ResourceKey<WorldPreset> preset) {
|
||||
var data = WORLD_PRESET_MAP.get(preset);
|
||||
if (data == null) return new HashMap<>();
|
||||
return data;
|
||||
}
|
||||
// private static final Map<ResourceKey<WorldPreset>, Map<ResourceKey<LevelStem>, LevelStem>> WORLD_PRESET_MAP = new HashMap<>();
|
||||
//
|
||||
// @ApiStatus.Internal
|
||||
// public static Map<ResourceKey<LevelStem>, LevelStem> getDimensionsWithModData(ResourceKey<WorldPreset> preset) {
|
||||
// var data = WORLD_PRESET_MAP.get(preset);
|
||||
// if (data == null) return new HashMap<>();
|
||||
// return data;
|
||||
// }
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static Holder<WorldPreset> reloadWithModData(Holder<WorldPreset> preset) {
|
||||
if (preset.value() instanceof WorldPresetAccessor acc) {
|
||||
var data = WORLD_PRESET_MAP.get(preset.unwrapKey().orElseThrow());
|
||||
if (data != null) {
|
||||
acc.bcl_setDimensions(data);
|
||||
}
|
||||
}
|
||||
// if (preset.value() instanceof WorldPresetAccessor acc) {
|
||||
// var data = WORLD_PRESET_MAP.get(preset.unwrapKey().orElseThrow());
|
||||
// if (data != null) {
|
||||
// acc.bcl_setDimensions(data);
|
||||
// }
|
||||
// }
|
||||
return preset;
|
||||
}
|
||||
|
||||
public static void clearPreloadedWorldPresets() {
|
||||
WORLD_PRESET_MAP.clear();
|
||||
// WORLD_PRESET_MAP.clear();
|
||||
}
|
||||
|
||||
// public static void preloadWorldPresets(ResourceManager resourceManager, RegistryAccess.Writable writable) {
|
||||
|
@ -227,12 +224,12 @@ public class WorldGenUtil {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ApiStatus.Internal
|
||||
public static WorldDimensions repairBiomeSourceInAllDimensions(
|
||||
public static Registry<LevelStem> repairBiomeSourceInAllDimensions(
|
||||
RegistryAccess registryAccess,
|
||||
WorldDimensions settings
|
||||
Registry<LevelStem> dimensionRegistry
|
||||
) {
|
||||
var dimensions = TogetherWorldPreset.loadWorldDimensions();
|
||||
for (var entry : settings.dimensions().entrySet()) {
|
||||
for (var entry : dimensionRegistry.entrySet()) {
|
||||
boolean didRepair = false;
|
||||
ResourceKey<LevelStem> key = entry.getKey();
|
||||
LevelStem loadedStem = entry.getValue();
|
||||
|
@ -262,12 +259,12 @@ public class WorldGenUtil {
|
|||
final ChunkGenerator loadedChunkGenerator = loadedStem.generator();
|
||||
|
||||
if (enforcer.togetherShouldRepair(loadedChunkGenerator)) {
|
||||
settings = enforcer.enforceGeneratorInWorldGenSettings(
|
||||
dimensionRegistry = enforcer.enforceGeneratorInWorldGenSettings(
|
||||
registryAccess,
|
||||
key,
|
||||
loadedStem.type().unwrapKey().orElseThrow(),
|
||||
loadedChunkGenerator,
|
||||
settings
|
||||
dimensionRegistry
|
||||
);
|
||||
didRepair = true;
|
||||
} else if (loadedChunkGenerator.getBiomeSource() instanceof BiomeSourceWithConfig bs) {
|
||||
|
@ -287,7 +284,7 @@ public class WorldGenUtil {
|
|||
}
|
||||
|
||||
}
|
||||
return settings;
|
||||
return dimensionRegistry;
|
||||
}
|
||||
|
||||
public static ResourceLocation getBiomeID(Biome biome) {
|
||||
|
|
|
@ -7,9 +7,7 @@ import net.minecraft.client.gui.screens.Screen;
|
|||
import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
|
||||
import net.minecraft.client.gui.screens.worldselection.WorldGenSettingsComponent;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.WorldLoader;
|
||||
import net.minecraft.world.level.WorldDataConfiguration;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
|
||||
|
@ -46,40 +44,6 @@ public class CreateWorldScreenMixin {
|
|||
private static Optional<ResourceKey<WorldPreset>> wt_NewDefault(Optional<ResourceKey<WorldPreset>> preset) {
|
||||
return Optional.of(WorldPresets.getDEFAULT());
|
||||
}
|
||||
//
|
||||
// @Redirect(method = "method_41854", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/RegistryAccess$Writable;freeze()Lnet/minecraft/core/RegistryAccess$Frozen;"))
|
||||
// private static RegistryAccess.Frozen loadDynamicRegistry(
|
||||
// RegistryAccess.Writable mutableRegistryManager,
|
||||
// ResourceManager dataPackManager
|
||||
// ) {
|
||||
// // This loads the dynamic registry from the data pack
|
||||
// RegistryOps.createAndLoad(JsonOps.INSTANCE, mutableRegistryManager, dataPackManager);
|
||||
// return mutableRegistryManager.freeze();
|
||||
// }
|
||||
|
||||
//Make sure the WorldGenSettings used to populate the create screen match the default WorldPreset
|
||||
@ModifyArg(method = "openFresh", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/WorldLoader;load(Lnet/minecraft/server/WorldLoader$InitConfig;Lnet/minecraft/server/WorldLoader$WorldDataSupplier;Lnet/minecraft/server/WorldLoader$ResultFactory;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"))
|
||||
private static WorldLoader.WorldDataSupplier<WorldGenSettings> wt_NewDefaultSettings(WorldLoader.WorldDataSupplier<WorldGenSettings> worldDataSupplier) {
|
||||
return worldDataSupplier;
|
||||
//TODO: 1.19.3 New DataProviders might handle this edge case automatically?
|
||||
// return (resourceManager, dataPackConfig) -> {
|
||||
//// Pair<WorldGenSettings, RegistryAccess.Frozen> res = worldDataSupplier.get(resourceManager, dataPackConfig);
|
||||
//// WorldGenSettings defaultGen = net.minecraft.world.level.levelgen.presets.WorldPresets.createNormalWorldFromPreset(frozen);
|
||||
//// WorldBootstrap.InGUI.setDefaultCreateWorldSettings(defaultGen);
|
||||
// RegistryAccess.Writable writable = RegistryAccess.builtinCopy();
|
||||
//
|
||||
//
|
||||
// WorldGenUtil.preloadWorldPresets(resourceManager, writable);
|
||||
// RegistryOps<JsonElement> registryOps = RegistryOps.createAndLoad(
|
||||
// JsonOps.INSTANCE, writable, resourceManager
|
||||
// );
|
||||
// RegistryAccess.Frozen frozen = writable.freeze();
|
||||
// WorldBootstrap.InGUI.registryReady(frozen);
|
||||
//
|
||||
//
|
||||
// return WorldGenUtil.defaultWorldDataSupplier(registryOps, frozen);
|
||||
// };
|
||||
}
|
||||
|
||||
//this is called when a new world is first created
|
||||
@Inject(method = "createNewWorldDirectory", at = @At("RETURN"))
|
||||
|
@ -87,4 +51,9 @@ public class CreateWorldScreenMixin {
|
|||
WorldBootstrap.InGUI.registryReadyOnNewWorld(this.worldGenSettingsComponent);
|
||||
WorldBootstrap.InGUI.setupNewWorld(cir.getReturnValue(), this.worldGenSettingsComponent);
|
||||
}
|
||||
|
||||
@Inject(method = "onCreate", at = @At("HEAD"))
|
||||
void wt_onCreate(CallbackInfo ci) {
|
||||
System.out.println("there");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,14 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalLong;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -33,6 +36,25 @@ public abstract class WorldGenSettingsComponentMixin implements WorldGenSettings
|
|||
@Shadow
|
||||
private WorldCreationContext settings;
|
||||
|
||||
@Shadow
|
||||
public abstract void updateSettings(WorldCreationContext.DimensionsUpdater dimensionsUpdater);
|
||||
|
||||
@Shadow
|
||||
private Optional<Holder<WorldPreset>> preset;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
public void wt_init(
|
||||
WorldCreationContext worldCreationContext,
|
||||
Optional worldPreset,
|
||||
OptionalLong seed,
|
||||
CallbackInfo ci
|
||||
) {
|
||||
if (this.preset.isPresent()) {
|
||||
//make sure the initial dimensions are in sync with the selected World Preset
|
||||
this.updateSettings((frozen, worldDimensions) -> this.preset.get().value().createWorldDimensions());
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyArg(method = "init", index = 0, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/CycleButton$Builder;withValues(Ljava/util/List;Ljava/util/List;)Lnet/minecraft/client/gui/components/CycleButton$Builder;"))
|
||||
public List<Holder<WorldPreset>> bcl_SortLists(List<Holder<WorldPreset>> list) {
|
||||
final Predicate<Holder<WorldPreset>> vanilla = (p -> p.unwrapKey()
|
||||
|
@ -40,7 +62,7 @@ public abstract class WorldGenSettingsComponentMixin implements WorldGenSettings
|
|||
.location()
|
||||
.getNamespace()
|
||||
.equals("minecraft"));
|
||||
|
||||
|
||||
|
||||
List<Holder<WorldPreset>> custom = list
|
||||
.stream()
|
||||
|
|
|
@ -5,15 +5,11 @@ import org.betterx.worlds.together.world.event.WorldBootstrap;
|
|||
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.worldselection.WorldOpenFlows;
|
||||
import net.minecraft.core.LayeredRegistryAccess;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.server.RegistryLayer;
|
||||
import net.minecraft.server.ReloadableServerResources;
|
||||
import net.minecraft.world.level.LevelSettings;
|
||||
import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
import net.minecraft.world.level.levelgen.WorldOptions;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
import net.minecraft.world.level.storage.WorldData;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -38,7 +34,6 @@ public abstract class WorldOpenFlowsMixin {
|
|||
private void wt_callFixerOnLoad(Screen screen, String levelID, CallbackInfo ci) {
|
||||
WorldBootstrap.InGUI.setupLoadedWorld(levelID, this.levelSource);
|
||||
|
||||
//if (DataFixerAPI.fixData(this.levelSource, levelID, true, (appliedFixes) -> {
|
||||
if (WorldBootstrap.InGUI.applyWorldPatches(levelSource, levelID, (appliedFixes) -> {
|
||||
WorldBootstrap.InGUI.finishedWorldLoad(levelID, this.levelSource);
|
||||
this.doLoadLevel(screen, levelID, false, false);
|
||||
|
@ -63,19 +58,8 @@ public abstract class WorldOpenFlowsMixin {
|
|||
Function<RegistryAccess, WorldDimensions> function,
|
||||
CallbackInfo ci
|
||||
) {
|
||||
WorldsTogether.LOGGER.info("called createFreshLevel...");
|
||||
//TODO: 1.19.3 no mor dimensions at this stage...
|
||||
//WorldBootstrap.InFreshLevel.setupNewWorld(levelID, worldGenSettings, this.levelSource, Optional.empty());
|
||||
}
|
||||
|
||||
@Inject(method = "createLevelFromExistingSettings", at = @At("HEAD"))
|
||||
public void wt_createLevelFromExistingSettings(
|
||||
LevelStorageSource.LevelStorageAccess levelStorageAccess,
|
||||
ReloadableServerResources reloadableServerResources,
|
||||
LayeredRegistryAccess<RegistryLayer> layeredRegistryAccess,
|
||||
WorldData worldData,
|
||||
CallbackInfo ci
|
||||
) {
|
||||
//called from the CreateWorldScreenMixin now
|
||||
//LifeCycleAPI.newWorldSetup(levelStorageAccess, worldData.worldGenSettings());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,17 @@
|
|||
package org.betterx.worlds.together.mixin.common;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.progress.ChunkProgressListener;
|
||||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
||||
|
||||
import net.minecraft.core.LayeredRegistryAccess;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.RegistryLayer;
|
||||
import net.minecraft.server.level.progress.ChunkProgressListener;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
@ -14,17 +22,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
*/
|
||||
@Mixin(value = MinecraftServer.class, priority = 2000)
|
||||
public class MinecraftServerMixin {
|
||||
// @Shadow
|
||||
// @Final
|
||||
// private RegistryAccess.Frozen registryHolder;
|
||||
// @Shadow
|
||||
// @Final
|
||||
// protected WorldData worldData;
|
||||
@Shadow
|
||||
@Final
|
||||
private LayeredRegistryAccess<RegistryLayer> registries;
|
||||
|
||||
@Inject(method = "createLevels", at = @At(value = "HEAD"))
|
||||
private void together_addSurfaceRules(ChunkProgressListener worldGenerationProgressListener, CallbackInfo ci) {
|
||||
//TODO: 1.19.3 Dimensions are handled differently now
|
||||
//WorldBootstrap.finalizeWorldGenSettings(this.worldData.worldGenSettings());
|
||||
|
||||
final Registry<LevelStem> dimensionRegistry = this.registries.compositeAccess()
|
||||
.registryOrThrow(Registry.LEVEL_STEM_REGISTRY);
|
||||
WorldBootstrap.finalizeWorldGenSettings(dimensionRegistry);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,22 @@
|
|||
package org.betterx.worlds.together.mixin.common;
|
||||
|
||||
import org.betterx.worlds.together.chunkgenerator.ChunkGeneratorUtils;
|
||||
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import net.minecraft.core.LayeredRegistryAccess;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.RegistryLayer;
|
||||
import net.minecraft.server.Services;
|
||||
import net.minecraft.server.WorldStem;
|
||||
import net.minecraft.server.level.progress.ChunkProgressListenerFactory;
|
||||
import net.minecraft.server.packs.repository.PackRepository;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
@ -17,6 +25,10 @@ import java.net.Proxy;
|
|||
|
||||
@Mixin(value = MinecraftServer.class, priority = 2000)
|
||||
public class MinecraftServerMixinLate {
|
||||
@Shadow
|
||||
@Final
|
||||
private LayeredRegistryAccess<RegistryLayer> registries;
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "<init>")
|
||||
private void bcl_restoreBiomeSource(
|
||||
Thread thread,
|
||||
|
@ -29,7 +41,8 @@ public class MinecraftServerMixinLate {
|
|||
ChunkProgressListenerFactory chunkProgressListenerFactory,
|
||||
CallbackInfo ci
|
||||
) {
|
||||
//TODO: 1.19.3 Dimensions are handled differently now
|
||||
//ChunkGeneratorUtils.restoreOriginalBiomeSourceInAllDimension(worldStem.worldData().worldGenSettings());
|
||||
final Registry<LevelStem> dimensionRegistry = this.registries.compositeAccess()
|
||||
.registryOrThrow(Registry.LEVEL_STEM_REGISTRY);
|
||||
ChunkGeneratorUtils.restoreOriginalBiomeSourceInAllDimension(dimensionRegistry);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,42 +1,61 @@
|
|||
package org.betterx.worlds.together.mixin.common;
|
||||
|
||||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
||||
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import com.mojang.serialization.Dynamic;
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.world.level.LevelSettings;
|
||||
import net.minecraft.world.level.levelgen.WorldOptions;
|
||||
import net.minecraft.world.level.storage.LevelVersion;
|
||||
import net.minecraft.world.level.storage.PrimaryLevelData;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Optional;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Mixin(PrimaryLevelData.class)
|
||||
public class PrimaryLevelDataMixin {
|
||||
//TODO: 1.19.3 This was changed completley
|
||||
//TODO: 1.19.3 This was changed completley, Replaced by WorldDimensions.bake
|
||||
// @Shadow
|
||||
// @Final
|
||||
// private WorldGenSettings worldGenSettings;
|
||||
// private static final ThreadLocal<Optional<RegistryOps<Tag>>> bcl_lastRegistryAccess = ThreadLocal.withInitial(
|
||||
// () -> Optional.empty());
|
||||
//
|
||||
// //This is the way a created (new) world is initializing the PrimaryLevelData
|
||||
// @ModifyArg(method = "<init>(Lnet/minecraft/world/level/LevelSettings;Lnet/minecraft/world/level/levelgen/WorldGenSettings;Lcom/mojang/serialization/Lifecycle;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/PrimaryLevelData;<init>(Lcom/mojang/datafixers/DataFixer;ILnet/minecraft/nbt/CompoundTag;ZIIIFJJIIIZIZZZLnet/minecraft/world/level/border/WorldBorder$Settings;IILjava/util/UUID;Ljava/util/Set;Lnet/minecraft/world/level/timers/TimerQueue;Lnet/minecraft/nbt/CompoundTag;Lnet/minecraft/nbt/CompoundTag;Lnet/minecraft/world/level/LevelSettings;Lnet/minecraft/world/level/levelgen/WorldGenSettings;Lcom/mojang/serialization/Lifecycle;)V"))
|
||||
private static final ThreadLocal<Optional<RegistryOps<Tag>>> bcl_lastRegistryAccess = ThreadLocal.withInitial(
|
||||
() -> Optional.empty());
|
||||
|
||||
// //This is the way a created (new) world is initializing the PrimaryLevelData
|
||||
// @ModifyArg(method = "<init>(Lnet/minecraft/world/level/LevelSettings;Lnet/minecraft/world/level/levelgen/WorldOptions;Lnet/minecraft/world/level/storage/PrimaryLevelData$SpecialWorldProperty;Lcom/mojang/serialization/Lifecycle;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/PrimaryLevelData;<init>(Lcom/mojang/datafixers/DataFixer;ILnet/minecraft/nbt/CompoundTag;ZIIIFJJIIIZIZZZLnet/minecraft/world/level/border/WorldBorder$Settings;IILjava/util/UUID;Ljava/util/Set;Lnet/minecraft/world/level/timers/TimerQueue;Lnet/minecraft/nbt/CompoundTag;Lnet/minecraft/nbt/CompoundTag;Lnet/minecraft/world/level/LevelSettings;Lnet/minecraft/world/level/levelgen/WorldGenSettings;Lcom/mojang/serialization/Lifecycle;)V"))
|
||||
// private static WorldGenSettings bcl_fixOtherSettings(WorldGenSettings worldGenSettings) {
|
||||
// return WorldBootstrap.enforceInNewWorld(worldGenSettings);
|
||||
// }
|
||||
//
|
||||
// @Inject(method = "parse", at = @At("HEAD"))
|
||||
// private static void bcl_parse(
|
||||
// Dynamic<Tag> dynamic,
|
||||
// DataFixer dataFixer,
|
||||
// int i,
|
||||
// @Nullable CompoundTag compoundTag,
|
||||
// LevelSettings levelSettings,
|
||||
// LevelVersion levelVersion,
|
||||
// WorldGenSettings worldGenSettings,
|
||||
// Lifecycle lifecycle,
|
||||
// CallbackInfoReturnable<PrimaryLevelData> cir
|
||||
// ) {
|
||||
// if (dynamic.getOps() instanceof RegistryOps<Tag> regOps) {
|
||||
// bcl_lastRegistryAccess.set(Optional.of(regOps));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
@Inject(method = "parse", at = @At("HEAD"))
|
||||
private static void bcl_parse(
|
||||
Dynamic<Tag> dynamic,
|
||||
DataFixer dataFixer,
|
||||
int i,
|
||||
@Nullable CompoundTag compoundTag,
|
||||
LevelSettings levelSettings,
|
||||
LevelVersion levelVersion,
|
||||
PrimaryLevelData.SpecialWorldProperty specialWorldProperty,
|
||||
WorldOptions worldOptions,
|
||||
Lifecycle lifecycle,
|
||||
CallbackInfoReturnable<PrimaryLevelData> cir
|
||||
) {
|
||||
if (dynamic.getOps() instanceof RegistryOps<Tag> regOps) {
|
||||
//bcl_lastRegistryAccess.set(Optional.of(regOps));
|
||||
WorldBootstrap.InGUI.registryReadyOnLoadedWorld(Optional.of(regOps));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// //This is the way a loaded (existing) world is initializing the PrimaryLevelData
|
||||
// @ModifyArg(method = "parse", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/PrimaryLevelData;<init>(Lcom/mojang/datafixers/DataFixer;ILnet/minecraft/nbt/CompoundTag;ZIIIFJJIIIZIZZZLnet/minecraft/world/level/border/WorldBorder$Settings;IILjava/util/UUID;Ljava/util/Set;Lnet/minecraft/world/level/timers/TimerQueue;Lnet/minecraft/nbt/CompoundTag;Lnet/minecraft/nbt/CompoundTag;Lnet/minecraft/world/level/LevelSettings;Lnet/minecraft/world/level/levelgen/WorldGenSettings;Lcom/mojang/serialization/Lifecycle;)V"))
|
||||
// private static WorldGenSettings bcl_fixSettings(WorldGenSettings settings) {
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package org.betterx.worlds.together.mixin.common;
|
||||
|
||||
import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(value = WorldDimensions.class, priority = 100)
|
||||
public class WorldDimensionsMixin {
|
||||
//TODO:1.19.3 no general registry access available yet as the layerd access is generated after this
|
||||
// @ModifyVariable(method = "bake", argsOnly = true, at = @At("HEAD"))
|
||||
// Registry<LevelStem> wt_bake(Registry<LevelStem> dimensionRegistry) {
|
||||
// final Registry<LevelStem> changedRegistry = WorldBootstrap.enforceInNewWorld(dimensionRegistry);
|
||||
// return changedRegistry;
|
||||
// }
|
||||
}
|
|
@ -14,7 +14,6 @@ public class WorldLoaderMixin {
|
|||
//this is the place a new Registry access gets first istantiated
|
||||
//either when a new Datapack was added to a world on the create-screen
|
||||
//or because we did start world loading
|
||||
//TODO: 1.19.3 This might get replaced by the data Providers...
|
||||
@ModifyArg(method = "load", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/ReloadableServerResources;loadResources(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/core/RegistryAccess$Frozen;Lnet/minecraft/world/flag/FeatureFlagSet;Lnet/minecraft/commands/Commands$CommandSelection;ILjava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"))
|
||||
private static RegistryAccess.Frozen wt_newRegistry(RegistryAccess.Frozen frozen) {
|
||||
WorldBootstrap.InGUI.registryReady(frozen);
|
||||
|
|
|
@ -21,6 +21,4 @@ public class AssignedSurfaceRule {
|
|||
this.ruleSource = ruleSource;
|
||||
this.biomeID = biomeID;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import net.minecraft.world.level.biome.BiomeSource;
|
|||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.SurfaceRules;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -83,8 +82,8 @@ public class SurfaceRuleUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static void injectSurfaceRulesToAllDimensions(WorldGenSettings settings) {
|
||||
for (var entry : settings.dimensions().dimensions().entrySet()) {
|
||||
public static void injectSurfaceRulesToAllDimensions(Registry<LevelStem> dimensionRegistry) {
|
||||
for (var entry : dimensionRegistry.entrySet()) {
|
||||
ResourceKey<LevelStem> key = entry.getKey();
|
||||
LevelStem stem = entry.getValue();
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package org.betterx.worlds.together.world.event;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface OnFinalizeLevelStem {
|
||||
void now(WorldGenSettings worldGenSettings, ResourceKey<LevelStem> dimensionKey, LevelStem stem);
|
||||
void now(Registry<LevelStem> dimensionRegistry, ResourceKey<LevelStem> dimensionKey, LevelStem stem);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package org.betterx.worlds.together.world.event;
|
||||
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
|
||||
public interface OnFinalizeWorldLoad {
|
||||
void done(WorldGenSettings settings);
|
||||
void done(Registry<LevelStem> dimensionRegistry);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import net.minecraft.resources.ResourceKey;
|
|||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
|
@ -42,9 +41,8 @@ public class WorldBootstrap {
|
|||
}
|
||||
|
||||
public static RegistryAccess getLastRegistryAccessOrElseBuiltin() {
|
||||
//TODO: 1.19.3 ther no longer is a general builtin ACCESS
|
||||
// if (LAST_REGISTRY_ACCESS == null)
|
||||
// return BuiltinRegistries.;
|
||||
if (LAST_REGISTRY_ACCESS == null)
|
||||
WorldsTogether.LOGGER.error("Tried to read from global registry!");
|
||||
return LAST_REGISTRY_ACCESS;
|
||||
}
|
||||
|
||||
|
@ -173,7 +171,6 @@ public class WorldBootstrap {
|
|||
Optional<Holder<WorldPreset>> newPreset = setupNewWorldCommon(
|
||||
levelStorageAccess.get(),
|
||||
currentPreset,
|
||||
//TODO: 1.19.13 see if this is the correct Dimensions list
|
||||
worldGenSettingsComponent.settings().selectedDimensions()
|
||||
);
|
||||
if (newPreset != currentPreset) {
|
||||
|
@ -298,11 +295,11 @@ public class WorldBootstrap {
|
|||
}
|
||||
}
|
||||
|
||||
public static void finalizeWorldGenSettings(WorldGenSettings worldGenSettings) {
|
||||
public static void finalizeWorldGenSettings(Registry<LevelStem> dimensionRegistry) {
|
||||
String output = "World Dimensions: ";
|
||||
for (var entry : worldGenSettings.dimensions().dimensions().entrySet()) {
|
||||
for (var entry : dimensionRegistry.entrySet()) {
|
||||
WorldEventsImpl.ON_FINALIZE_LEVEL_STEM.emit(e -> e.now(
|
||||
worldGenSettings,
|
||||
dimensionRegistry,
|
||||
entry.getKey(),
|
||||
entry.getValue()
|
||||
));
|
||||
|
@ -318,26 +315,12 @@ public class WorldBootstrap {
|
|||
}
|
||||
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||
BCLib.LOGGER.info(output);
|
||||
SurfaceRuleUtil.injectSurfaceRulesToAllDimensions(worldGenSettings);
|
||||
SurfaceRuleUtil.injectSurfaceRulesToAllDimensions(dimensionRegistry);
|
||||
|
||||
WorldEventsImpl.ON_FINALIZED_WORLD_LOAD.emit(e -> e.done(worldGenSettings));
|
||||
WorldEventsImpl.ON_FINALIZED_WORLD_LOAD.emit(e -> e.done(dimensionRegistry));
|
||||
}
|
||||
|
||||
public static WorldDimensions enforceInNewWorld(WorldDimensions worldGenSettings) {
|
||||
return WorldGenUtil.repairBiomeSourceInAllDimensions(LAST_REGISTRY_ACCESS, worldGenSettings);
|
||||
public static Registry<LevelStem> enforceInNewWorld(Registry<LevelStem> dimensionRegistry) {
|
||||
return WorldGenUtil.repairBiomeSourceInAllDimensions(LAST_REGISTRY_ACCESS, dimensionRegistry);
|
||||
}
|
||||
|
||||
public static WorldDimensions enforceInLoadedWorld(
|
||||
Optional<RegistryOps<Tag>> registryOps,
|
||||
WorldDimensions worldGenSettings
|
||||
) {
|
||||
if (registryOps.orElse(null) instanceof RegistryOpsAccessor acc) {
|
||||
return WorldGenUtil.repairBiomeSourceInAllDimensions(acc.bcl_getRegistryAccess(), worldGenSettings);
|
||||
//.repairSettingsOnLoad(LAST_REGISTRY_ACCESS, worldGenSettings);
|
||||
} else {
|
||||
WorldsTogether.LOGGER.error("Unable to obtain registryAccess when enforcing generators.");
|
||||
}
|
||||
return worldGenSettings;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.betterx.worlds.together.worldPreset;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.config.Configs;
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
||||
import org.betterx.worlds.together.mixin.common.WorldPresetAccessor;
|
||||
|
@ -106,24 +105,13 @@ public class TogetherWorldPreset extends WorldPreset {
|
|||
public static @NotNull Map<ResourceKey<LevelStem>, ChunkGenerator> loadWorldDimensions() {
|
||||
try {
|
||||
final RegistryAccess registryAccess = WorldBootstrap.getLastRegistryAccessOrElseBuiltin();
|
||||
boolean globalRegistry = false;
|
||||
//TODO: 1.19.3 there is no longer a builtin registry acccess
|
||||
/*if (registryAccess == BuiltinRegistries.ACCESS) {
|
||||
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||
BCLib.LOGGER.info("Loading from builtin Registry");
|
||||
globalRegistry = true;
|
||||
} else */
|
||||
{
|
||||
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||
BCLib.LOGGER.info("Loading from datapack Registry");
|
||||
}
|
||||
final RegistryOps<Tag> registryOps = RegistryOps.create(NbtOps.INSTANCE, registryAccess);
|
||||
if (DEFAULT_DIMENSIONS_WRAPPER == null) {
|
||||
DEFAULT_DIMENSIONS_WRAPPER = new DimensionsWrapper(TogetherWorldPreset.getDimensionsMap(WorldPresets.getDEFAULT()));
|
||||
}
|
||||
|
||||
CompoundTag presetNBT = WorldGenUtil.getPresetsNbt();
|
||||
if (!presetNBT.contains("dimensions") || globalRegistry) {
|
||||
if (!presetNBT.contains("dimensions")) {
|
||||
return DEFAULT_DIMENSIONS_WRAPPER.dimensions;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
"RegistryDataLoaderMixin",
|
||||
"RegistryOpsAccessor",
|
||||
"TagLoaderMixin",
|
||||
"WorldDimensionsMixin",
|
||||
"WorldGenPropertiesMixin",
|
||||
"WorldLoaderMixin",
|
||||
"WorldPresetAccessor",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue