Skip to content

Commit

Permalink
Allow overriding world chunk loading listener
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Dec 10, 2024
1 parent 3b1400d commit 3a3bff1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/main/java/xyz/nucleoid/fantasy/RuntimeWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected RuntimeWorld(MinecraftServer server, RegistryKey<World> registryKey, R
new RuntimeWorldProperties(server.getSaveProperties(), config),
registryKey,
config.createDimensionOptions(server),
VoidWorldProgressListener.INSTANCE,
config.getWorldGenerationProgressListener(),
false,
BiomeAccess.hashSeed(config.getSeed()),
ImmutableList.of(),
Expand All @@ -43,7 +43,6 @@ protected RuntimeWorld(MinecraftServer server, RegistryKey<World> registryKey, R
this.flat = config.isFlat().orElse(super.isFlat());
}


protected RuntimeWorld(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session, ServerWorldProperties properties, RegistryKey<World> worldKey, DimensionOptions dimensionOptions, WorldGenerationProgressListener worldGenerationProgressListener, boolean debugWorld, long seed, List<SpecialSpawner> spawners, boolean shouldTickTime, @Nullable RandomSequencesState randomSequencesState, Style style) {
super(server, workerExecutor, session, properties, worldKey, dimensionOptions, worldGenerationProgressListener, debugWorld, seed, spawners, shouldTickTime, randomSequencesState);
this.style = style;
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/xyz/nucleoid/fantasy/RuntimeWorldConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.WorldGenerationProgressListener;
import net.minecraft.world.Difficulty;
import net.minecraft.world.GameRules;
import net.minecraft.world.dimension.DimensionOptions;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import org.jetbrains.annotations.Nullable;
import xyz.nucleoid.fantasy.util.GameRuleStore;
import xyz.nucleoid.fantasy.util.VoidWorldProgressListener;

/**
* A configuration describing how a runtime world should be constructed. This includes properties such as the dimension
Expand All @@ -32,6 +34,7 @@ public final class RuntimeWorldConfig {
private boolean mirrorOverworldGameRules = false;
private boolean mirrorOverworldDifficulty = false;
private RuntimeWorld.Constructor worldConstructor = RuntimeWorld::new;
private WorldGenerationProgressListener worldGenerationProgressListener = VoidWorldProgressListener.INSTANCE;

private int sunnyTime = Integer.MAX_VALUE;
private boolean raining;
Expand Down Expand Up @@ -402,4 +405,12 @@ public boolean isThundering() {
public TriState isFlat() {
return this.flat;
}

public WorldGenerationProgressListener getWorldGenerationProgressListener() {
return this.worldGenerationProgressListener;
}

public void setWorldGenerationProgressListener(WorldGenerationProgressListener listener) {
this.worldGenerationProgressListener = listener;
}
}

0 comments on commit 3a3bff1

Please sign in to comment.