New event for finalizing ChunkGenerators
This commit is contained in:
parent
14443761d7
commit
4dc07f6567
7 changed files with 43 additions and 11 deletions
|
@ -1,6 +1,6 @@
|
|||
package org.betterx.worlds.together.mixin.common;
|
||||
|
||||
import org.betterx.worlds.together.surfaceRules.SurfaceRuleUtil;
|
||||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
||||
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
@ -29,6 +29,7 @@ public class MinecraftServerMixin {
|
|||
|
||||
@Inject(method = "createLevels", at = @At(value = "HEAD"))
|
||||
private void together_addSurfaceRules(ChunkProgressListener worldGenerationProgressListener, CallbackInfo ci) {
|
||||
SurfaceRuleUtil.injectSurfaceRulesToAllDimensions(this.worldData.worldGenSettings());
|
||||
WorldBootstrap.finalizeWorldGenSettings(this.worldData.worldGenSettings());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package org.betterx.worlds.together.world.event;
|
||||
|
||||
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);
|
||||
}
|
|
@ -5,6 +5,7 @@ import org.betterx.worlds.together.WorldsTogether;
|
|||
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
||||
import org.betterx.worlds.together.mixin.common.RegistryOpsAccessor;
|
||||
import org.betterx.worlds.together.mixin.common.WorldPresetAccessor;
|
||||
import org.betterx.worlds.together.surfaceRules.SurfaceRuleUtil;
|
||||
import org.betterx.worlds.together.world.WorldConfig;
|
||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||
import org.betterx.worlds.together.worldPreset.WorldGenSettingsComponentAccessor;
|
||||
|
@ -287,6 +288,17 @@ public class WorldBootstrap {
|
|||
}
|
||||
}
|
||||
|
||||
public static void finalizeWorldGenSettings(WorldGenSettings worldGenSettings) {
|
||||
for (var entry : worldGenSettings.dimensions().entrySet()) {
|
||||
WorldEventsImpl.ON_FINALIZE_LEVEL_STEM.emit(e -> e.now(
|
||||
worldGenSettings,
|
||||
entry.getKey(),
|
||||
entry.getValue()
|
||||
));
|
||||
}
|
||||
SurfaceRuleUtil.injectSurfaceRulesToAllDimensions(worldGenSettings);
|
||||
}
|
||||
|
||||
public static WorldGenSettings enforceInNewWorld(WorldGenSettings worldGenSettings) {
|
||||
return WorldGenUtil.repairBiomeSourceInAllDimensions(LAST_REGISTRY_ACCESS, worldGenSettings);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ public class WorldEvents {
|
|||
public static final Event<BeforeWorldLoad> BEFORE_WORLD_LOAD = WorldEventsImpl.BEFORE_WORLD_LOAD;
|
||||
public static final Event<BeforeServerWorldLoad> BEFORE_SERVER_WORLD_LOAD = WorldEventsImpl.BEFORE_SERVER_WORLD_LOAD;
|
||||
public static final Event<OnWorldLoad> ON_WORLD_LOAD = WorldEventsImpl.ON_WORLD_LOAD;
|
||||
|
||||
public static final Event<OnFinalizeLevelStem> ON_FINALIZE_LEVEL_STEM = WorldEventsImpl.ON_FINALIZE_LEVEL_STEM;
|
||||
public static final Event<OnWorldPatch> PATCH_WORLD = WorldEventsImpl.PATCH_WORLD;
|
||||
public static final Event<OnAdaptWorldPresetSettings> ADAPT_WORLD_PRESET = WorldEventsImpl.ADAPT_WORLD_PRESET;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ class WorldEventsImpl {
|
|||
public static final EventImpl<BeforeServerWorldLoad> BEFORE_SERVER_WORLD_LOAD = new EventImpl<>();
|
||||
|
||||
public static final EventImpl<OnWorldLoad> ON_WORLD_LOAD = new EventImpl<>();
|
||||
public static final EventImpl<OnFinalizeLevelStem> ON_FINALIZE_LEVEL_STEM = new EventImpl<>();
|
||||
|
||||
public static final PatchWorldEvent PATCH_WORLD = new PatchWorldEvent();
|
||||
public static final AdaptWorldPresetSettingEvent ADAPT_WORLD_PRESET = new AdaptWorldPresetSettingEvent();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue