33import com .flowpowered .nbt .CompoundTag ;
44import com .grinderwolf .swm .api .world .SlimeWorld ;
55import com .grinderwolf .swm .api .world .properties .SlimeProperties ;
6+ import com .grinderwolf .swm .api .world .properties .SlimePropertyMap ;
67import com .grinderwolf .swm .nms .CraftSlimeWorld ;
78import com .grinderwolf .swm .nms .SlimeNMS ;
89import com .mojang .serialization .Dynamic ;
2425import java .io .IOException ;
2526import java .nio .file .Files ;
2627import java .nio .file .Path ;
28+ import java .util .Properties ;
2729import java .util .UUID ;
2830
2931@ Getter
@@ -94,7 +96,7 @@ public void setDefaultWorlds(SlimeWorld normalWorld, SlimeWorld netherWorld, Sli
9496
9597 private CustomWorldServer createDefaultWorld (SlimeWorld world , ResourceKey <WorldDimension > dimensionKey ,
9698 ResourceKey <net .minecraft .server .v1_16_R2 .World > worldKey ) {
97- WorldDataServer worldDataServer = createWorldData (world . getName (), world . getExtraData () );
99+ WorldDataServer worldDataServer = createWorldData (world );
98100
99101 RegistryMaterials <WorldDimension > registryMaterials = worldDataServer .getGeneratorSettings ().d ();
100102 WorldDimension worldDimension = registryMaterials .a (dimensionKey );
@@ -123,7 +125,7 @@ public void generateWorld(SlimeWorld world) {
123125 throw new IllegalArgumentException ("World " + worldName + " already exists! Maybe it's an outdated SlimeWorld object?" );
124126 }
125127
126- WorldDataServer worldDataServer = createWorldData (world . getName (), world . getExtraData () );
128+ WorldDataServer worldDataServer = createWorldData (world );
127129 RegistryMaterials <WorldDimension > materials = worldDataServer .getGeneratorSettings ().d ();
128130 WorldDimension worldDimension = materials .a (WorldDimension .OVERWORLD );
129131 DimensionManager dimensionManager = worldDimension .b ();
@@ -165,18 +167,27 @@ private World.Environment getEnvironment(SlimeWorld world) {
165167 return World .Environment .valueOf (world .getPropertyMap ().getString (SlimeProperties .ENVIRONMENT ).toUpperCase ());
166168 }
167169
168- private WorldDataServer createWorldData (String worldName , CompoundTag extraData ) {
170+ private WorldDataServer createWorldData (SlimeWorld world ) {
169171 WorldDataServer worldDataServer ;
170- NBTTagCompound extraTag = (NBTTagCompound ) Converter .convertTag (extraData );
172+ NBTTagCompound extraTag = (NBTTagCompound ) Converter .convertTag (world . getExtraData () );
171173 MinecraftServer mcServer = MinecraftServer .getServer ();
172174
175+ SlimePropertyMap propertyMap = world .getPropertyMap ();
176+ Properties properties = new Properties ();
177+ String defaultBiome = propertyMap .getString (SlimeProperties .DEFAULT_BIOME );
178+ String generatorString = "{\" structures\" :{\" structures\" :{}},\" biome\" :\" " + defaultBiome + "\" ,\" layers\" :[]}" ;
179+
180+ properties .put ("generator-settings" , generatorString );
181+ properties .put ("level-type" , "FLAT" );
182+
183+ GeneratorSettings generatorSettings = GeneratorSettings .a (mcServer .getCustomRegistry (), properties );
184+
173185 if (extraTag .hasKeyOfType ("LevelData" , CraftMagicNumbers .NBT .TAG_COMPOUND )) {
174186 NBTTagCompound levelData = extraTag .getCompound ("LevelData" );
175187 int dataVersion = levelData .hasKeyOfType ("DataVersion" , 99 ) ? levelData .getInt ("DataVersion" ) : -1 ;
176188 Dynamic <NBTBase > dynamic = mcServer .getDataFixer ().update (DataFixTypes .LEVEL .a (),
177189 new Dynamic <>(DynamicOpsNBT .a , levelData ), dataVersion , SharedConstants .getGameVersion ()
178190 .getWorldVersion ());
179- GeneratorSettings generatorSettings = GeneratorSettings .a (mcServer .getCustomRegistry ());
180191 Lifecycle lifecycle = Lifecycle .stable ();
181192 LevelVersion levelVersion = LevelVersion .a (dynamic );
182193 WorldSettings worldSettings = WorldSettings .a (dynamic , mcServer .datapackconfiguration );
@@ -186,13 +197,13 @@ private WorldDataServer createWorldData(String worldName, CompoundTag extraData)
186197 } else {
187198 EnumDifficulty difficulty = ((DedicatedServer ) mcServer ).getDedicatedServerProperties ().difficulty ;
188199 EnumGamemode defaultGamemode = ((DedicatedServer ) mcServer ).getDedicatedServerProperties ().gamemode ;
189- WorldSettings worldSettings = new WorldSettings (worldName , defaultGamemode , false ,
200+ WorldSettings worldSettings = new WorldSettings (world . getName () , defaultGamemode , false ,
190201 difficulty , false , new GameRules (), mcServer .datapackconfiguration );
191202 worldDataServer = new WorldDataServer (worldSettings , ((DedicatedServer ) mcServer )
192203 .getDedicatedServerProperties ().generatorSettings , Lifecycle .stable ());
193204 }
194205
195- worldDataServer .checkName (worldName );
206+ worldDataServer .checkName (world . getName () );
196207 worldDataServer .a (mcServer .getServerModName (), mcServer .getModded ().isPresent ());
197208 worldDataServer .c (true );
198209
0 commit comments