|
1 | 1 | package com.hugman.uhc.map; |
2 | 2 |
|
3 | 3 | import com.hugman.uhc.config.UHCConfig; |
| 4 | +import net.minecraft.client.option.GameOptions; |
4 | 5 | import net.minecraft.server.MinecraftServer; |
5 | 6 | import net.minecraft.world.GameRules; |
| 7 | +import net.minecraft.world.gen.GeneratorOptions; |
6 | 8 | import net.minecraft.world.gen.chunk.ChunkGenerator; |
7 | 9 | import xyz.nucleoid.fantasy.RuntimeWorldConfig; |
8 | 10 |
|
9 | 11 | public class UHCMap { |
10 | 12 | private final UHCConfig config; |
11 | 13 | private final ChunkGenerator chunkGenerator; |
| 14 | + private final long seed; |
12 | 15 |
|
13 | | - public UHCMap(UHCConfig config, MinecraftServer server) { |
| 16 | + public UHCMap(UHCConfig config, ChunkGenerator chunkGenerator, long seed) { |
14 | 17 | this.config = config; |
15 | | - //this.chunkGenerator = config.mapConfig().dimension().chunkGenerator(); // temporary fix |
16 | | - this.chunkGenerator = new ModuledChunkGenerator(server, config); |
| 18 | + this.chunkGenerator = chunkGenerator; |
| 19 | + this.seed = seed; |
| 20 | + } |
| 21 | + |
| 22 | + public static UHCMap of(UHCConfig config) { |
| 23 | + long seed = GeneratorOptions.getRandomSeed(); |
| 24 | + return new UHCMap(config, ModuledChunkGenerator.of(config, seed), seed); |
17 | 25 | } |
18 | 26 |
|
19 | 27 | public RuntimeWorldConfig createRuntimeWorldConfig() { |
20 | 28 | return new RuntimeWorldConfig() |
| 29 | + .setSeed(this.seed) |
21 | 30 | .setGenerator(this.chunkGenerator) |
22 | 31 | .setGameRule(GameRules.NATURAL_REGENERATION, false) |
23 | 32 | .setGameRule(GameRules.DO_MOB_SPAWNING, true) |
|
0 commit comments