Compiling version (some features are currently disabled and need a rewrite)
This commit is contained in:
parent
b1f4173ce4
commit
f8bcba4d3a
48 changed files with 488 additions and 506 deletions
|
@ -6,7 +6,7 @@ import net.minecraft.world.level.levelgen.WorldGenSettings;
|
|||
|
||||
public class ChunkGeneratorUtils {
|
||||
public static void restoreOriginalBiomeSourceInAllDimension(WorldGenSettings settings) {
|
||||
for (var entry : settings.dimensions().entrySet()) {
|
||||
for (var entry : settings.dimensions().dimensions().entrySet()) {
|
||||
ResourceKey<LevelStem> key = entry.getKey();
|
||||
LevelStem stem = entry.getValue();
|
||||
|
||||
|
|
|
@ -10,15 +10,15 @@ 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.WorldGenSettings;
|
||||
import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
|
||||
public interface EnforceableChunkGenerator<G extends ChunkGenerator> {
|
||||
WorldGenSettings enforceGeneratorInWorldGenSettings(
|
||||
WorldDimensions enforceGeneratorInWorldGenSettings(
|
||||
RegistryAccess access,
|
||||
ResourceKey<LevelStem> dimensionKey,
|
||||
ResourceKey<DimensionType> dimensionTypeKey,
|
||||
ChunkGenerator loadedChunkGenerator,
|
||||
WorldGenSettings settings
|
||||
WorldDimensions worldDims
|
||||
);
|
||||
|
||||
default boolean togetherShouldRepair(ChunkGenerator chunkGenerator) {
|
||||
|
|
|
@ -12,17 +12,12 @@ import org.betterx.worlds.together.world.event.WorldBootstrap;
|
|||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
|
@ -30,14 +25,11 @@ import net.minecraft.world.level.dimension.DimensionType;
|
|||
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.WorldGenSettings;
|
||||
import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
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 com.google.common.collect.ImmutableMap;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
@ -46,18 +38,18 @@ public class WorldGenUtil {
|
|||
public static final String TAG_PRESET = "preset";
|
||||
public static final String TAG_GENERATOR = "generator";
|
||||
|
||||
public static WorldGenSettings createWorldFromPreset(
|
||||
public static WorldDimensions createWorldFromPreset(
|
||||
ResourceKey<WorldPreset> preset,
|
||||
RegistryAccess registryAccess,
|
||||
long seed,
|
||||
boolean generateStructures,
|
||||
boolean generateBonusChest
|
||||
) {
|
||||
WorldGenSettings settings = registryAccess
|
||||
WorldDimensions settings = registryAccess
|
||||
.registryOrThrow(Registry.WORLD_PRESET_REGISTRY)
|
||||
.getHolderOrThrow(preset)
|
||||
.value()
|
||||
.createWorldGenSettings(seed, generateStructures, generateBonusChest);
|
||||
.createWorldDimensions();
|
||||
|
||||
for (LevelStem stem : settings.dimensions()) {
|
||||
if (stem.generator().getBiomeSource() instanceof BiomeSourceWithSeed bcl) {
|
||||
|
@ -73,7 +65,7 @@ public class WorldGenUtil {
|
|||
return settings;
|
||||
}
|
||||
|
||||
public static WorldGenSettings createDefaultWorldFromPreset(
|
||||
public static WorldDimensions createDefaultWorldFromPreset(
|
||||
RegistryAccess registryAccess,
|
||||
long seed,
|
||||
boolean generateStructures,
|
||||
|
@ -89,28 +81,30 @@ public class WorldGenUtil {
|
|||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static Pair<WorldGenSettings, RegistryAccess.Frozen> defaultWorldDataSupplier(
|
||||
RegistryOps<JsonElement> loaderOps,
|
||||
RegistryAccess.Frozen frozen
|
||||
) {
|
||||
WorldGenSettings defaultGen = createDefaultWorldFromPreset(frozen);
|
||||
RegistryOps<JsonElement> registryOps = RegistryOps.create(JsonOps.INSTANCE, frozen);
|
||||
WorldGenSettings worldGenSettings = WorldGenSettings.CODEC
|
||||
.encodeStart(registryOps, defaultGen)
|
||||
.flatMap(json -> WorldGenSettings.CODEC.parse(
|
||||
loaderOps,
|
||||
json
|
||||
))
|
||||
.getOrThrow(
|
||||
false,
|
||||
Util.prefix(
|
||||
"Error parsing worldgen settings after loading data packs: ",
|
||||
WorldsTogether.LOGGER::error
|
||||
)
|
||||
);
|
||||
// WorldGenSettings worldGenSettings = createDefaultWorldFromPreset(frozen);
|
||||
return Pair.of(worldGenSettings, frozen);
|
||||
}
|
||||
//TODO: 1.19.3 Disabled for now
|
||||
// public static Pair<WorldDimensions, RegistryAccess.Frozen> defaultWorldDataSupplier(
|
||||
// RegistryOps<JsonElement> loaderOps,
|
||||
// RegistryAccess.Frozen frozen
|
||||
// ) {
|
||||
// WorldDimensions defaultGen = createDefaultWorldFromPreset(frozen);
|
||||
// RegistryOps<JsonElement> registryOps = RegistryOps.create(JsonOps.INSTANCE, frozen);
|
||||
//
|
||||
// WorldDimensions worldGenSettings = WorldDimensions.CODEC
|
||||
// .codec().parse(registryOps, defaultGen)
|
||||
// .flatMap(json -> WorldDimensions.CODEC.codec().parse(
|
||||
// loaderOps,
|
||||
// json
|
||||
// ))
|
||||
// .getOrThrow(
|
||||
// false,
|
||||
// Util.prefix(
|
||||
// "Error parsing worldgen settings after loading data packs: ",
|
||||
// WorldsTogether.LOGGER::error
|
||||
// )
|
||||
// );
|
||||
//// WorldGenSettings worldGenSettings = createDefaultWorldFromPreset(frozen);
|
||||
// return Pair.of(worldGenSettings, frozen);
|
||||
// }
|
||||
|
||||
private static final Map<ResourceKey<WorldPreset>, Map<ResourceKey<LevelStem>, LevelStem>> WORLD_PRESET_MAP = new HashMap<>();
|
||||
|
||||
|
@ -136,52 +130,52 @@ public class WorldGenUtil {
|
|||
WORLD_PRESET_MAP.clear();
|
||||
}
|
||||
|
||||
public static void preloadWorldPresets(ResourceManager resourceManager, RegistryAccess.Writable writable) {
|
||||
clearPreloadedWorldPresets();
|
||||
Registry<WorldPreset> registry = writable.registryOrThrow(Registry.WORLD_PRESET_REGISTRY);
|
||||
//for (ResourceKey<WorldPreset> key : registry.registryKeySet())
|
||||
ResourceKey<WorldPreset> key = net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL;
|
||||
{
|
||||
RegistryOps<JsonElement> loaderOps = RegistryOps.createAndLoad(
|
||||
JsonOps.INSTANCE, writable, resourceManager
|
||||
);
|
||||
Holder<WorldPreset> in = registry.getHolderOrThrow(key);
|
||||
if (in.unwrapKey().isPresent()) {
|
||||
RegistryOps<JsonElement> registryOps = RegistryOps.create(JsonOps.INSTANCE, writable);
|
||||
WorldGenSettings settings = WorldGenUtil.createWorldFromPreset(
|
||||
in.unwrapKey().orElseThrow(),
|
||||
writable,
|
||||
RandomSource.create().nextLong(),
|
||||
true,
|
||||
false
|
||||
);
|
||||
WorldGenSettings worldGenSettings = WorldGenSettings.CODEC
|
||||
.encodeStart(registryOps, settings)
|
||||
.flatMap(json -> WorldGenSettings.CODEC.parse(
|
||||
loaderOps,
|
||||
json
|
||||
))
|
||||
.getOrThrow(
|
||||
false,
|
||||
Util.prefix(
|
||||
"Error parsing world preset settings after loading data packs: ",
|
||||
WorldsTogether.LOGGER::error
|
||||
)
|
||||
);
|
||||
ImmutableMap.Builder<ResourceKey<LevelStem>, LevelStem> map = ImmutableMap.builder();
|
||||
for (Map.Entry<ResourceKey<LevelStem>, LevelStem> entry : worldGenSettings.dimensions().entrySet()) {
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
WORLD_PRESET_MAP.put(key, map.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// public static void preloadWorldPresets(ResourceManager resourceManager, RegistryAccess.Writable writable) {
|
||||
// clearPreloadedWorldPresets();
|
||||
// Registry<WorldPreset> registry = writable.registryOrThrow(Registry.WORLD_PRESET_REGISTRY);
|
||||
// //for (ResourceKey<WorldPreset> key : registry.registryKeySet())
|
||||
// ResourceKey<WorldPreset> key = net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL;
|
||||
// {
|
||||
// RegistryOps<JsonElement> loaderOps = RegistryOps.createAndLoad(
|
||||
// JsonOps.INSTANCE, writable, resourceManager
|
||||
// );
|
||||
// Holder<WorldPreset> in = registry.getHolderOrThrow(key);
|
||||
// if (in.unwrapKey().isPresent()) {
|
||||
// RegistryOps<JsonElement> registryOps = RegistryOps.create(JsonOps.INSTANCE, writable);
|
||||
// WorldGenSettings settings = WorldGenUtil.createWorldFromPreset(
|
||||
// in.unwrapKey().orElseThrow(),
|
||||
// writable,
|
||||
// RandomSource.create().nextLong(),
|
||||
// true,
|
||||
// false
|
||||
// );
|
||||
// WorldGenSettings worldGenSettings = WorldGenSettings.CODEC
|
||||
// .encodeStart(registryOps, settings)
|
||||
// .flatMap(json -> WorldGenSettings.CODEC.parse(
|
||||
// loaderOps,
|
||||
// json
|
||||
// ))
|
||||
// .getOrThrow(
|
||||
// false,
|
||||
// Util.prefix(
|
||||
// "Error parsing world preset settings after loading data packs: ",
|
||||
// WorldsTogether.LOGGER::error
|
||||
// )
|
||||
// );
|
||||
// ImmutableMap.Builder<ResourceKey<LevelStem>, LevelStem> map = ImmutableMap.builder();
|
||||
// for (Map.Entry<ResourceKey<LevelStem>, LevelStem> entry : worldGenSettings.dimensions().entrySet()) {
|
||||
// map.put(entry.getKey(), entry.getValue());
|
||||
// }
|
||||
// WORLD_PRESET_MAP.put(key, map.build());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public static WorldGenSettings createDefaultWorldFromPreset(RegistryAccess registryAccess, long seed) {
|
||||
public static WorldDimensions createDefaultWorldFromPreset(RegistryAccess registryAccess, long seed) {
|
||||
return createDefaultWorldFromPreset(registryAccess, seed, true, false);
|
||||
}
|
||||
|
||||
public static WorldGenSettings createDefaultWorldFromPreset(RegistryAccess registryAccess) {
|
||||
public static WorldDimensions createDefaultWorldFromPreset(RegistryAccess registryAccess) {
|
||||
return createDefaultWorldFromPreset(registryAccess, RandomSource.create().nextLong());
|
||||
}
|
||||
|
||||
|
@ -233,9 +227,9 @@ public class WorldGenUtil {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ApiStatus.Internal
|
||||
public static WorldGenSettings repairBiomeSourceInAllDimensions(
|
||||
public static WorldDimensions repairBiomeSourceInAllDimensions(
|
||||
RegistryAccess registryAccess,
|
||||
WorldGenSettings settings
|
||||
WorldDimensions settings
|
||||
) {
|
||||
var dimensions = TogetherWorldPreset.loadWorldDimensions();
|
||||
for (var entry : settings.dimensions().entrySet()) {
|
||||
|
@ -271,7 +265,7 @@ public class WorldGenUtil {
|
|||
settings = enforcer.enforceGeneratorInWorldGenSettings(
|
||||
registryAccess,
|
||||
key,
|
||||
loadedStem.typeHolder().unwrapKey().orElseThrow(),
|
||||
loadedStem.type().unwrapKey().orElseThrow(),
|
||||
loadedChunkGenerator,
|
||||
settings
|
||||
);
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
package org.betterx.worlds.together.mixin.client;
|
||||
|
||||
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
||||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
||||
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
||||
|
||||
import com.mojang.serialization.JsonOps;
|
||||
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.core.RegistryAccess;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.WorldLoader;
|
||||
import net.minecraft.world.level.DataPackConfig;
|
||||
|
@ -17,7 +13,6 @@ import net.minecraft.world.level.levelgen.WorldGenSettings;
|
|||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -65,23 +60,25 @@ public class CreateWorldScreenMixin {
|
|||
//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 (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);
|
||||
};
|
||||
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
|
||||
|
|
|
@ -5,10 +5,13 @@ 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.WorldGenSettings;
|
||||
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;
|
||||
|
||||
|
@ -19,7 +22,7 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Mixin(WorldOpenFlows.class)
|
||||
public abstract class WorldOpenFlowsMixin {
|
||||
|
@ -56,18 +59,19 @@ public abstract class WorldOpenFlowsMixin {
|
|||
public void wt_createFreshLevel(
|
||||
String levelID,
|
||||
LevelSettings levelSettings,
|
||||
RegistryAccess registryAccess,
|
||||
WorldGenSettings worldGenSettings,
|
||||
WorldOptions worldOptions,
|
||||
Function<RegistryAccess, WorldDimensions> function,
|
||||
CallbackInfo ci
|
||||
) {
|
||||
WorldBootstrap.InFreshLevel.setupNewWorld(levelID, worldGenSettings, this.levelSource, Optional.empty());
|
||||
//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,
|
||||
RegistryAccess.Frozen frozen,
|
||||
LayeredRegistryAccess<RegistryLayer> layeredRegistryAccess,
|
||||
WorldData worldData,
|
||||
CallbackInfo ci
|
||||
) {
|
||||
|
|
|
@ -6,7 +6,6 @@ import com.mojang.serialization.DynamicOps;
|
|||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.server.Main;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -23,7 +22,7 @@ abstract public class MainMixin {
|
|||
}
|
||||
|
||||
|
||||
@ModifyArg(method = "method_43613", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;getDataTag(Lcom/mojang/serialization/DynamicOps;Lnet/minecraft/world/level/DataPackConfig;Lcom/mojang/serialization/Lifecycle;)Lnet/minecraft/world/level/storage/WorldData;"))
|
||||
@ModifyArg(method = "method_43613", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;getDataTag(Lcom/mojang/serialization/DynamicOps;Lnet/minecraft/world/level/WorldDataConfiguration;Lnet/minecraft/core/Registry;Lcom/mojang/serialization/Lifecycle;)Lcom/mojang/datafixers/util/Pair;"))
|
||||
private static DynamicOps<Tag> bcl_onCreate(DynamicOps<Tag> dynamicOps) {
|
||||
if (dynamicOps instanceof RegistryOps<Tag> regOps) {
|
||||
WorldBootstrap.DedicatedServer.registryReady(regOps);
|
||||
|
@ -31,9 +30,10 @@ abstract public class MainMixin {
|
|||
return dynamicOps;
|
||||
}
|
||||
|
||||
@ModifyArg(method = "method_43613", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/PrimaryLevelData;<init>(Lnet/minecraft/world/level/LevelSettings;Lnet/minecraft/world/level/levelgen/WorldGenSettings;Lcom/mojang/serialization/Lifecycle;)V"))
|
||||
private static WorldGenSettings bcl_onCreateLevelData(WorldGenSettings worldGenSettings) {
|
||||
WorldBootstrap.DedicatedServer.applyDatapackChangesOnNewWorld(worldGenSettings);
|
||||
return worldGenSettings;
|
||||
}
|
||||
//TODO: 1.19.3 this may be obsolete, as datapacks are handled differently now
|
||||
// @ModifyArg(method = "method_43613", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/PrimaryLevelData;<init>(Lnet/minecraft/world/level/LevelSettings;Lnet/minecraft/world/level/levelgen/WorldOptions;Lnet/minecraft/world/level/storage/PrimaryLevelData$SpecialWorldProperty;Lcom/mojang/serialization/Lifecycle;)V"))
|
||||
// private static WorldGenSettings bcl_onCreateLevelData(WorldGenSettings worldGenSettings) {
|
||||
// WorldBootstrap.DedicatedServer.applyDatapackChangesOnNewWorld(worldGenSettings);
|
||||
// return worldGenSettings;
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package org.betterx.worlds.together.mixin.common;
|
||||
|
||||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
||||
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.progress.ChunkProgressListener;
|
||||
|
@ -29,7 +27,8 @@ public class MinecraftServerMixin {
|
|||
|
||||
@Inject(method = "createLevels", at = @At(value = "HEAD"))
|
||||
private void together_addSurfaceRules(ChunkProgressListener worldGenerationProgressListener, CallbackInfo ci) {
|
||||
WorldBootstrap.finalizeWorldGenSettings(this.worldData.worldGenSettings());
|
||||
//TODO: 1.19.3 Dimensions are handled differently now
|
||||
//WorldBootstrap.finalizeWorldGenSettings(this.worldData.worldGenSettings());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package org.betterx.worlds.together.mixin.common;
|
||||
|
||||
import org.betterx.worlds.together.chunkgenerator.ChunkGeneratorUtils;
|
||||
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.Services;
|
||||
|
@ -31,6 +29,7 @@ public class MinecraftServerMixinLate {
|
|||
ChunkProgressListenerFactory chunkProgressListenerFactory,
|
||||
CallbackInfo ci
|
||||
) {
|
||||
ChunkGeneratorUtils.restoreOriginalBiomeSourceInAllDimension(worldStem.worldData().worldGenSettings());
|
||||
//TODO: 1.19.3 Dimensions are handled differently now
|
||||
//ChunkGeneratorUtils.restoreOriginalBiomeSourceInAllDimension(worldStem.worldData().worldGenSettings());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,69 +1,50 @@
|
|||
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.WorldGenSettings;
|
||||
import net.minecraft.world.level.storage.LevelVersion;
|
||||
import net.minecraft.world.level.storage.PrimaryLevelData;
|
||||
|
||||
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.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Optional;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Mixin(PrimaryLevelData.class)
|
||||
public class PrimaryLevelDataMixin {
|
||||
@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 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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//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) {
|
||||
Optional<RegistryOps<Tag>> registryOps = bcl_lastRegistryAccess.get();
|
||||
WorldBootstrap.InGUI.registryReadyOnLoadedWorld(registryOps);
|
||||
settings = WorldBootstrap.enforceInLoadedWorld(registryOps, settings);
|
||||
bcl_lastRegistryAccess.set(Optional.empty());
|
||||
return settings;
|
||||
}
|
||||
//TODO: 1.19.3 This was changed completley
|
||||
// @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 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));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// //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) {
|
||||
// Optional<RegistryOps<Tag>> registryOps = bcl_lastRegistryAccess.get();
|
||||
// WorldBootstrap.InGUI.registryReadyOnLoadedWorld(registryOps);
|
||||
// settings = WorldBootstrap.enforceInLoadedWorld(registryOps, settings);
|
||||
// bcl_lastRegistryAccess.set(Optional.empty());
|
||||
// return settings;
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -1,48 +1,35 @@
|
|||
package org.betterx.worlds.together.mixin.common;
|
||||
|
||||
import org.betterx.worlds.together.surfaceRules.AssignedSurfaceRule;
|
||||
import org.betterx.worlds.together.surfaceRules.SurfaceRuleRegistry;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
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.ModifyArg;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Mixin(RegistryAccess.class)
|
||||
public interface RegistryAccessMixin {
|
||||
|
||||
@ModifyArg(method = "<clinit>", at = @At(value = "INVOKE", target = "Lnet/minecraft/Util;make(Ljava/util/function/Supplier;)Ljava/lang/Object;"))
|
||||
private static Supplier<ImmutableMap<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>>> together_addRegistry(
|
||||
Supplier<ImmutableMap<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>>> supplier
|
||||
) {
|
||||
|
||||
return () -> {
|
||||
Map<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>> res = supplier.get();
|
||||
ImmutableMap.Builder<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>> builder = ImmutableMap.builder();
|
||||
|
||||
builder.putAll(res);
|
||||
put(builder, SurfaceRuleRegistry.SURFACE_RULES_REGISTRY, AssignedSurfaceRule.CODEC);
|
||||
return builder.build();
|
||||
};
|
||||
}
|
||||
|
||||
@Shadow
|
||||
static <E> void put(
|
||||
ImmutableMap.Builder<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>> builder,
|
||||
ResourceKey<? extends Registry<E>> resourceKey,
|
||||
Codec<E> codec
|
||||
) {
|
||||
throw new RuntimeException("Shadowed Call");
|
||||
}
|
||||
//TODO: 1.19.3 This will probably be a new kind of DataProvider.
|
||||
// @ModifyArg(method = "<clinit>", at = @At(value = "INVOKE", target = "Lnet/minecraft/Util;make(Ljava/util/function/Supplier;)Ljava/lang/Object;"))
|
||||
// private static Supplier<ImmutableMap<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>>> together_addRegistry(
|
||||
// Supplier<ImmutableMap<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>>> supplier
|
||||
// ) {
|
||||
//
|
||||
// return () -> {
|
||||
// Map<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>> res = supplier.get();
|
||||
// ImmutableMap.Builder<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>> builder = ImmutableMap.builder();
|
||||
//
|
||||
// builder.putAll(res);
|
||||
// put(builder, SurfaceRuleRegistry.SURFACE_RULES_REGISTRY, AssignedSurfaceRule.CODEC);
|
||||
// return builder.build();
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// @Shadow
|
||||
// static <E> void put(
|
||||
// ImmutableMap.Builder<ResourceKey<Registry<?>>, RegistryAccess.RegistryData<?>> builder,
|
||||
// ResourceKey<? extends Registry<E>> resourceKey,
|
||||
// Codec<E> codec
|
||||
// ) {
|
||||
// throw new RuntimeException("Shadowed Call");
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
@Mixin(DedicatedServerProperties.WorldGenProperties.class)
|
||||
@Mixin(DedicatedServerProperties.WorldDimensionData.class)
|
||||
public class WorldGenPropertiesMixin {
|
||||
// @ModifyArg(method = "create", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/levelgen/presets/WorldPreset;createWorldGenSettings(JZZ)Lnet/minecraft/world/level/levelgen/WorldGenSettings;"))
|
||||
// public long wt_getSeed(long seed) {
|
||||
|
|
|
@ -84,7 +84,7 @@ public class SurfaceRuleUtil {
|
|||
}
|
||||
|
||||
public static void injectSurfaceRulesToAllDimensions(WorldGenSettings settings) {
|
||||
for (var entry : settings.dimensions().entrySet()) {
|
||||
for (var entry : settings.dimensions().dimensions().entrySet()) {
|
||||
ResourceKey<LevelStem> key = entry.getKey();
|
||||
LevelStem stem = entry.getValue();
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package org.betterx.worlds.together.world.event;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class AdaptWorldPresetSettingEvent extends EventImpl<OnAdaptWorldPresetSettings> {
|
||||
public Optional<Holder<WorldPreset>> emit(Optional<Holder<WorldPreset>> start, WorldGenSettings settings) {
|
||||
public Optional<Holder<WorldPreset>> emit(Optional<Holder<WorldPreset>> start, WorldDimensions worldDims) {
|
||||
for (OnAdaptWorldPresetSettings a : handlers) {
|
||||
start = a.adapt(start, settings);
|
||||
start = a.adapt(start, worldDims);
|
||||
}
|
||||
return start;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.betterx.worlds.together.world.event;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
|
||||
import java.util.Optional;
|
||||
|
@ -10,6 +10,6 @@ import java.util.Optional;
|
|||
public interface OnAdaptWorldPresetSettings {
|
||||
Optional<Holder<WorldPreset>> adapt(
|
||||
Optional<Holder<WorldPreset>> currentPreset,
|
||||
WorldGenSettings worldGenSettings
|
||||
WorldDimensions worldDims
|
||||
);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import net.minecraft.resources.RegistryOps;
|
|||
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;
|
||||
|
@ -42,7 +43,8 @@ public class WorldBootstrap {
|
|||
}
|
||||
|
||||
public static RegistryAccess getLastRegistryAccessOrElseBuiltin() {
|
||||
if (LAST_REGISTRY_ACCESS == null) return BuiltinRegistries.ACCESS;
|
||||
//TODO: 1.19.3 ther no longer is a general builtin ACCESS
|
||||
if (LAST_REGISTRY_ACCESS == null) return BuiltinRegistries.createAccess();
|
||||
return LAST_REGISTRY_ACCESS;
|
||||
}
|
||||
|
||||
|
@ -92,10 +94,10 @@ public class WorldBootstrap {
|
|||
if (currentPreset.isPresent() && LAST_REGISTRY_ACCESS != null) {
|
||||
var presetKey = currentPreset.get().unwrapKey();
|
||||
if (presetKey.isPresent()) {
|
||||
Optional<Holder<WorldPreset>> newPreset = LAST_REGISTRY_ACCESS
|
||||
Optional<Holder.Reference<WorldPreset>> newPreset = LAST_REGISTRY_ACCESS
|
||||
.registryOrThrow(Registry.WORLD_PRESET_REGISTRY)
|
||||
.getHolder(presetKey.get());
|
||||
if (newPreset.isPresent()) currentPreset = newPreset;
|
||||
if (newPreset.isPresent()) currentPreset = (Optional<Holder<WorldPreset>>) (Optional<?>) newPreset;
|
||||
}
|
||||
}
|
||||
return currentPreset;
|
||||
|
@ -131,15 +133,15 @@ public class WorldBootstrap {
|
|||
}
|
||||
|
||||
//Needs to get called after setupWorld
|
||||
public static void applyDatapackChangesOnNewWorld(WorldGenSettings worldGenSettings) {
|
||||
public static void applyDatapackChangesOnNewWorld(WorldDimensions worldDims) {
|
||||
Optional<Holder<WorldPreset>> currentPreset = Optional.of(Helpers.defaultServerPreset());
|
||||
currentPreset = WorldEventsImpl.ADAPT_WORLD_PRESET.emit(currentPreset, worldGenSettings);
|
||||
currentPreset = WorldEventsImpl.ADAPT_WORLD_PRESET.emit(currentPreset, worldDims);
|
||||
|
||||
if (currentPreset.map(Holder::value).orElse(null) instanceof WorldPresetAccessor acc) {
|
||||
TogetherWorldPreset.writeWorldPresetSettings(acc.bcl_getDimensions());
|
||||
} else {
|
||||
WorldsTogether.LOGGER.error("Failed writing together File");
|
||||
TogetherWorldPreset.writeWorldPresetSettings(worldGenSettings.dimensions());
|
||||
TogetherWorldPreset.writeWorldPresetSettings(worldDims.dimensions());
|
||||
}
|
||||
WorldEventsImpl.ON_WORLD_LOAD.emit(OnWorldLoad::onLoad);
|
||||
}
|
||||
|
@ -171,7 +173,8 @@ public class WorldBootstrap {
|
|||
Optional<Holder<WorldPreset>> newPreset = setupNewWorldCommon(
|
||||
levelStorageAccess.get(),
|
||||
currentPreset,
|
||||
worldGenSettingsComponent.settings().worldGenSettings()
|
||||
//TODO: 1.19.13 see if this is the correct Dimensions list
|
||||
worldGenSettingsComponent.settings().selectedDimensions()
|
||||
);
|
||||
if (newPreset != currentPreset) {
|
||||
acc.bcl_setPreset(newPreset);
|
||||
|
@ -188,7 +191,7 @@ public class WorldBootstrap {
|
|||
static Optional<Holder<WorldPreset>> setupNewWorldCommon(
|
||||
LevelStorageSource.LevelStorageAccess levelStorageAccess,
|
||||
Optional<Holder<WorldPreset>> currentPreset,
|
||||
WorldGenSettings worldGenSettings
|
||||
WorldDimensions worldDims
|
||||
) {
|
||||
Helpers.initializeWorldConfig(levelStorageAccess, true);
|
||||
|
||||
|
@ -208,13 +211,13 @@ public class WorldBootstrap {
|
|||
true
|
||||
));
|
||||
|
||||
currentPreset = WorldEventsImpl.ADAPT_WORLD_PRESET.emit(currentPreset, worldGenSettings);
|
||||
currentPreset = WorldEventsImpl.ADAPT_WORLD_PRESET.emit(currentPreset, worldDims);
|
||||
|
||||
if (currentPreset.map(Holder::value).orElse(null) instanceof WorldPresetAccessor acc) {
|
||||
TogetherWorldPreset.writeWorldPresetSettings(acc.bcl_getDimensions());
|
||||
} else {
|
||||
WorldsTogether.LOGGER.error("Failed writing together File");
|
||||
TogetherWorldPreset.writeWorldPresetSettings(worldGenSettings.dimensions());
|
||||
TogetherWorldPreset.writeWorldPresetSettings(worldDims.dimensions());
|
||||
}
|
||||
|
||||
//LifeCycleAPI._runBeforeLevelLoad();
|
||||
|
@ -281,13 +284,13 @@ public class WorldBootstrap {
|
|||
public static class InFreshLevel {
|
||||
public static void setupNewWorld(
|
||||
String levelID,
|
||||
WorldGenSettings worldGenSettings,
|
||||
WorldDimensions worldDims,
|
||||
LevelStorageSource levelSource,
|
||||
Optional<Holder<WorldPreset>> worldPreset
|
||||
) {
|
||||
try {
|
||||
var levelStorageAccess = levelSource.createAccess(levelID);
|
||||
InGUI.setupNewWorldCommon(levelStorageAccess, worldPreset, worldGenSettings);
|
||||
InGUI.setupNewWorldCommon(levelStorageAccess, worldPreset, worldDims);
|
||||
levelStorageAccess.close();
|
||||
} catch (Exception e) {
|
||||
WorldsTogether.LOGGER.error("Failed to initialize data in world", e);
|
||||
|
@ -297,7 +300,7 @@ public class WorldBootstrap {
|
|||
|
||||
public static void finalizeWorldGenSettings(WorldGenSettings worldGenSettings) {
|
||||
String output = "World Dimensions: ";
|
||||
for (var entry : worldGenSettings.dimensions().entrySet()) {
|
||||
for (var entry : worldGenSettings.dimensions().dimensions().entrySet()) {
|
||||
WorldEventsImpl.ON_FINALIZE_LEVEL_STEM.emit(e -> e.now(
|
||||
worldGenSettings,
|
||||
entry.getKey(),
|
||||
|
@ -320,13 +323,13 @@ public class WorldBootstrap {
|
|||
WorldEventsImpl.ON_FINALIZED_WORLD_LOAD.emit(e -> e.done(worldGenSettings));
|
||||
}
|
||||
|
||||
public static WorldGenSettings enforceInNewWorld(WorldGenSettings worldGenSettings) {
|
||||
public static WorldDimensions enforceInNewWorld(WorldDimensions worldGenSettings) {
|
||||
return WorldGenUtil.repairBiomeSourceInAllDimensions(LAST_REGISTRY_ACCESS, worldGenSettings);
|
||||
}
|
||||
|
||||
public static WorldGenSettings enforceInLoadedWorld(
|
||||
public static WorldDimensions enforceInLoadedWorld(
|
||||
Optional<RegistryOps<Tag>> registryOps,
|
||||
WorldGenSettings worldGenSettings
|
||||
WorldDimensions worldGenSettings
|
||||
) {
|
||||
if (registryOps.orElse(null) instanceof RegistryOpsAccessor acc) {
|
||||
return WorldGenUtil.repairBiomeSourceInAllDimensions(acc.bcl_getRegistryAccess(), worldGenSettings);
|
||||
|
|
|
@ -13,7 +13,6 @@ import com.mojang.serialization.Dynamic;
|
|||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.nbt.Tag;
|
||||
|
@ -108,11 +107,13 @@ public class TogetherWorldPreset extends WorldPreset {
|
|||
try {
|
||||
final RegistryAccess registryAccess = WorldBootstrap.getLastRegistryAccessOrElseBuiltin();
|
||||
boolean globalRegistry = false;
|
||||
if (registryAccess == BuiltinRegistries.ACCESS) {
|
||||
//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 {
|
||||
} else */
|
||||
{
|
||||
if (Configs.MAIN_CONFIG.verboseLogging())
|
||||
BCLib.LOGGER.info("Loading from datapack Registry");
|
||||
}
|
||||
|
@ -145,11 +146,7 @@ public class TogetherWorldPreset extends WorldPreset {
|
|||
return preset
|
||||
.get()
|
||||
.value()
|
||||
.createWorldGenSettings(
|
||||
0,
|
||||
true,
|
||||
true
|
||||
)
|
||||
.createWorldDimensions()
|
||||
.dimensions();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,8 @@ public class WorldPresets {
|
|||
private static ResourceKey<WorldPreset> DEFAULT = net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL;
|
||||
|
||||
public static Holder<WorldPreset> get(RegistryAccess access, ResourceKey<WorldPreset> key) {
|
||||
return ((access != null) ? access : BuiltinRegistries.ACCESS)
|
||||
//TODO: 1.19.3 there is no longer a builtin registry acccess
|
||||
return ((access != null) ? access : BuiltinRegistries.createAccess())
|
||||
.registryOrThrow(Registry.WORLD_PRESET_REGISTRY)
|
||||
.getHolderOrThrow(key);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue