[Change] Separated all World-Load related code to a new namespace
This commit is contained in:
parent
67d09676c4
commit
25fa53541f
79 changed files with 1924 additions and 814 deletions
|
@ -1,68 +0,0 @@
|
|||
package org.betterx.bclib.mixin.client;
|
||||
|
||||
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
||||
import org.betterx.bclib.presets.worldgen.BCLWorldPresets;
|
||||
import org.betterx.bclib.presets.worldgen.WorldBootstrap;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
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.ResourceKey;
|
||||
import net.minecraft.server.WorldLoader;
|
||||
import net.minecraft.world.level.DataPackConfig;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
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.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Mixin(CreateWorldScreen.class)
|
||||
public class CreateWorldScreenMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
public WorldGenSettingsComponent worldGenSettingsComponent;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void bcl_init(
|
||||
Screen screen,
|
||||
DataPackConfig dataPackConfig,
|
||||
WorldGenSettingsComponent worldGenSettingsComponent,
|
||||
CallbackInfo ci
|
||||
) {
|
||||
InternalBiomeAPI.initRegistry(worldGenSettingsComponent.registryHolder());
|
||||
}
|
||||
|
||||
//Change the WorldPreset that is selected by default on the Create World Screen
|
||||
@ModifyArg(method = "openFresh", index = 1, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent;<init>(Lnet/minecraft/client/gui/screens/worldselection/WorldCreationContext;Ljava/util/Optional;Ljava/util/OptionalLong;)V"))
|
||||
private static Optional<ResourceKey<WorldPreset>> bcl_NewDefault(Optional<ResourceKey<WorldPreset>> preset) {
|
||||
return BCLWorldPresets.DEFAULT;
|
||||
}
|
||||
|
||||
//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> bcl_NewDefaultSettings(WorldLoader.WorldDataSupplier<WorldGenSettings> worldDataSupplier) {
|
||||
return (resourceManager, dataPackConfig) -> {
|
||||
Pair<WorldGenSettings, RegistryAccess.Frozen> res = worldDataSupplier.get(resourceManager, dataPackConfig);
|
||||
return LevelGenUtil.defaultWorldDataSupplier(res.getSecond());
|
||||
};
|
||||
}
|
||||
|
||||
//this is called when a new world is first created
|
||||
@Inject(method = "createNewWorldDirectory", at = @At("RETURN"))
|
||||
void bcl_createNewWorld(CallbackInfoReturnable<Optional<LevelStorageSource.LevelStorageAccess>> cir) {
|
||||
WorldBootstrap.InGUI.registryReady(this.worldGenSettingsComponent);
|
||||
WorldBootstrap.InGUI.setupNewWorld(cir.getReturnValue(), this.worldGenSettingsComponent);
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package org.betterx.bclib.mixin.client;
|
||||
|
||||
import org.betterx.bclib.interfaces.WorldGenSettingsComponentAccessor;
|
||||
|
||||
import net.minecraft.client.gui.screens.worldselection.WorldGenSettingsComponent;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Mixin(WorldGenSettingsComponent.class)
|
||||
public abstract class WorldGenSettingsComponentMixin implements WorldGenSettingsComponentAccessor {
|
||||
@Override
|
||||
@Accessor("preset")
|
||||
public abstract Optional<Holder<WorldPreset>> bcl_getPreset();
|
||||
|
||||
@Override
|
||||
@Accessor("preset")
|
||||
public abstract void bcl_setPreset(Optional<Holder<WorldPreset>> preset);
|
||||
|
||||
@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()
|
||||
.orElseThrow()
|
||||
.location()
|
||||
.getNamespace()
|
||||
.equals("minecraft"));
|
||||
List<Holder<WorldPreset>> custom = list
|
||||
.stream()
|
||||
.filter(p -> !vanilla.test(p))
|
||||
.collect(Collectors.toCollection(LinkedList::new));
|
||||
custom.addAll(list.stream().filter(vanilla).toList());
|
||||
|
||||
return custom;
|
||||
}
|
||||
}
|
|
@ -5,16 +5,13 @@ import org.betterx.bclib.interfaces.ChunkGeneratorAccessor;
|
|||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.level.StructureManager;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
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;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.betterx.bclib.mixin.common;
|
||||
|
||||
import org.betterx.bclib.presets.worldgen.BCLWorldPresets;
|
||||
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
||||
|
||||
import net.minecraft.server.dedicated.DedicatedServerProperties;
|
||||
|
||||
|
@ -13,6 +13,6 @@ public class DedicatedServerPropertiesMixin {
|
|||
//Make sure the default server properties use our Default World Preset
|
||||
@ModifyArg(method = "<init>", index = 3, at = @At(value = "INVOKE", target = "Lnet/minecraft/server/dedicated/DedicatedServerProperties$WorldGenProperties;<init>(Ljava/lang/String;Lcom/google/gson/JsonObject;ZLjava/lang/String;)V"))
|
||||
private String bcl_init(String levelType) {
|
||||
return BCLWorldPresets.DEFAULT.orElseThrow().location().toString();
|
||||
return WorldPresets.DEFAULT.orElseThrow().location().toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
package org.betterx.bclib.mixin.common;
|
||||
|
||||
import org.betterx.bclib.presets.worldgen.WorldBootstrap;
|
||||
|
||||
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.storage.LevelStorageSource;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
|
||||
@Mixin(Main.class)
|
||||
abstract public class MainMixin {
|
||||
@ModifyVariable(method = "main", ordinal = 0, at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;getSummary()Lnet/minecraft/world/level/storage/LevelSummary;"))
|
||||
private static LevelStorageSource.LevelStorageAccess bc_createAccess(LevelStorageSource.LevelStorageAccess levelStorageAccess) {
|
||||
WorldBootstrap.DedicatedServer.setupWorld(levelStorageAccess);
|
||||
return levelStorageAccess;
|
||||
}
|
||||
|
||||
|
||||
@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;"))
|
||||
private static DynamicOps<Tag> bcl_onCreate(DynamicOps<Tag> dynamicOps) {
|
||||
if (dynamicOps instanceof RegistryOps<Tag> regOps) {
|
||||
WorldBootstrap.DedicatedServer.registryReady(regOps);
|
||||
}
|
||||
return dynamicOps;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package org.betterx.bclib.mixin.common;
|
||||
|
||||
import org.betterx.bclib.api.v2.generator.BCLChunkGenerator;
|
||||
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
|
||||
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
@ -9,8 +8,6 @@ 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.levelgen.WorldGenSettings;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -20,7 +17,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
|
||||
import java.net.Proxy;
|
||||
|
||||
@Mixin(value= MinecraftServer.class, priority = 2000)
|
||||
@Mixin(value = MinecraftServer.class, priority = 2000)
|
||||
public class MinecraftServerMixinLate {
|
||||
@Inject(at = @At("RETURN"), method = "<init>")
|
||||
private void appendGlobalFeatures(
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
package org.betterx.bclib.mixin.common;
|
||||
|
||||
import org.betterx.bclib.presets.worldgen.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 an 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.registryReady(registryOps);
|
||||
settings = WorldBootstrap.enforceInLoadedWorld(registryOps, settings);
|
||||
bcl_lastRegistryAccess.set(Optional.empty());
|
||||
return settings;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package org.betterx.bclib.mixin.common;
|
||||
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(RegistryOps.class)
|
||||
public interface RegistryOpsAccessor {
|
||||
@Accessor("registryAccess")
|
||||
RegistryAccess bcl_getRegistryAccess();
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package org.betterx.bclib.mixin.common;
|
||||
|
||||
import org.betterx.bclib.presets.worldgen.BCLWorldPresets;
|
||||
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.dedicated.DedicatedServerProperties;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
@Mixin(DedicatedServerProperties.WorldGenProperties.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 bcl_create(long seed) {
|
||||
return seed;
|
||||
}
|
||||
|
||||
//Make sure Servers use our Default World Preset
|
||||
@ModifyArg(method = "create", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/core/Registry;getHolder(Lnet/minecraft/resources/ResourceKey;)Ljava/util/Optional;"))
|
||||
private ResourceKey<WorldPreset> bcl_foo(ResourceKey<WorldPreset> resourceKey) {
|
||||
return BCLWorldPresets.DEFAULT.orElseThrow();
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ public class WorldGenRegionMixin {
|
|||
@Shadow
|
||||
private ChunkAccess center;
|
||||
|
||||
//TODO: 1.19 Is it ok to remove this?
|
||||
@Inject(method = "ensureCanWrite", at = @At("HEAD"), cancellable = true)
|
||||
private void be_alterBlockCheck(BlockPos blockPos, CallbackInfoReturnable<Boolean> info) {
|
||||
int x = blockPos.getX() >> 4;
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
package org.betterx.bclib.mixin.common;
|
||||
|
||||
import org.betterx.bclib.api.v2.LifeCycleAPI;
|
||||
import org.betterx.bclib.api.v2.datafixer.DataFixerAPI;
|
||||
import org.betterx.bclib.config.Configs;
|
||||
import org.betterx.bclib.presets.worldgen.WorldBootstrap;
|
||||
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.worldselection.WorldOpenFlows;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.server.ReloadableServerResources;
|
||||
import net.minecraft.world.level.LevelSettings;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
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;
|
||||
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;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Mixin(WorldOpenFlows.class)
|
||||
public abstract class WorldOpenFlowsMixin {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private LevelStorageSource levelSource;
|
||||
|
||||
@Shadow
|
||||
protected abstract void doLoadLevel(Screen screen, String levelID, boolean safeMode, boolean canAskForBackup);
|
||||
|
||||
@Inject(method = "loadLevel", cancellable = true, at = @At("HEAD"))
|
||||
private void bcl_callFixerOnLoad(Screen screen, String levelID, CallbackInfo ci) {
|
||||
WorldBootstrap.InGUI.setupLoadedWorld(levelID, this.levelSource);
|
||||
|
||||
if (DataFixerAPI.fixData(this.levelSource, levelID, true, (appliedFixes) -> {
|
||||
LifeCycleAPI._runBeforeLevelLoad();
|
||||
this.doLoadLevel(screen, levelID, false, false);
|
||||
})) {
|
||||
//cancel call when fix-screen is presented
|
||||
ci.cancel();
|
||||
} else {
|
||||
LifeCycleAPI._runBeforeLevelLoad();
|
||||
if (Configs.CLIENT_CONFIG.suppressExperimentalDialog()) {
|
||||
this.doLoadLevel(screen, levelID, false, false);
|
||||
//cancel call as we manually start the level load here
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "createFreshLevel", at = @At("HEAD"))
|
||||
public void bcl_createFreshLevel(
|
||||
String levelID,
|
||||
LevelSettings levelSettings,
|
||||
RegistryAccess registryAccess,
|
||||
WorldGenSettings worldGenSettings,
|
||||
CallbackInfo ci
|
||||
) {
|
||||
WorldBootstrap.InFreshLevel.setupNewWorld(levelID, worldGenSettings, this.levelSource, Optional.empty());
|
||||
}
|
||||
|
||||
@Inject(method = "createLevelFromExistingSettings", at = @At("HEAD"))
|
||||
public void bcl_createLevelFromExistingSettings(
|
||||
LevelStorageSource.LevelStorageAccess levelStorageAccess,
|
||||
ReloadableServerResources reloadableServerResources,
|
||||
RegistryAccess.Frozen frozen,
|
||||
WorldData worldData,
|
||||
CallbackInfo ci
|
||||
) {
|
||||
//called from the CreateWorldScreenMixin now
|
||||
//LifeCycleAPI.newWorldSetup(levelStorageAccess, worldData.worldGenSettings());
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package org.betterx.bclib.mixin.common;
|
||||
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(WorldPreset.class)
|
||||
public interface WorldPresetAccessor {
|
||||
@Accessor("dimensions")
|
||||
Map<ResourceKey<LevelStem>, LevelStem> bcl_getDimensions();
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
package org.betterx.bclib.mixin.common;
|
||||
|
||||
import org.betterx.bclib.presets.worldgen.BCLWorldPreset;
|
||||
import org.betterx.bclib.presets.worldgen.WorldPresetSettings;
|
||||
|
||||
import com.mojang.datafixers.kinds.App;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Mixin(WorldPreset.class)
|
||||
public class WorldPresetMixin {
|
||||
|
||||
|
||||
@ModifyArg(method = "<clinit>", at = @At(value = "INVOKE", target = "Lcom/mojang/serialization/codecs/RecordCodecBuilder;create(Ljava/util/function/Function;)Lcom/mojang/serialization/Codec;"))
|
||||
private static Function<RecordCodecBuilder.Instance<WorldPreset>, ? extends App<RecordCodecBuilder.Mu<WorldPreset>, WorldPreset>> foo(
|
||||
Function<RecordCodecBuilder.Instance<WorldPreset>, ? extends App<RecordCodecBuilder.Mu<WorldPreset>, WorldPreset>> builder
|
||||
) {
|
||||
final Function<RecordCodecBuilder.Instance<WorldPreset>, App<RecordCodecBuilder.Mu<WorldPreset>, WorldPreset>> CODEC_FUNCTION = builderInstance -> {
|
||||
RecordCodecBuilder<WorldPreset, Map<ResourceKey<LevelStem>, LevelStem>> dimensionsBuilder = Codec
|
||||
.unboundedMap(
|
||||
ResourceKey.codec(Registry.LEVEL_STEM_REGISTRY),
|
||||
LevelStem.CODEC
|
||||
)
|
||||
.fieldOf("dimensions")
|
||||
.forGetter((wp) -> (wp instanceof WorldPresetAccessor)
|
||||
? ((WorldPresetAccessor) wp).bcl_getDimensions()
|
||||
: null);
|
||||
|
||||
RecordCodecBuilder<WorldPreset, Optional<Integer>> sortBuilder = Codec.INT
|
||||
.optionalFieldOf("sort_order")
|
||||
.forGetter(wp -> (wp instanceof BCLWorldPreset)
|
||||
? Optional.of(((BCLWorldPreset) wp).sortOrder)
|
||||
: Optional.empty());
|
||||
|
||||
RecordCodecBuilder<WorldPreset, Optional<WorldPresetSettings>> settingsBuilder = WorldPresetSettings.CODEC
|
||||
.optionalFieldOf("settings")
|
||||
.forGetter(wp -> (wp instanceof BCLWorldPreset)
|
||||
? Optional.of(((BCLWorldPreset) wp).settings)
|
||||
: Optional.empty());
|
||||
|
||||
return builderInstance
|
||||
.group(dimensionsBuilder, sortBuilder, settingsBuilder)
|
||||
.apply(builderInstance, BCLWorldPreset::new);
|
||||
};
|
||||
|
||||
return CODEC_FUNCTION;
|
||||
}
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
package org.betterx.bclib.mixin.common;
|
||||
|
||||
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
|
||||
import org.betterx.bclib.presets.worldgen.BCLWorldPresets;
|
||||
import org.betterx.bclib.presets.worldgen.WorldPresetSettings;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPresets;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||
import net.minecraft.world.level.levelgen.synth.NormalNoise;
|
||||
|
||||
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.ModifyArg;
|
||||
|
||||
@Mixin(WorldPresets.Bootstrap.class)
|
||||
public abstract class WorldPresetsBootstrapMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
private Registry<WorldPreset> presets;
|
||||
@Shadow
|
||||
@Final
|
||||
private Registry<Biome> biomes;
|
||||
@Shadow
|
||||
@Final
|
||||
private Registry<StructureSet> structureSets;
|
||||
@Shadow
|
||||
@Final
|
||||
private Registry<NormalNoise.NoiseParameters> noises;
|
||||
@Shadow
|
||||
@Final
|
||||
private Holder<DimensionType> netherDimensionType;
|
||||
@Shadow
|
||||
@Final
|
||||
private Holder<NoiseGeneratorSettings> netherNoiseSettings;
|
||||
@Shadow
|
||||
@Final
|
||||
private Holder<DimensionType> endDimensionType;
|
||||
@Shadow
|
||||
@Final
|
||||
private Holder<NoiseGeneratorSettings> endNoiseSettings;
|
||||
|
||||
//see WorldPresets.register
|
||||
|
||||
@ModifyArg(method = "run", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/level/levelgen/presets/WorldPresets$Bootstrap;registerCustomOverworldPreset(Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/level/dimension/LevelStem;)Lnet/minecraft/core/Holder;"))
|
||||
private LevelStem bcl_getOverworldStem(LevelStem overworldStem) {
|
||||
WorldPresetSettings.bootstrap();
|
||||
LevelGenUtil.Context netherContext = new LevelGenUtil.Context(
|
||||
this.biomes,
|
||||
this.netherDimensionType,
|
||||
this.structureSets,
|
||||
this.noises,
|
||||
this.netherNoiseSettings
|
||||
);
|
||||
LevelGenUtil.Context endContext = new LevelGenUtil.Context(
|
||||
this.biomes,
|
||||
this.endDimensionType,
|
||||
this.structureSets,
|
||||
this.noises,
|
||||
this.endNoiseSettings
|
||||
);
|
||||
|
||||
BCLWorldPresets.bootstrapPresets(presets, overworldStem, netherContext, endContext);
|
||||
|
||||
return overworldStem;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue