NucleoidMC / fantasy

Library to support creating dimensions at runtime
GNU Lesser General Public License v3.0
95 stars 26 forks source link

Custom seed isn't applied to Fantasy world #19

Closed HyperPigeon closed 1 year ago

HyperPigeon commented 1 year ago

I've been trying to create a copy of the Overworld dimension using Fantasy.

       Long seed = gameSpace.getServer().getOverworld().getRandom().nextLong();        
       ChunkGenerator overworldGen = config.overworld().chunkGenerator();

        RuntimeWorldConfig worldConfig = new RuntimeWorldConfig()
                .setDimensionType(config.overworld().dimensionTypeEntry())
                .setDifficulty(Difficulty.HARD)
                .setGameRule(GameRules.DO_MOB_SPAWNING,true)
                .setGameRule(GameRules.DO_DAYLIGHT_CYCLE, true)
                .setGenerator(overworldGen)
                .setSeed(seed);

However, the world created by the above RuntimeWorldConfig is always the same regardless of the seed value. My guess is that the game is using the seed of the main world instead of the set seed.

Patbox commented 1 year ago

Most likely it's caused by generator having own seed

HyperPigeon commented 1 year ago

That's a bit irritating, does that mean I have to make my own generator?

Patbox commented 1 year ago

Most likely

haykam821 commented 1 year ago

The main issue is that the runtime world must return the custom seed through World#getSeed, including within the ServerWorld constructor. The solution is to override World#getSeed in a way that the seed is initialized before it is called.

sakurawald commented 1 year ago

The main issue is that the runtime world must return the custom seed through World#getSeed, including within the ServerWorld constructor. The solution is to override World#getSeed in a way that the seed is initialized before it is called.

Spent hours debugging and finally found this solution.